jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit
Llama 3.1 8B Financial Sentiment — QLoRA
<p align="center"> <img src="thumbnail.png" alt="Llama 3.1 8B Financial Sentiment QLoRA" width="100%"> </p>
A finance-domain fine-tuned Llama 3.1 8B Instruct model for 3-class financial sentiment classification: negative, neutral, and positive.
The model was fine-tuned with QLoRA, using a 4-bit NF4 frozen base model and BF16 LoRA adapters.
Highlights
- Base:
meta-llama/Meta-Llama-3.1-8B-Instruct - Fine-tuning: QLoRA
- Quantization: 4-bit NF4 during adapter training
- Adapter: LoRA, BF16
- Task: Financial sentiment classification
- Training data:
FinGPT/fingpt-sentiment-train(~76k examples) - License: Apache 2.0
Evaluation compares the fine-tuned model against a zero-shot Meta-Llama-3.1-8B-Instruct baseline using the same prompt template.
Model Details
Quick Start
Transformers
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{
"role": "user",
"content": "The company's quarterly earnings exceeded analyst expectations. "
"The stock price increased following the announcement."
}
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=50,
do_sample=False,
)
response = tokenizer.decode(
outputs[0][inputs["input_ids"].shape[-1]:],
skip_special_tokens=True,
)
print(response)Pipeline
from transformers import pipeline
pipe = pipeline(
"text-generation",
model="jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit",
)
messages = [
{
"role": "user",
"content": "The company reported record revenue and strong quarterly growth."
}
]
output = pipe(messages)
print(output)Intended Use
This model is intended for:
- Financial sentiment analysis
- Research and experimentation with finance-focused LLMs
- Classification of financial news, statements, and market-related text
- Building finance-oriented NLP and GenAI applications
For production financial decision-making, outputs should be independently validated and should not be treated as financial advice.
Limitations
- Model performance depends on the domain and wording of the input.
- Financial language can be ambiguous and context-dependent.
- Benchmark performance does not guarantee production performance.
- The model may produce incorrect or overconfident classifications.
- Human review and application-specific evaluation are recommended for high-impact use cases.
Evaluation
Financial PhraseBank (FPB)
FiQA-SA (Out-of-Domain)
Related Models
- QLoRA adapters:
jhon53/Llama3_1_8B_Finance_QLoRA - GGUF version:
jhon53/Llama3_1_8B_Finance_QLoRA-GGUF
Citation
If you use this model in your research or project, please reference the Hugging Face repository:
jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bitAuthor
Dharmik Bhingradiya
AI/ML Engineer focused on LLM fine-tuning, RAG, model evaluation, MLOps, and production AI systems.
Hugging Face: https://huggingface.co/jhon53
