Instructions to use Sudhanshu1985/slm-125m-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Sudhanshu1985/slm-125m-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Sudhanshu1985/slm-125m-base")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Sudhanshu1985/slm-125m-base") model = AutoModelForCausalLM.from_pretrained("Sudhanshu1985/slm-125m-base") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Sudhanshu1985/slm-125m-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Sudhanshu1985/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": "Sudhanshu1985/slm-125m-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Sudhanshu1985/slm-125m-base
- SGLang
How to use Sudhanshu1985/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 "Sudhanshu1985/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": "Sudhanshu1985/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 "Sudhanshu1985/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": "Sudhanshu1985/slm-125m-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Sudhanshu1985/slm-125m-base with Docker Model Runner:
docker model run hf.co/Sudhanshu1985/slm-125m-base
SLM-125M-base
A 125.8M-parameter, Llama-style language model pretrained from scratch on a cleaned, deduplicated, and decontaminated legal + financial corpus. Give it the start of a sentence and it continues in the legal/financial register.
This is a base completer, not a chat model. It was trained on next-token prediction only, so it continues text rather than answering questions.
Model details
| Parameters | 125,847,552 (~125.8M) |
| Architecture | Llama-style (LlamaForCausalLM) |
| Layers | 12 |
| Hidden size | 768 |
| Attention heads | 12 (head dim 64), MHA (12 KV heads) |
| MLP | SwiGLU, inner 3072 |
| Normalization | RMSNorm, pre-norm |
| Positional | RoPE (theta 10000) |
| Context length | 1024 |
| Vocab | 16,384 (byte-level BPE, trained from scratch) |
| Embeddings | tied (input = output) |
| Precision | bf16 |
Training data
A ~2.04B-token corpus built from three public, ungated sources, streamed and filtered through a deterministic cleaning + dedup + decontamination pipeline:
| Source | Content | Share |
|---|---|---|
HFforLegal/case-law |
US court opinions | ~40% |
PleIAs/SEC |
SEC filings (10-K, etc.) | ~40% |
HuggingFaceFW/fineweb-edu |
Educational web text | ~20% |
The corpus was decontaminated against CaseHOLD / LexGLUE (13-gram overlap removed) and deduplicated (exact + MinHash/LSH near-duplicate removal).
Training recipe
| Knob | Value |
|---|---|
| Objective | next-token cross-entropy |
| Hardware | 8Γ H100 (single-node DDP) |
| Epochs | 1 (~2.04B tokens seen) |
| Optimizer | AdamW, betas (0.9, 0.95), weight decay 0.1 |
| LR | 6e-4 β 6e-5, cosine decay, 200M-token warmup |
| Global batch | ~524,288 tokens/step |
| Grad clip | 1.0 |
| Steps | 3,889 |
Results
Held-out validation perplexity: 11.01 (val loss 2.42) on a 1% held-out split
(20.6M tokens). Perplexity was still descending at the end of the single epoch
(step 2000 β 12.54, step 3000 β 11.27, final β 11.01), so additional epochs would
lower it further. Total compute cost to train: **$11**.
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("Sudhanshu1985/slm-125m-base")
model = AutoModelForCausalLM.from_pretrained("Sudhanshu1985/slm-125m-base")
prompt = "The plaintiff alleges that the defendant"
inputs = tok(prompt, return_tensors="pt")
out = model.generate(
**inputs,
max_new_tokens=80,
min_new_tokens=40,
do_sample=True,
temperature=0.8,
top_p=0.95,
top_k=40,
repetition_penalty=1.3,
)
print(tok.decode(out[0], skip_special_tokens=True))
Example completions
- "The plaintiff alleges that the defendant" β "breached its contract of employment... In order to prove fraud, a party must show: (1) The existence of a confidential relationship; (2) the absence or violation by one party of any duty owed..."
- "Pursuant to the terms of this Agreement," β "the parties have agreed as follows: 1. ...all disputes... shall be subject to the jurisdiction of said Court..."
- "The Company's net revenues for the fiscal year" β "ended September 30, 1996 were $305.1 million. The operating loss in fiscal 1995 was primarily attributable to..."
Limitations
- Base completer, not a chatbot. It continues text; it does not follow instructions or answer questions.
- Does not know facts. At 125M parameters a model holds only a small amount of usable knowledge; grounded facts would require retrieval (RAG).
- Domain-biased. It speaks the legal register fluently; non-legal prompts drift toward that register.
- Trained on US legal/financial + educational web text; may reflect biases in those sources. Not legal or financial advice.
Provenance
Pretrained from random weights (nothing fine-tuned). Pipeline: stream 3 datasets β rule-based cleaning β dedup + decontaminate β 16K byte-level BPE β pack 1024-token windows β pretrain on 8Γ H100. Based on the Vizuara AI Labs slm-125m-from-scratch recipe.
- Downloads last month
- 485