slm-125m-sft
A 125.8M-parameter Llama-architecture model, fully fine-tuned from thesreedath/slm-125m-base for grounded question answering and summarization over legal and financial text (US court opinions, SEC filings, educational web pages). It answers only from the passage it is given and says when the passage does not contain the answer.
Prompt format
<|bos|><|system|>{system}\n<|user|>Context:\n{passage}\n\nQuestion: {question}\n<|assistant|>
For summaries the user turn is {instruction}\n\n{passage}. The model ends its answer with
<|eos|> (id 1). Trained system prompt:
"You are a careful legal and financial assistant. Use only the information in the provided text.
If the text does not contain the answer, say so."
from transformers import AutoTokenizer, AutoModelForCausalLM
tok = AutoTokenizer.from_pretrained("roshith07/slm-125m-sft")
model = AutoModelForCausalLM.from_pretrained("roshith07/slm-125m-sft")
msgs = [{"role": "system", "content": "You are a careful legal and financial assistant. Use only the information in the provided text. If the text does not contain the answer, say so."},
{"role": "user", "content": "Context:\n<passage>\n\nQuestion: <question>"}]
ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt")
out = model.generate(ids, max_new_tokens=200, do_sample=False, repetition_penalty=1.1)
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
Training data
13,809 synthetic examples (train 13,128 / val 681, split by passage) generated from 3,500 passages of the pretraining corpus (40% case law, 40% SEC, 20% FineWeb-Edu): 9,726 grounded QA (10 question types, 3 difficulties), 3,000 summaries (5 formats), 1,083 "not in the text" questions. Generated by gpt-4o-mini / Gemini flash-lite, filtered by an LLM judge (gpt-5-nano / Gemini) plus code checks (evidence-in-passage, format, cross-passage leak, meta-references, exact and embedding near-duplicate removal).
Training
Full fine-tune, 1x H100, bf16 autocast, AdamW (lr 5e-5, cosine to 10%, 3% warmup, wd 0.01), batch 32 sequences, 3 epochs = 1,233 steps, 18,672,483 tokens processed (1,523,406 loss tokens; loss on assistant tokens only), 2.58 min of training. This checkpoint is the lowest validation loss (step 411, end of epoch 1); epochs 2-3 overfit.
| val loss (answer tokens) | perplexity | |
|---|---|---|
| base model | 3.0365 | 20.83 |
| this model | 1.2466 | 3.48 |
License
Derived from thesreedath/slm-125m-base; use is subject to that model's license.
Limitations
A 125M model: it follows the format well but still makes factual slips (wrong qualifiers, occasionally an unsupported detail). Do not rely on it for legal or financial advice; verify answers against the source text. English only, context length 1,024 tokens.
- Downloads last month
- 30
Model tree for roshith07/slm-125m-sft
Base model
thesreedath/slm-125m-base