Downloads · 30 days
451
38% of all-time downloads
jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit
Llama3_1_8B_Finance_QLoRA-merged-16bit is a text generation model from jhon53. 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.
<p align="center" <img src="thumbnail.png" alt="Llama 3.1 8B Financial Sentiment QLoRA" width="100%" </p
Downloads · 30 days
451
38% of all-time downloads
All-time downloads
1.2K
Public
Parameters
8B
16.1 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors16.1 GB · 100%
From the Hugging Face model README
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.
| Metric | Base Model | Fine-Tuned |
|---|---|---|
| FPB Accuracy | 89.08% | 97.48% |
| FPB Macro-F1 | 87.65% | 97.25% |
| FiQA-SA Accuracy | 81.20% | 94.02% |
| FiQA-SA Macro-F1 | 67.05% | 83.35% |
meta-llama/Meta-Llama-3.1-8B-InstructFinGPT/fingpt-sentiment-train (~76k examples)Evaluation compares the fine-tuned model against a zero-shot Meta-Llama-3.1-8B-Instruct baseline using the same prompt template.
| Parameter | Value |
|---|---|
| Base model | meta-llama/Meta-Llama-3.1-8B-Instruct |
| Method | QLoRA (4-bit NF4 + BF16 LoRA) |
| LoRA rank | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.05 |
| Target modules | q, k, v, o, gate, up, down projections |
| Optimizer | AdamW 8-bit |
| Learning rate | 2e-4 |
| Scheduler | Cosine |
| Epochs | 3 |
| Early stopping | Patience = 3 |
| Loss | Completion-only cross-entropy |
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)
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)
This model is intended for:
For production financial decision-making, outputs should be independently validated and should not be treated as financial advice.
| Model | Accuracy | Macro-F1 |
|---|---|---|
| Base | 0.8908 | 0.8765 |
| Fine-tuned | 0.9748 | 0.9725 |
| Model | Accuracy | Macro-F1 |
|---|---|---|
| Base | 0.8120 | 0.6705 |
| Fine-tuned | 0.9402 | 0.8335 |
jhon53/Llama3_1_8B_Finance_QLoRAjhon53/Llama3_1_8B_Finance_QLoRA-GGUFIf you use this model in your research or project, please reference the Hugging Face repository:
jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit
Dharmik Bhingradiya
AI/ML Engineer focused on LLM fine-tuning, RAG, model evaluation, MLOps, and production AI systems.
Hugging Face: https://huggingface.co/jhon53