Tantra
AI Labs
Models
Datasets
Research
Blog
About
Careers
Contact
GitHub
Hugging Face
LinkedIn
Hugging Face ↗
Learn
TRACK
Prompting & structured outputs
Chat templates, JSON output, sampling and few-shot vs reasoning.
4 answers · 2,000+ words each
System Prompts vs. User Prompts: How Chat Templates Work
A chat template is the Jinja program that turns role-tagged messages into the exact token sequence a model was trained on. Roles are a serialization convention, not a privilege system: some templates merge the system message into the first user turn, and every model expects different delimiters. Render the template yourself, pin it with the weights, and never treat the system role as a security boundary.
Read answer
How to Force Valid JSON Output from Any Open-Weight LLM
Getting JSON out of an open-weight model is a stack, not a prompt. Ask for it explicitly, prefill the opening brace, and where the server supports it, constrain decoding with a JSON schema or GBNF grammar so invalid tokens are masked at every step. Grammar guarantees syntax, never meaning, so validate with a schema-aware parser and retry with the error text.
Read answer
Temperature, Top-P, and Repetition Penalty Explained
Temperature divides logits before softmax, sharpening or flattening the distribution without changing the ranking. Top-p then keeps the smallest set of tokens whose probabilities sum to p and renormalises. Repetition penalties subtract from tokens already seen and quietly wreck JSON, code and quoted names. Set temperature first, leave top-p near 1.0, and use penalties sparingly.
Read answer
Few-Shot Prompting vs. Native thinking Reasoning
Few-shot prompting teaches format and task framing through pattern completion; it does not install an algorithm. Reasoning models are trained with reinforcement learning to produce their own long chain of thought, so examples mostly add cost and anchor the model to a shorter, shallower trace. Use demonstrations for output shape, and let native reasoning handle the method.
Read answer