Instructions to use shivamfet/slm-125m-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use shivamfet/slm-125m-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="shivamfet/slm-125m-instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("shivamfet/slm-125m-instruct") model = AutoModelForCausalLM.from_pretrained("shivamfet/slm-125m-instruct", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use shivamfet/slm-125m-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "shivamfet/slm-125m-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "shivamfet/slm-125m-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/shivamfet/slm-125m-instruct
- SGLang
How to use shivamfet/slm-125m-instruct 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 "shivamfet/slm-125m-instruct" \ --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": "shivamfet/slm-125m-instruct", "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 "shivamfet/slm-125m-instruct" \ --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": "shivamfet/slm-125m-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use shivamfet/slm-125m-instruct with Docker Model Runner:
docker model run hf.co/shivamfet/slm-125m-instruct
shivamfet/slm-125m-instruct
The shivamfet/slm-125m-base base model, supervised fine-tuned into a grounded question-answering model: give it a passage and a question, and it answers using only what's in the passage.
๐ Live demo: https://slm-125m-sft-shivamk.vercel.app
What it does
Reads a source passage and answers extractive questions about it โ who, what, where, which claims, what a clause requires, what a court held. It pulls the answer from the passage and states it directly, rather than answering from memory.
What it does not do
At ~125M parameters this is a small model with real limits, stated honestly:
- No arithmetic. "6% of $50,000", revenue growth deltas โ it cannot compute.
- Little world knowledge. Remove the passage and it has almost nothing to say; it is a reader, not a knowledge base. Pair it with retrieval (RAG) for real use.
- Not RLHF-aligned; do not rely on it for legal or financial advice.
Training
| Method | Supervised fine-tuning (answer-only loss mask) |
| Data | 13,774 grounded QA pairs, teacher-generated + LLM-judged for groundedness, semantically deduplicated |
| Sources | U.S. case law, SEC filings, FineWeb-Edu passages |
| Schedule | 2 epochs, 1รH100, ~4 min, AdamW, cosine LR 2e-5โ2e-6 |
| Selection | Epoch 2 chosen by held-out val loss (later epochs overfit) |
| Val perplexity | 2.60 (answer tokens) |
| Architecture | Llama, 12L / 768d / 12h, 16,384 vocab, 1024 context |
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("shivamfet/slm-125m-instruct")
model = AutoModelForCausalLM.from_pretrained("shivamfet/slm-125m-instruct")
passage = ("The court affirmed the conviction but remanded for resentencing "
"because the trial judge improperly considered the defendant's silence.")
question = "Why did the court remand the case?"
messages = [
{"role": "system", "content": "Answer the question using only the passage."},
{"role": "user", "content": passage + "\n\n" + question},
]
prompt = tok.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
enc = tok(prompt, return_tensors="pt", return_token_type_ids=False)
# Greedy decoding, NO repetition penalty: extractive QA must copy spans from the
# passage, and a penalty >1 pushes the model off the grounded answer.
eos = tok.convert_tokens_to_ids("<|eos|>")
out = model.generate(**enc, max_new_tokens=128, do_sample=False,
eos_token_id=eos, pad_token_id=eos)
print(tok.decode(out[0][enc["input_ids"].shape[1]:], skip_special_tokens=True).strip())
# -> "The court remanded because the trial judge improperly considered the silence."
- Downloads last month
- 43
Model tree for shivamfet/slm-125m-instruct
Base model
shivamfet/slm-125m-base