ByteBridge is a diagnostic study of byte-side input adapters for frozen tokenizer-based language models.
The question is simple:
Can a frozen language model read raw UTF-8 byte input if we train only a small external adapter?
The answer from this project is mixed. Byte adapters can help on some tokenizer-unfriendly inputs, especially typo noise, but they do not reliably replace native tokenization. The strongest result is model-dependent: Qwen2.5 remains below its tokenizer baseline outside typo-noise buckets, while TinyLlama all-layer KV-prefix injection is stronger on clean, typo, and Unicode inputs but still fails on multilingual and tokenizer-stress buckets.
This repository contains the code, fixed benchmark splits, compact metrics, and paper artifacts behind that study. Large adapter checkpoints are intentionally excluded.
- Input-layer byte replacement is not enough. Fixed byte patches through
inputs_embedstrain successfully, but clean-text loss remains far worse than native tokenized input. - Embedding alignment is not enough. Distilling byte latents toward token embeddings reduces the auxiliary loss but does not improve downstream LM evaluation.
- Token reconstruction helps, but does not solve the problem. Byte spans can recover tokenizer token identity, especially with oracle token boundaries, but Qwen2.5 still does not use the resulting input-layer latents like native token embeddings.
- Deeper injection helps. Soft prefixes and KV-prefixes improve several stress buckets, but Qwen2.5 still misses the clean-retention threshold.
- The result is model- and bucket-dependent. TinyLlama benefits much more from all-layer KV-prefix injection than Qwen2.5, while still failing badly on multilingual and tokenizer-stress inputs.
bytebridge/ Core adapter, data, mapping, and metric code
scripts/ Training, evaluation, comparison, and plotting scripts
configs/ YAML configs for all reported runs
data/phase2/splits/ Fixed train/validation/test manifests
experiments/ Compact metrics, summaries, and result tables
reports/ Phase-by-phase technical reports
paper/pricai2026/ PRICAI paper source and figures
paper/tokshop2026/ Earlier short workshop version
The experiments/ directory in this repository contains small JSON/CSV/JSONL
artifacts needed for auditing results. It does not include trained adapter
checkpoints such as adapter.pt, best_adapter.pt, or final_adapter.pt.
The fixed benchmark uses paired conditional evaluation:
input_textis the prompt.target_textis the supervised suffix.- Noisy examples use noisy input and clean target text.
- Tokenizer baselines and ByteBridge adapters are scored on the same target tokens.
Buckets include:
- clean English
- light/medium/heavy typo noise
- Unicode stress
- multilingual short text
- code snippets
- tokenizer-stress strings such as URLs, paths, IDs, hex/base64-like strings, and logs
The fixed manifests live in data/phase2/splits/.
Representative Qwen2.5-0.5B results:
| Run | Clean retention | Wins vs tokenizer |
|---|---|---|
| Fixed input byte adapter | 2.19x | typo light / medium / heavy |
| Distill then LM | 2.22x | typo light / medium / heavy |
| Token reconstruction then LM | 1.84x | typo light / medium / heavy |
| Soft prefix p64 | 1.76x | typo light / medium / heavy |
| KV prefix p32 all layers | 1.61x | typo light / medium / heavy |
Selected cross-model result:
| Model | Best selected interface | Clean retention | Main outcome |
|---|---|---|---|
| Qwen2.5-1.5B | KV prefix p32 all layers | 2.52x | still negative |
| TinyLlama-1.1B-Chat | KV prefix p32 all layers | 0.63x | wins clean, typo, Unicode; loses multilingual and tokenizer-stress |
For full per-bucket numbers, see:
reports/phase2_research_report.mdreports/phase3_projection_alignment_report.mdreports/phase4_boundary_reconstruction_report.mdreports/phase5_prefix_kv_injection_report.mdreports/phase6_kv_prefix_report.mdreports/pricai_enhancement_notes.mdexperiments/pricai/tables/
Install the usual PyTorch/Hugging Face stack for your GPU environment, then run commands from the repository root.
Build the fixed data splits:
python scripts/phase2_build_data.py --config configs/phase2_data.yamlEvaluate the native tokenizer baseline:
python scripts/phase2_eval_tokenizer_baseline.py \
--config configs/phase2_tokenizer_baseline.yamlRun a representative byte adapter experiment:
python scripts/phase2_train_bytebridge.py \
--config configs/phase2_bb_noise_l32_seed1_2k.yamlRun the later KV-prefix diagnostic:
python scripts/phase6_probe_qwen_kv_cache.py
python scripts/phase6_train_kv_prefix.py \
--config configs/phase6_kv_prefix_p32_lall.yamlRun the PRICAI cross-model comparison scripts:
python scripts/pricai_compare_tokenizer_fertility.py
python scripts/pricai_compare_training_curves.py
python scripts/pricai_cross_model_diagnosis.pyMany scripts expect Hugging Face model access for:
Qwen/Qwen2.5-0.5BQwen/Qwen2.5-1.5BTinyLlama/TinyLlama-1.1B-Chat-v1.0
The current PRICAI paper source is in paper/pricai2026/.
Important note: the paper in this private repository is an anonymous submission artifact. Do not make the repository public during double-anonymous review.
To keep the repository lightweight and review-safe, the following are excluded:
- virtual environments
- downloaded model weights
- adapter checkpoints
- large binary archives
- LaTeX build intermediates
The compact metrics in experiments/ are enough to audit the reported tables and
figures. Checkpoints can be regenerated from the configs and scripts.
No public citation is provided while the paper is under anonymous review.