Downloads · 30 days
27
3% of all-time downloads
OVHaiLLM/fin-pythia-1.4b
fin-pythia-1.4b is a text generation model from OVHaiLLM. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
Fin-Pythia-1.4B is an instruction-finetuned model for sentiment analysis of financial text. It is built by 1) further training Pythia-1.4B model on financial documents, then 2) instruction fine-tuning on financial tas…
Downloads · 30 days
27
3% of all-time downloads
All-time downloads
792
Public
Repo size
11.5 GB
Likes
5
Public
Click a slice to open those files.
.bin5.8 GB · 100%
From the Hugging Face model README
Fin-Pythia-1.4B is an instruction-finetuned model for sentiment analysis of financial text. It is built by 1) further training Pythia-1.4B model on financial documents, then 2) instruction fine-tuning on financial tasks. Although, the model is designed to be used for sentiment analysis, it performs well on other tasks such as named entity recognition (check our FinNLP 2023 paper). Fin-Pythia-1.4B's performance on financial sentiment analysis is on par with much larger financial LLMs and exceeds the performance of general models like GPT-4:
| Models | FPB | FIQA-SA | Headlines | NER |
|---|---|---|---|---|
| BloombergGPT | 0.51 | 0.75 | 0.82 | 0.61 |
| GPT-4 | 0.78 | - | 0.86 | 0.83 |
| FinMA-7B | 0.86 | 0.84 | 0.98 | 0.75 |
| FinMA-30B | 0.88 | 0.87 | 0.97 | 0.62 |
| Pythia-1.4B | 0.84 | 0.83 | 0.97 | 0.69 |
Usage
Your instruction should follow this format:
prompt = "\n".join([
'### Instruction: YOUR_INSTRUCTION',
'### Text: YOUR_SENTENCE',
'### Answer:'])
For example:
### Instruction: Analyze the sentiment of this statement extracted from a financial news article. Provide your answer as either negative, positive, or neutral.\n### Text: The economic uncertainty caused by the ongoing trade tensions between major global economies has led to a sharp decline in investor confidence, resulting in a significant drop in the stock market.\n### Answer:
You could also force the model to generate only the sentiment tokens using the following example code:
prompt = "### Instruction: Analyze the sentiment of this statement extracted from a financial news article. Provide your answer as either negative, positive, or neutral.\n### Text: XYZ reported record-breaking profits for the quarter, exceeding analyst expectations and driving their stock price to new highs.\n### Answer:"
target_classes = ["positive", "negative", "neutral"]
target_class_ids = tokenizer.convert_tokens_to_ids(target_classes)
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to(args.device)
outputs = model(inputs.input_ids)
top_output = outputs.logits[0][-1][target_class_ids].argmax(dim=0)
print(target_classes[top_output])
@misc{lc_finnlp2023,
title={Large Language Model Adaptation for Financial Sentiment Analysis},
author={Rodriguez Inserte Pau and Nakhlé Mariam and Qader Raheel and Caillaut Gaëtan and Liu Jingshu},
year={2023},
}