Instructions to use Sudhanshu1985/slm-125m-raft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Sudhanshu1985/slm-125m-raft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Sudhanshu1985/slm-125m-raft") 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-raft") model = AutoModelForCausalLM.from_pretrained("Sudhanshu1985/slm-125m-raft", 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-raft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Sudhanshu1985/slm-125m-raft" # 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-raft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Sudhanshu1985/slm-125m-raft
- SGLang
How to use Sudhanshu1985/slm-125m-raft 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-raft" \ --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-raft", "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-raft" \ --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-raft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Sudhanshu1985/slm-125m-raft with Docker Model Runner:
docker model run hf.co/Sudhanshu1985/slm-125m-raft
slm-125m-raft
A RAFT (Retrieval-Augmented Fine-Tuning) version of the 125M legal/financial model:
thesreedath/slm-125m-base
fine-tuned to answer from a retrieved set of documents (one golden chunk + distractors)
and to refuse when the answer is not present in any of them.
Companion to Sudhanshu1985/slm-125m-sft
(plain grounded-QA SFT). RAFT adds distractor documents and a 30% "no-golden" negative rate,
so the model learns to ignore irrelevant retrieved chunks and not hallucinate.
Results (held-out validation)
| Base | RAFT | |
|---|---|---|
| Loss | 2.81 | 0.85 |
| Perplexity | 16.54 | 2.34 |
(Val set is the harder RAFT set โ multi-document with distractors.)
Training data
Sudhanshu1985/slm-125m-raft-dataset
โ 23,830 examples derived from the reviewed QA set:
- 70% positive:
question + [golden chunk + 3 distractors](shuffled) โ grounded answer - 30% negative: golden removed / unanswerable โ
"That is not stated in the context." - ~200-token chunks so
golden + distractorsfit the 1024 window.
Recipe: 3 epochs, 1xH100, lr 2e-5 cosine, AdamW, bf16, effective batch 32, loss on the assistant span only.
Chat template
<|bos|><|system|>SYSTEM<|user|>USER<|assistant|>ANSWER<|eos|>
The user turn holds the retrieved documents followed by the question, e.g.:
Context:
[Document 1]
...
[Document 2]
...
<your question>
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("Sudhanshu1985/slm-125m-raft")
model = AutoModelForCausalLM.from_pretrained("Sudhanshu1985/slm-125m-raft")
Limitations
- Knows no facts of its own; works only over the documents you supply.
- 1024-token window โ keep the retrieved doc set short.
- Domain-biased toward US legal/financial register. Not legal or financial advice.
- Downloads last month
- 15
Model tree for Sudhanshu1985/slm-125m-raft
Base model
thesreedath/slm-125m-base