Downloads · 30 days
24
18% of all-time downloads
fotapol/qwen3-1.7b-financial-qa-lora
qwen3-1.7b-financial-qa-lora is a text generation model from fotapol. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
This repository contains a LoRA adapter for Qwen/Qwen3-1.7B fine-tuned on normalized FinQA and DocFinQA financial question-answering examples.
Downloads · 30 days
24
18% of all-time downloads
All-time downloads
133
Public
Repo size
34.9 MB
Likes
1
Public
Click a slice to open those files.
.safetensors34.9 MB · 100%
From the Hugging Face model README
This repository contains a LoRA adapter for Qwen/Qwen3-1.7B
fine-tuned on normalized FinQA and DocFinQA financial question-answering
examples.
This repository does not contain the base model weights. The adapter must
be loaded on top of Qwen/Qwen3-1.7B.
Qwen/Qwen3-1.7B70d244cc86ccca08cf5af4e1e306ecf908b1ad5eThe adapter is intended for:
The model is experimental and must not be treated as financial, investment, accounting, tax, or legal advice.
The adapter was trained on normalized examples from:
Each training example used:
The training data itself is not included in this repository.
| Parameter | Value |
|---|---|
| Training examples | 11,713 |
| Validation examples | 1,642 |
| Epochs | 1 |
| Maximum sequence length | 4,096 |
| Per-device batch size | 1 |
| Gradient accumulation | 8 |
| Effective batch size | 8 |
| Learning rate | 2e-4 |
| LoRA rank | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.05 |
| Target modules | All linear layers |
| Assistant-only loss | Yes |
| Packing | No |
| Training GPU | NVIDIA Tesla T4 |
Seven train examples, one validation example, and one final-holdout example were excluded because their rendered sequences exceeded 4,096 tokens (nine excluded examples in total).
Two evaluation sets were used:
| Metric | Base model | Fine-tuned adapter |
|---|---|---|
| Exact match | 0.15% | 19.82% |
| Normalized exact match | 0.46% | 19.88% |
| Numeric accuracy | 1.00% | 20.45% |
Numeric evaluation examples:
| Dataset | Base model | Fine-tuned adapter |
|---|---|---|
| FinQA | 1.30% | 25.07% |
| DocFinQA | 0.61% | 14.42% |
Detailed aggregate results are available in the results/ directory.
The reported numeric accuracy uses a deterministic custom evaluator that extracts and compares the first numeric value in each answer.
It is not the official FinQA program-execution or program-accuracy metric.
The evaluator does not fully normalize:
The results should therefore be reported as:
Numeric accuracy using the project evaluator v1.
Install the required libraries:
pip install \
"transformers>=4.57.6" \
"peft>=0.20.0" \
"accelerate>=1.14.0" \
"bitsandbytes>=0.50.0"
Load the base model and adapter:
import torch
from peft import PeftModel
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
BitsAndBytesConfig,
)
BASE_MODEL_ID = "Qwen/Qwen3-1.7B"
BASE_MODEL_REVISION = (
"70d244cc86ccca08cf5af4e1e306ecf908b1ad5e"
)
ADAPTER_ID = "fotapol/qwen3-1.7b-financial-qa-lora"
tokenizer = AutoTokenizer.from_pretrained(
BASE_MODEL_ID,
revision=BASE_MODEL_REVISION,
)
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True,
)
base_model = AutoModelForCausalLM.from_pretrained(
BASE_MODEL_ID,
revision=BASE_MODEL_REVISION,
quantization_config=quantization_config,
device_map="auto",
)
model = PeftModel.from_pretrained(
base_model,
ADAPTER_ID,
)
model.eval()
Generate an answer:
context = """
Revenue increased from $12.4 million in 2024 to
$14.1 million in 2025.
"""
question = """
What was the percentage increase in revenue?
"""
messages = [
{
"role": "system",
"content": (
"Answer the financial question using only the "
"provided context. Return only the final answer."
),
},
{
"role": "user",
"content": (
f"Context:\n{context}\n\n"
f"Question:\n{question}"
),
},
]
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False,
)
inputs = tokenizer(
prompt,
return_tensors="pt",
).to(model.device)
with torch.inference_mode():
output = model.generate(
**inputs,
max_new_tokens=64,
do_sample=False,
pad_token_id=tokenizer.eos_token_id,
)
answer = tokenizer.decode(
output[0, inputs["input_ids"].shape[1]:],
skip_special_tokens=True,
)
print(answer.strip())
The repository includes:
The normalized training examples, split manifest, per-example predictions, full training notebook, and source pipeline are not included in this model release. Paths in the experiment metadata are relative to this repository; omitted artifacts are marked explicitly.
This adapter is released under the Apache License 2.0. See LICENSE for
the complete license text. The Qwen3-1.7B base model is also distributed
under Apache 2.0; the training datasets retain their respective licenses
listed above.
| Package | Version |
|---|---|
| PyTorch | 2.10.0+cu128 |
| Transformers | 4.57.6 |
| Datasets | 4.8.5 |
| Accelerate | 1.14.0 |
| BitsAndBytes | 0.50.0 |
| TRL | 1.9.2 |
| PEFT | 0.20.0 |
@inproceedings{chen2021finqa,
title={FinQA: A Dataset of Numerical Reasoning over Financial Data},
author={Chen, Zhiyu and others},
booktitle={Proceedings of EMNLP},
year={2021}
}
@article{reddy2024docfinqa,
title={DocFinQA: A Long-Context Financial Reasoning Dataset},
author={Reddy, Varshini and others},
year={2024}
}