File size: 701 Bytes
c3bf538
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from sentence_transformers import CrossEncoder
import os

# Define the model name and the directory to save it to
MODEL_NAME = 'cross-encoder/nli-roberta-base'
MODEL_PATH = './sentiment_model'

def main():
    """
    Downloads the specified model from Hugging Face and saves it locally.
    """
    print(f"Downloading model: {MODEL_NAME}")
    
    # Check if the directory exists
    if not os.path.exists(MODEL_PATH):
        os.makedirs(MODEL_PATH)
        
    # This command downloads the model and saves it to the specified path
    model = CrossEncoder(MODEL_NAME)
    model.save(MODEL_PATH)
    
    print(f"Model downloaded and saved to {MODEL_PATH}")

if __name__ == "__main__":
    main()