Views
No views yet
| Technique | Token Savings | Best For |
|---|---|---|
transcode | ~99% | Text extraction, OCR tasks |
crop | 50-90% | Region-specific queries |
full_low | ~87% | General understanding |
preserve | 0% | Fine details, counting |
| Class | Precision | Recall | F1-Score |
|---|---|---|---|
| transcode | 0.95 | 0.92 | 0.93 |
| crop | 0.92 | 0.97 | 0.94 |
| preserve | 0.97 | 0.90 | 0.93 |
| full_low | 0.89 | 0.96 | 0.92 |
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4# Load model
5model_id = "chopratejas/technique-router"
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForSequenceClassification.from_pretrained(model_id)
8model.eval()
9
10# Classify a query
11query = "What brand is the TV?"
12inputs = tokenizer(query, return_tensors="pt", truncation=True, padding=True)
13
14with torch.no_grad():
15 outputs = model(**inputs)
16 probs = torch.softmax(outputs.logits, dim=-1)
17 pred_id = torch.argmax(probs, dim=-1).item()
18 confidence = probs[0][pred_id].item()
19
20technique = model.config.id2label[pred_id]
21print(f"{query} -> {technique} ({confidence:.0%})")
22# Output: What brand is the TV? -> preserve (73%)1from headroom.image import TrainedRouter
2
3router = TrainedRouter()
4decision = router.classify(image_bytes, "What brand is the TV?")
5print(decision.technique) # Technique.PRESERVE1@misc{headroom-technique-router,
2 title={Technique Router for Image Token Optimization},
3 author={Headroom AI},
4 year={2025},
5 publisher={Hugging Face},
6 url={https://huggingface.co/chopratejas/technique-router}
7}