Views
No views yet
mistralai/Mistral-7B-v0.1, designed specifically for financial sentiment analysis. It classifies financial texts into positive, negative, or neutral categories using a lightweight and efficient LoRA-based adaptation.diwakartiwari/mistral-7b-financial-sentimentmistralai/Mistral-7B-v0.11from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3
4# Load tokenizer and model
5tokenizer = AutoTokenizer.from_pretrained("diwakartiwari/mistral-7b-financial-sentiment")
6base_model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1")
7model = PeftModel.from_pretrained(base_model, "diwakartiwari/mistral-7b-financial-sentiment")
8
9# Prepare prompt
10prompt = "<s>[INST] Analyze the financial sentiment of this statement: Company reported record profits [/INST] "
11
12# Generate response
13inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
14outputs = model.generate(**inputs, max_new_tokens=20)
15print(tokenizer.decode(outputs[0], skip_special_tokens=True))
16
17# Expected Output: "The financial sentiment is positive."