slm-125m-sft

An instruction-tuned 125M legal/financial model: [thesreedath/slm-125m-base] (https://huggingface.co/thesreedath/slm-125m-base) fine-tuned on a synthetic, judged, deduplicated, decontaminated grounded-QA dataset.

The base model is a completer. This one follows instructions: it answers questions about a supplied context, summarizes, extracts to JSON, and rewrites.

Results

Base After SFT
Held-out loss 2.66 1.63
Held-out perplexity 14.30 5.10

Chat template (required)

It was trained on one exact format, which ships in tokenizer_config.json:

<|bos|><|system|>SYSTEM<|user|>USER<|assistant|>ANSWER<|eos|>
from transformers import AutoModelForCausalLM, AutoTokenizer

tok = AutoTokenizer.from_pretrained("Sudhanshu1985/slm-125m-sft")
model = AutoModelForCausalLM.from_pretrained("Sudhanshu1985/slm-125m-sft")

msgs = [
    {"role": "system", "content": "You are a legal and financial assistant. Answer only from the provided context. If the answer is not in the context, say so."},
    {"role": "user", "content": "Context:\n<your passage>\n\nWhat date was suit filed?"},
]
text = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
enc = tok(text, return_tensors="pt", add_special_tokens=False)
enc = {k: v for k, v in enc.items() if k in ("input_ids", "attention_mask")}
print(tok.decode(model.generate(**enc, max_new_tokens=90)[0][enc["input_ids"].shape[1]:],
                 skip_special_tokens=True))

Training data

7,279 pairs synthesized with gpt-4.1-mini from a cleaned legal/financial corpus (US case law 50%, SEC filings 35%, educational web 15%), then filtered:

  • LLM-as-judge (1-5 rubric for correctness + grounding); kept >= 4
  • Grounding check (answer/passage token overlap)
  • Near-duplicate removal (char n-gram cosine on question+answer)
  • Decontamination (13-gram overlap vs CaseHOLD / LexGLUE)

Task mix: grounded QA 3,692 (incl. 1,243 "unanswerable" refusals) - summarization 1,457 - extraction-to-JSON 1,043 - rewriting 1,087.

Recipe: 3 epochs, 1xH100, lr 2e-5 cosine, AdamW, bf16, effective batch 32, loss on the assistant span only. ~22M tokens processed.

Limitations (read this)

  • Refusal is unreliable. Despite 1,243 "not stated in the context" training examples, the model will sometimes confidently invent an answer that is not in the context instead of refusing. Judging "is this answerable?" is hard at 125M params. Do not rely on it for factual grounding without verification.
  • It knows no facts of its own; it only works over context you supply.
  • Domain-biased toward US legal/financial register.
  • Not legal or financial advice.
Downloads last month
312
Safetensors
Model size
0.1B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Sudhanshu1985/slm-125m-sft

Finetuned
(10)
this model