--- license: apache-2.0 library_name: transformers pipeline_tag: text-generation tags: - llama - legal - finance - small-language-model --- # 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. **🌐 Live demo:** https://slm-125m-shivamk.vercel.app ## 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 ```python 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.