Run this model with HF Jobs
Run pvlabs/Hlupak-2-13M-Instruct on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/pvlabs/Hlupak-2-13M-Instruct. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/pvlabs/Hlupak-2-13M-Instruct on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/pvlabs/Hlupak-2-13M-Instruct. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/pvlabs/Hlupak-2-13M-Instruct. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use pvlabs/Hlupak-2-13M-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pvlabs/Hlupak-2-13M-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="pvlabs/Hlupak-2-13M-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("pvlabs/Hlupak-2-13M-Instruct") model = AutoModelForCausalLM.from_pretrained("pvlabs/Hlupak-2-13M-Instruct", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use pvlabs/Hlupak-2-13M-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pvlabs/Hlupak-2-13M-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pvlabs/Hlupak-2-13M-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/pvlabs/Hlupak-2-13M-Instruct
- SGLang
How to use pvlabs/Hlupak-2-13M-Instruct 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 "pvlabs/Hlupak-2-13M-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pvlabs/Hlupak-2-13M-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "pvlabs/Hlupak-2-13M-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pvlabs/Hlupak-2-13M-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use pvlabs/Hlupak-2-13M-Instruct with Docker Model Runner:
docker model run hf.co/pvlabs/Hlupak-2-13M-Instruct
Hlupak-2-13M-Instruct
A tiny chat model trained from scratch that thinks before it answers and uses two tools: Wikipedia search and a calculator. It looks facts up instead of guessing, sends harder math to the calculator, and handles short follow-ups like "and of 64?" or "no, I meant 36". It's still a very small model: without search it gets facts wrong, and explanations, lists and poems are weak.
This is the best Hlupak so far. It beats the older Hlupak-14M-Instruct on our test chats (~16/20 vs ~10.5/20) even though it has fewer parameters. For a smaller version, see Hlupak-2-10M-Instruct.
It runs in a web browser. An int8 ONNX export is included in onnx/.
Built by PingVortex Labs.
Model Details
- Parameters: 13M (13.1M with tied embeddings, 10.4M without)
- Architecture: Qwen3, 10 layers, hidden size 320, 5 attention heads, 1 KV head, head dim 64, SwiGLU MLP 832
- Vocabulary: 8,256 tokens (custom BPE, with tool and thinking tokens)
- Context length: 8192 tokens
- Language: English only
- Format: custom chat tags (
<|user|>,<|assistant|>,<|end|>), thoughts in<|think|>, tools via<|tool_call|>/<|tool_result|> - Base model: Hlupak-2-13M-Base
- License: Apache 2.0
Training
- Pretraining: 1.5B tokens on one RTX 5060 Ti in ~3.3 hours: 1.35B at 1k context, then 0.15B at 8k. Educational web text, encyclopedia articles, textbook-style text, math, synthetic arithmetic, chat, and synthetic thinking and search transcripts.
- Fine-tuning: ~125M tokens, 1 epoch. Chats where every reply starts with a short plan in
<|think|>, search chats, calculator chats, follow-ups and corrections ("and of 64", "no I meant ...", "so what's the answer?"), and a "tools off" mode.
Usage
import re
import math
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_path = "pvlabs/Hlupak-2-13M-Instruct"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path, dtype=torch.float16)
model.eval()
END = [tokenizer.convert_tokens_to_ids("<|end|>"), tokenizer.convert_tokens_to_ids("<|end_of_text|>")]
def calc(expr):
# numbers, + - * / ^ ( ) and sqrt() only
if not re.fullmatch(r"(sqrt|[\d.+\-*/^() ])+", expr):
return "Error: bad expression."
v = eval(expr.replace("^", "**").replace("sqrt", "math.sqrt"), {"__builtins__": {}, "math": math})
return str(int(v)) if v == int(v) else f"{v:.6f}".rstrip("0")
def search(query):
# plug in a real search here; the model expects up to 3 numbered results
return "[1] Paris: Paris is the capital and largest city of France."
def reply(chat):
"""chat: the conversation so far as one string, ending with <|assistant|>"""
for _ in range(3): # at most 2 tool calls per reply
inputs = tokenizer(chat, return_tensors="pt", add_special_tokens=False)
with torch.no_grad():
out = model.generate(**inputs, max_new_tokens=200, do_sample=True, temperature=0.5, top_k=40, top_p=0.9,
eos_token_id=END, pad_token_id=tokenizer.pad_token_id)
text = tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)
text = text.replace("<|end_of_text|>", "<|end|>")
chat += text if text.endswith("<|end|>") else text + "<|end|>"
call = re.search(r'<\|tool_call\|>(search|calc)\("(.*?)"\)', text)
if not call:
return chat
result = calc(call[2]) if call[1] == "calc" else search(call[2])
chat += f"<|tool_result|>{result}<|end|><|assistant|>"
return chat
chat = reply("<|user|>whats the square root of 16<|end|><|assistant|>")
chat = reply(chat + "<|user|>and of 64<|end|><|assistant|>")
print(chat)
Output:
<|user|>whats the square root of 16<|end|><|assistant|><|think|>Math: a square root. I will use the calculator for an exact answer.<|/think|><|tool_call|>calc("sqrt(16)")<|end|><|tool_result|>4<|end|><|assistant|>The square root of 16 is 4.<|end|><|user|>and of 64<|end|><|assistant|><|think|>Follow-up math: the same question as before, now the square root of 64. I will use the calculator. The expression is sqrt(64).<|/think|><|tool_call|>calc("sqrt(64)")<|end|><|tool_result|>8<|end|><|assistant|>The square root of 64 is 8.<|end|>
Avoid repetition penalties. They also penalise repeated digits, which breaks arithmetic.
Prompt Format
Each turn is wrapped in a role tag and closed with <|end|>, with no newlines between turns:
<|user|>Your message here<|end|><|assistant|>
- Thinking: every reply starts with a short plan,
<|think|>...<|/think|>, then the answer. - Tools: the model writes
<|tool_call|>search("query")or<|tool_call|>calc("expression")and ends the turn with<|end|>. Append<|tool_result|>result<|end|><|assistant|>and generate again; the model then answers from the result. - Search results: up to 3 lines like
[1] Title: first sentences of the article. The model picks the result that matches and answers from it. - Calculator: expressions use numbers,
+ - * / ^ ( )andsqrt(). - Tools off: start the chat with
<|system|>Tools are off.<|end|>. The model then answers from memory and does math in its thoughts.
The bundled chat template builds plain user and assistant turns: tokenizer.apply_chat_template(messages, add_generation_prompt=True).
Evaluation
Our own tests, all with the same scripts. Test chats are graded by hand. Benchmarks are accuracy in %, with no tools.
| Model | Params | Test chats (20) | Follow-up turns (14) | Fact quiz | Holdout quiz | ARC-Easy | ARC-Challenge | HellaSwag |
|---|---|---|---|---|---|---|---|---|
| Hlupak-2-13M-Instruct | 13.1M | ~16 | 12.5 | 69.9 | 63.2 | 45.3 | 20.4 | 26.3 |
| Hlupak-2-10M-Instruct | 10.0M | ~16 | 11.5 | 69.9 | 55.7 | 42.1 | 20.4 | 25.9 |
| Hlupak-14M-Instruct | 15.7M | ~10.5 | not tested | 77.2 | 61.3 | 43.3 | 20.4 | 26.0 |
- Test chats: 20 scripted chats with real tools (greetings, its name, facts, sums, square roots, percentages, corrections, feelings, remembering your name, a poem, a list, explanations).
- Follow-up turns: 10 chats with short follow-ups and corrections, like "and of 64" or "and isaac newton?".
- Holdout quiz: never used to pick training data, so it's the fairest knowledge test. The fact quiz was used to pick data for older Hlupak models.
- ARC-Challenge and HellaSwag are at chance (25%) for every model this small.
ONNX
onnx/model_int8.onnx (dynamic int8, 21 MB) runs in a web browser with onnxruntime-web and takes an explicit KV cache:
- Inputs:
input_idsint64[1, T],past_kandpast_vfloat32[10, 1, 1, P, 64](useP = 0for the first call) - Outputs:
logitsfor the last position[1, 8256],present_kandpresent_v[10, 1, 1, P+T, 64]
It picks the same next token as the PyTorch model in our check, but its longer answers can drift from the original. For full precision, use the bf16 safetensors.
Limitations
- Without search it often invents facts, names and dates. It can also mix up details from the search results it reads.
- Sometimes answers from memory when it should search.
- Explanations ("why is the sky blue?"), lists and poems are weak and may repeat themselves.
- Follow-ups to answers it gave from memory ("and of Germany?" after the capital of France) don't trigger a new search.
- English only. Not suited to code or anything safety-critical.
Made by PingVortex.
- Downloads last month
- 229