Downloads · 30 days
9
20% of all-time downloads
fotapol/qwen3-1.7b-financial-rag-lora-v3
qwen3-1.7b-financial-rag-lora-v3 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 is an experimental PEFT LoRA adapter for grounded question answering over retrieved financial-document context. It is the adapter used by the document-rag pet-project MVP.
Downloads · 30 days
9
20% of all-time downloads
All-time downloads
45
Public
Repo size
46.3 MB
Likes
0
Public
Click a slice to open those files.
.safetensors34.9 MB · 69%
From the Hugging Face model README
This is an experimental PEFT LoRA adapter for grounded question answering over retrieved financial-document context. It is the adapter used by the document-rag pet-project MVP.
The adapter is intentionally published separately from the base weights. It must be loaded on Qwen/Qwen3-1.7B at the pinned revision:
70d244cc86ccca08cf5af4e1e306ecf908b1ad5e
V3 was trained to improve behavior that the earlier benchmark-oriented adapter did not learn reliably:
The intended input is a grounded chat prompt containing:
The intended output is a short answer with units and source citations, or exactly:
I cannot answer this question from the supplied context.
This adapter is intended for demonstrations, learning, and experimentation. It is not suitable for autonomous financial, investment, legal, tax, or accounting decisions.
Install compatible versions:
pip install "transformers>=4.57.6" "peft>=0.20.0" accelerate torch
Load the pinned base model and unmerged adapter:
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
BASE_MODEL_ID = "Qwen/Qwen3-1.7B"
BASE_MODEL_REVISION = "70d244cc86ccca08cf5af4e1e306ecf908b1ad5e"
ADAPTER_ID = "fotapol/qwen3-1.7b-financial-rag-lora-v3"
tokenizer = AutoTokenizer.from_pretrained(ADAPTER_ID)
base_model = AutoModelForCausalLM.from_pretrained(
BASE_MODEL_ID,
revision=BASE_MODEL_REVISION,
dtype="auto",
device_map="auto",
)
model = PeftModel.from_pretrained(
base_model,
ADAPTER_ID,
is_trainable=False,
)
model.eval()
messages = [
{
"role": "system",
"content": (
"You are a financial document question-answering assistant. "
"Use only the retrieved context supplied by the user. "
"If the context does not fully support an answer, respond exactly: "
"I cannot answer this question from the supplied context. "
"When an answer is supported, cite the relevant source labels."
),
},
{
"role": "user",
"content": (
"Retrieved context:\n\n"
"[Source 1 | page 4 | chunk_id example-1]\n"
"Revenue was $14.1 million in 2025 and $12.4 million in 2024.\n\n"
"Question:\n"
"By how much did revenue increase from 2024 to 2025?"
),
},
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False,
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
with torch.inference_mode():
generated = model.generate(
**inputs,
max_new_tokens=128,
do_sample=False,
pad_token_id=tokenizer.pad_token_id or tokenizer.eos_token_id,
eos_token_id=tokenizer.eos_token_id,
)
answer = tokenizer.decode(
generated[0, inputs["input_ids"].shape[1] :],
skip_special_tokens=True,
).strip()
print(answer)
The deterministic settings above reproduce the project evaluation configuration. They are not a claim that greedy decoding is optimal for every Qwen3 use case.
Training examples were derived from FinQA and DocFinQA and converted into production-shaped RAG conversations using frozen BM25+dense RRF contexts, source labels, units, visible calculations, and synthetic insufficient-context refusals. Report-level splitting prevents documents from crossing train, validation, and test.
See dataset_manifest.json and training_metadata.json for the exact configuration and counts.
The complete 1,493-example schema-v5 validation split was evaluated with identical frozen prompts for the pinned base and adapter. Both conditions used thinking disabled, greedy decoding, a 4,096-token input limit, and a 128-token output limit.
| Metric | Pinned base | Adapter v3 | Difference |
|---|---|---|---|
| Overall accuracy | 16.28% | 30.48% | +14.20 pp |
| Final-value accuracy | 3.19% | 23.70% | +20.50 pp |
| Unit accuracy | 16.19% | 89.18% | +72.99 pp |
| Citation completion | 5.80% | 75.80% | +70.00 pp |
| Calculation-format accuracy | 0.00% | 93.29% | +93.29 pp |
| Unsupported refusal accuracy | 79.87% | 70.96% | -8.91 pp |
| False-refusal rate | 59.50% | 6.55% | -52.94 pp |
| Invalid-citation rate | 0.00% | 0.00% | 0.00 pp |
These are project-specific validation metrics, not public benchmark or leaderboard results. The held-out schema-v5 test split was not run for this MVP release. Exact evaluation configuration is stored in evaluation/validation_metrics.json.
Always display retrieved context, page information, and chunk IDs beside generated answers.
The adapter follows the Apache-2.0 license of the Qwen3-1.7B base model. Users are responsible for reviewing the licenses and terms of the base model and source datasets.