Text Generation
Transformers
Safetensors
llama
legal
finance
small-language-model
text-generation-inference
Instructions to use shivamfet/slm-125m-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use shivamfet/slm-125m-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="shivamfet/slm-125m-base")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("shivamfet/slm-125m-base") model = AutoModelForCausalLM.from_pretrained("shivamfet/slm-125m-base") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use shivamfet/slm-125m-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "shivamfet/slm-125m-base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "shivamfet/slm-125m-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/shivamfet/slm-125m-base
- SGLang
How to use shivamfet/slm-125m-base 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-base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "shivamfet/slm-125m-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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-base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "shivamfet/slm-125m-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use shivamfet/slm-125m-base with Docker Model Runner:
docker model run hf.co/shivamfet/slm-125m-base
shivamfet/slm-125m-base
A ~125M-parameter Llama-architecture language model pretrained from scratch on a legal- and finance-heavy corpus (U.S. case law, SEC filings, and a slice of FineWeb-Edu). Built as a compact domain SLM; not instruction-tuned.
Model details
| Parameters | ~125.8M (tied embeddings) |
| Architecture | Llama (12 layers, 768 hidden, 12 heads) |
| Vocab | 16,384 (byte-level BPE, trained on-corpus) |
| Context length | 1024 |
| Precision | bf16 autocast (fp32 master weights) |
Training
- Corpus: ~2.4B unique tokens (case-law / SEC / FineWeb-Edu), deduplicated (MinHash LSH) and decontaminated against CaseHOLD / LexGLUE eval sets.
- Schedule: 4 epochs (~8.15B tokens seen) on 8xH100, cosine LR (6e-4 -> 6e-5), token-based warmup, fused AdamW.
- Result: validation perplexity 16.0 -> 8.35, monotonic, no divergence.
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("shivamfet/slm-125m-base")
model = AutoModelForCausalLM.from_pretrained("shivamfet/slm-125m-base")
ids = tok("The plaintiff shall bear the burden of proving",
return_tensors="pt", return_token_type_ids=False)
out = model.generate(**ids, max_new_tokens=80, do_sample=True,
top_k=50, temperature=0.8, pad_token_id=tok.pad_token_id)
print(tok.decode(out[0], skip_special_tokens=True))
Limitations
Base model only — no instruction tuning or RLHF. It can produce plausible-sounding but incorrect legal/financial text and must not be relied on for legal or financial advice. Reflects biases in its public training sources.
- Downloads last month
- -