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)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Sudhanshu1985/slm-125m-sft") model = AutoModelForCausalLM.from_pretrained("Sudhanshu1985/slm-125m-sft", device_map="auto") 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=256) 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
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?"
}
]
}'slm-125m-sft
An instruction-tuned 125M legal/financial model: thesreedath/slm-125m-base
fine-tuned on a synthetic, LLM-judged, decontaminated grounded-QA dataset.
The base model is a completer. This one follows instructions: it answers questions grounded in a supplied context, and refuses ("That is not stated in the context.") when the answer is not present.
Results (held-out validation)
| Base | After QA SFT | |
|---|---|---|
| Loss | 2.61 | 0.69 |
| Perplexity | 13.61 | 2.00 |
Chat template (required)
Trained on one exact format, shipped 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
24,713 grounded-QA pairs (23,204 train / 474 val after filtering to the 1024-token window), synthesized from a cleaned legal/financial + web corpus and filtered by an LLM judge (1-5 rubric for correctness + grounding; kept >= 4):
| Source | Pairs | Share |
|---|---|---|
US case law (HFforLegal/case-law) |
13,005 | 52.6% |
SEC filings (PleIAs/SEC) |
9,309 | 37.7% |
Educational web (HuggingFaceFW/fineweb-edu) |
2,399 | 9.7% |
Task types: lookup, reasoning, and unanswerable (refusals). ~32% of the pairs are unanswerable, which directly trains reliable refusal behavior.
Recipe: 3 epochs, 1xH100, lr 2e-5 cosine, AdamW, bf16, effective batch 32, loss on the assistant span only.
Behaviour
| Prompt type | Example output |
|---|---|
| lookup | "The plaintiff filed suit on March 14, 1994..." |
| reasoning | "...because DeWitt failed to establish that Northstar had actual or constructive notice of the defect." |
| unanswerable | "That is not stated in the context." |
Limitations
- It knows no facts of its own; it only works over context you supply.
- Domain-biased toward US legal/financial register.
- 1024-token context window; longer inputs must be chunked.
- Not legal or financial advice.
- Downloads last month
- 54
Model tree for Sudhanshu1985/slm-125m-sft
Base model
thesreedath/slm-125m-base
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?" } ] }'