Pragma-1-4B: a compact language model with WebGPU support and a focus on math and coding
2 min readupdated
The Pragma-1-4B model by Yours Research features 3.78B parameters and is built for fast math analysis, coding tasks, document reading, and tool calling. It is optimized to run directly in the browser via Chromium WebGPU at speeds starting from 63 tokens per second. Its architecture combines a hybrid design of linear and full attention, along with a reduced vocabulary of 81,920 tokens while maintaining a 262,144-token context window. This new release is useful for developers of client-side AI apps and researchers studying compact architectures.
Key features
- Strong benchmark scores on MATH-500 and GSM8K despite its compact size of around 3.8B parameters.
- Support for client-side execution in the browser using optimized WGSL Q4 quantization.
- Hybrid attention architecture (32 layers combining Gated DeltaNet and grouped-query attention).
- Massive native context length of up to 262,144 tokens for processing large texts.
What you can do
- Integrate the model into web applications to run locally in the user's browser without a heavy server GPU.
- Solve complex math problems and write code on mobile or low-spec devices.
- Set up structured tool calling in chatbots and agent systems.
Example
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "yours-research/Pragma-1-4B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{"role": "user", "content": "Solve step by step: if x + 1/x = 5, find x^3 + 1/x^3."}
]
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=True,
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.inference_mode():
outputs = model.generate(
**inputs,
max_new_tokens=1024,
temperature=0.6,
top_p=0.95,
)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
Read more
DetailsMetrics: MATH-500 (62.0% BF16), GSM8K (86.0% BF16 / 89.0% Q4), MMLU-Pro (34.0% BF16).
Hardware requirements: about 2.26 GiB VRAM for the WGSL Q4 version in the browser.
Performance: average decoder speed of 63.25 tokens/sec, time to first token (TTFT) of 101.8 ms.
License: Apache-2.0.










Comments