Instructions to use paritok/paritok-4b-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use paritok/paritok-4b-v1 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B-Instruct-2507") model = PeftModel.from_pretrained(base_model, "paritok/paritok-4b-v1") - Notebooks
- Google Colab
- Kaggle
Paritok-4B-v1
The first open-source compression model trained specifically for coding agents.
Cut Claude / GPT input token bills by up to 95% while retaining 86.5% of full-context solve quality on SWE-bench Verified.
π₯ TL;DR
~74%Fewer tokensTypical CR = 25.7% Up to 95% on long sessions |
86.5%Solve quality retainedSWE-bench Verified Matches gpt-4.1-mini |
4BSelf-hostable LoRASingle 24GB GPU Apache 2.0, zero fee |
β¨ Why Paritok?
- π¨ Code-native. Trained end-to-end on 45K real coding-agent trajectories (
file_read,bash_command,log_output...). Preserves function names, imports, paths, and error strings while compressing. - π ~74% fewer tokens on typical workloads β up to 95% on heavy long-session traffic.
- π° Up to 95% off your input token bill on Claude Sonnet / GPT-4 (74% typical). Long-session teams save thousands per month.
- π― 86.5% of full-context solve quality retained on SWE-bench Verified β matching gpt-4.1-mini as compressor at less than half the token spend.
- πͺΆ Small, fast, self-hostable. 4B LoRA adapter, bf16, single 24GB GPU. No SaaS, no lock-in, no per-token fee.
- π Fully open. Apache 2.0 weights, reproducible pipeline, real end-to-end benchmarks.
π Quick Start
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
BASE_MODEL = "Qwen/Qwen3-4B-Instruct-2507"
ADAPTER = "paritok/paritok-4b-v1"
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
base = AutoModelForCausalLM.from_pretrained(
BASE_MODEL, torch_dtype=torch.bfloat16, device_map="auto"
)
model = PeftModel.from_pretrained(base, ADAPTER)
model.eval()
# Wrap your code as [SEG id=1 kind=file_read] ... [/SEG]
user_msg = "[SEG id=1 kind=file_read]\n<your code here>\n[/SEG]"
prompt = tokenizer.apply_chat_template(
[{"role": "system", "content": "<full system prompt β see GitHub>"},
{"role": "user", "content": user_msg}],
tokenize=False, add_generation_prompt=True,
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=1024, do_sample=False)
print(tokenizer.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
π Full runnable example + system prompt + reproduction pipeline: GitHub β Paritok-official/paritok-4b-v1
π SWE-bench Verified β Head-to-head
| Context source | Quality retained ΒΉ | Compression rate |
|---|---|---|
| Uncompressed baseline | 100.0% | 100.0% |
| gpt-4.1-mini (compressor) | 85.6% | 50.2% |
| gpt-5 (compressor) | 93.6% | 61.9% |
| Paritok-4B-v1 β | 86.5% | 25.7% |
ΒΉ Quality retained = compressor solve rate Γ· uncompressed baseline solve rate. Higher is better.
Paritok compresses ~2Γ harder than gpt-4.1-mini on the same task while keeping the same solve rate β the only open-source entry trained end-to-end on real coding-agent trajectories.
π° Cost Impact (Claude Sonnet, $3/M input tokens)
| Turn input size | Uncompressed input | With Paritok |
|---|---|---|
| Short (8K) | $0.024 | $0.006 |
| Typical (15K) | $0.045 | $0.012 |
| Long session (30K) | $0.090 | $0.023 |
10-person team, 3-month project β save ~$10K on API bills.
π Model details (click to expand)
| Property | Value |
|---|---|
| Base model | Qwen/Qwen3-4B-Instruct-2507 |
| Adapter type | LoRA, r=32, Ξ±=64, dropout=0.0 |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Training steps | 2000 (selected from a 5-checkpoint sweep on OOD holdout) |
| Training precision | bf16 |
| Effective batch | 32 (per_device=2 Γ grad_accum=16) |
| Learning rate | 1e-5, linear decay, 10% warmup |
| Optimizer | AdamW (8-bit) |
| Max seq length | 16 384 |
| Dataset size | 45 000 samples (file_read, bash_command, log_output, ...) |
| Teacher | gpt-4.1-mini |
β οΈ Limitations (click to expand)
- ~6pp accuracy trade for 74% compression. Not free β buying context length with a small solve-rate drop. Bring your own uncompressed-fallback path for safety-critical turns.
- Rare identifier loss (~40% preserved on hard OOD segments). Add a post-compression check that your target identifier is still in the compressed output before sending upstream.
- English source code, Python-heavy training distribution. Non-English comments/strings and other-language codebases have not been benchmarked.
Recommended safeguards for production: format check, target-identifier presence check, and a session-level toggle to fall back to raw context on failure.
πΊοΈ Roadmap (click to expand)
- Paritok-4B-v2 β Next-generation training pipeline pushing compression to under 20% while closing the gap to uncompressed solve rate.
- Frontier-scale backbones (10B+ parameters) for multi-day sessions with 100K+ token histories.
- Multi-language expansion β TypeScript, Rust, Go, Java, C++, Kotlin.
- Native integrations β
mcp add paritokplugin for Claude Code and Cursor, plus a hosted inference endpoint.
π Citation
@misc{paritok-4b-v1,
author = {Paritok Team},
title = {Paritok-4B-v1: An Open-Source Compression Model for AI Coding Agents},
year = {2026},
publisher = {GitHub},
howpublished = {\url{https://github.com/Paritok-official/paritok-4b-v1}},
}
π License
Apache 2.0 β see LICENSE. Base model (Qwen3-4B-Instruct-2507) is under its own license; please review before commercial deployment.
GitHub Β· paritok.com Β· Contact
- Downloads last month
- 34
Model tree for paritok/paritok-4b-v1
Base model
Qwen/Qwen3-4B-Instruct-2507Evaluation results
- Quality retained on SWE-bench Verifiedself-reported86.500
- Compression rate on SWE-bench Verifiedself-reported25.700