Text Generation
Transformers
Safetensors
English
llama
text-generation-inference
finance
conversational
Instructions to use jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit") model = AutoModelForCausalLM.from_pretrained("jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit
- SGLang
How to use jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit with Docker Model Runner:
docker model run hf.co/jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit
Llama-3.1-8B Financial Sentiment — QLoRA
LoRA adapters fine-tuned on FinGPT/fingpt-sentiment-train with QLoRA: 4-bit NF4 frozen base + bf16 LoRA adapters (r=16, alpha=32, dropout=0.05).
Task: 3-class financial sentiment — negative / neutral / positive
Evaluation Results
| Dataset | Base Accuracy | FT Accuracy | Base Macro-F1 | FT Macro-F1 |
|---|---|---|---|---|
| FPB in-domain | 0.8908 | 0.9748 | 0.8765 | 0.9725 |
| FiQA-SA OOD | 0.8120 | 0.9402 | 0.6705 | 0.8335 |
Baseline = zero-shot Meta-Llama-3.1-8B-Instruct with the same prompt template.
Quick Start
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = AutoModelForCausalLM.from_pretrained(
"meta-llama/Meta-Llama-3.1-8B-Instruct",
load_in_4bit=True,
device_map="auto",
)
model = PeftModel.from_pretrained(base, "jhon53/Llama3_1_8B_Finance_QLoRA")
tokenizer = AutoTokenizer.from_pretrained("jhon53/Llama3_1_8B_Finance_QLoRA")
Training Details
| Param | Value |
|---|---|
| Base model | meta-llama/Meta-Llama-3.1-8B-Instruct |
| Method | QLoRA (4-bit NF4 + LoRA bf16) |
| LoRA rank (r) | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.05 |
| Target modules | q, k, v, o, gate, up, down projections |
| Training data | FinGPT/fingpt-sentiment-train (~76k) |
| Optimizer | AdamW 8-bit |
| Learning rate | 2e-4 (cosine schedule) |
| Epochs | 3 (early stopping, patience=3) |
| Loss | Completion-only cross-entropy |
Related Repos
- GGUF q4_k_m: jhon53/Llama3_1_8B_Finance_QLoRA-GGUF
- model: jhon53/Llama3_1_8B_Finance_QLoRA
Uploaded finetuned model
- Developed by: jhon53
- License: apache-2.0
- Finetuned from model : unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit
- Downloads last month
- 32
Model tree for jhon53/Llama3_1_8B_Finance_QLoRA-merged-16bit
Base model
meta-llama/Llama-3.1-8B Finetuned
meta-llama/Llama-3.1-8B-Instruct