One of 13 models in a controlled study of how far a small language model can be pushed on US legal and financial text. Every version was trained on the same data, evaluated on the same frozen held-out set, and scored by the same blind LLM judge, so the stages are directly comparable. Compare them side by side in the
SLM Arena.
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4MODEL = "Ace-2504/slm-500m-raft"
5model = AutoModelForCausalLM.from_pretrained(MODEL, torch_dtype=torch.bfloat16).eval()
6tok = AutoTokenizer.from_pretrained(MODEL)
7
8SYS = ('You are a precise legal and financial assistant. Answer clearly using the '
9 'provided context; do not invent facts.')
10user = 'Context:\n<passage>\n\nQuestion: <your question>'
11
12# Custom chat scheme. NOTE: never prepend <|bos|> — it was left untrained.
13prompt = f'<|system|>\n{SYS}<|eos|>\n<|user|>\n{user}<|eos|>\n<|assistant|>\n'
14enc = tok(prompt, return_tensors='pt', add_special_tokens=False).to(model.device)
15eos = tok.convert_tokens_to_ids('<|eos|>')
16out = model.generate(**enc, max_new_tokens=160, eos_token_id=eos,
17 pad_token_id=eos) # pad and eos share an id here
18print(tok.decode(out[0, enc['input_ids'].shape[1]:], skip_special_tokens=True))
All under
Ace-2504 except the two imported bases.
1@misc{sandhu2026slm,
2 title = {Small Language Models for Legal and Financial Text: a controlled study of
3 pretraining, instruction tuning, retrieval augmentation and alignment},
4 author = {Harman Sandhu},
5 year = {2026},
6 note = {https://slm-arena-harman.vercel.app}
7}