marcev/financebert
0462
1from transformers import AutoModelForSequenceClassification, AutoTokenizer2 3# Correctly formatted path using a raw string to prevent escape sequence errors4model_path = r'C:\Users\marco\financebert'5 6# Load the tokenizer and model7tokenizer = AutoTokenizer.from_pretrained(model_path)8model = AutoModelForSequenceClassification.from_pretrained(model_path)9 10# Update the model configuration with label mappings11model.config.id2label = {0: 'Negative', 1: 'Neutral', 2: 'Positive'}12model.config.label2id = {'Negative': 0, 'Neutral': 1, 'Positive': 2}13 14# Save the tokenizer and model with the updated configuration15tokenizer.save_pretrained(model_path)16model.save_pretrained(model_path)17 18print("Tokenizer and model saved with updated labels.")