Instructions to use Sudhanshu1985/slm-125m-sft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Sudhanshu1985/slm-125m-sft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Sudhanshu1985/slm-125m-sft") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Sudhanshu1985/slm-125m-sft") model = AutoModelForCausalLM.from_pretrained("Sudhanshu1985/slm-125m-sft") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Sudhanshu1985/slm-125m-sft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Sudhanshu1985/slm-125m-sft" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Sudhanshu1985/slm-125m-sft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Sudhanshu1985/slm-125m-sft
- SGLang
How to use Sudhanshu1985/slm-125m-sft 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 "Sudhanshu1985/slm-125m-sft" \ --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": "Sudhanshu1985/slm-125m-sft", "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 "Sudhanshu1985/slm-125m-sft" \ --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": "Sudhanshu1985/slm-125m-sft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Sudhanshu1985/slm-125m-sft with Docker Model Runner:
docker model run hf.co/Sudhanshu1985/slm-125m-sft
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
Model tree for Sudhanshu1985/slm-125m-sft
Base model
thesreedath/slm-125m-base