Add byte-offset alignment update and canonical URL
#8
by kashif HF Staff - opened
- app/src/content/article.mdx +13 -0
- app/src/content/bibliography.bib +10 -0
- app/src/pages/index.astro +4 -1
app/src/content/article.mdx
CHANGED
|
@@ -51,6 +51,7 @@ affiliations:
|
|
| 51 |
- name: "Hugging Face"
|
| 52 |
url: "https://huggingface.co"
|
| 53 |
published: "Oct. 29, 2025"
|
|
|
|
| 54 |
tags:
|
| 55 |
- research
|
| 56 |
tableOfContentsAutoCollapse: true
|
|
@@ -179,6 +180,18 @@ We perform the token merge through scalar multiplication to leverage the autoreg
|
|
| 179 |
caption={'Figure 3: Diagram highlighting the differences between ULD and GOLD in the sequence alignment step. Instead of truncating the sequence at the minimum sequence length, we first determine the merges that result in an aligned sequence length between the two tokenizer. We then calculate the sum of the logprobs for the merged token position to get a unified vector with the token distribution for that position in the sequence.'}
|
| 180 |
/>
|
| 181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
Having resolved sequence mismatches through token merging, we now turn to vocabulary alignment, ensuring logits are comparable even when token IDs differ.
|
| 183 |
|
| 184 |
### Vocabulary Alignment
|
|
|
|
| 51 |
- name: "Hugging Face"
|
| 52 |
url: "https://huggingface.co"
|
| 53 |
published: "Oct. 29, 2025"
|
| 54 |
+
url: "https://huggingface.co/spaces/HuggingFaceH4/on-policy-distillation"
|
| 55 |
tags:
|
| 56 |
- research
|
| 57 |
tableOfContentsAutoCollapse: true
|
|
|
|
| 180 |
caption={'Figure 3: Diagram highlighting the differences between ULD and GOLD in the sequence alignment step. Instead of truncating the sequence at the minimum sequence length, we first determine the merges that result in an aligned sequence length between the two tokenizer. We then calculate the sum of the logprobs for the merged token position to get a unified vector with the token distribution for that position in the sequence.'}
|
| 181 |
/>
|
| 182 |
|
| 183 |
+
#### Update (June 2026): Robust alignment via UTF-8 byte offsets
|
| 184 |
+
|
| 185 |
+
Our original implementation identified merges by incrementally decoding both sides into text buffers and flushing a group whenever the two buffers compared equal as strings. The failure mode was first reported as [TRL issue #4393](https://github.com/huggingface/trl/issues/4393) and later analysed formally as Table 7 of the X-Token paper [@sreenivas2026xtokenprojectionguidedcrosstokenizer]. When the student tokenizer prepends a BOS token (e.g. Llama-3's `<|begin_of_text|>`, which decodes to 16 characters) and the teacher's does not (e.g. Qwen-3, Phi-4-mini), the per-side decoded buffers stay character-misaligned from the very first piece. Buffer equality never fires, the end-of-sequence force-flush bundles every student and teacher token into a single mis-grouped super-bucket, and the merge runs on that mis-grouped bucket and corrupts the loss signal across the whole sequence.
|
| 186 |
+
|
| 187 |
+
We've replaced the text-walker with a **UTF-8 byte-offset walker** that we ship in [TRL #5885](https://github.com/huggingface/trl/pull/5885). The idea is to skip the lossy decode step entirely and align directly in the source's byte coordinate system:
|
| 188 |
+
|
| 189 |
+
1. We obtain each token's UTF-8 byte span $(b_{\text{start}}, b_{\text{end}})$ from the fast tokenizer's character offsets. Both Llama-3 and Qwen-3 use ByteLevel BPE, so the spans are well-defined and consistent across tokenizers.
|
| 190 |
+
2. We walk both sequences advancing whichever side's current token ends earlier in bytes. A group closes whenever the student's and teacher's current byte end coincide, which is the exact condition for both groups to cover the same source content.
|
| 191 |
+
3. The BOS asymmetry now resolves automatically: Llama's `<|begin_of_text|>` carries a zero-width span at byte 0, so the walker advances the student once more, sees student "Hello" closing at byte 5 against teacher "Hello" closing at byte 5, and flushes a clean 2-to-1 group ([BOS, Hello] vs [Hello]). The rest of the sequence stays diagonal.
|
| 192 |
+
|
| 193 |
+
The new walker is also strictly simpler than the substring version: no per-piece decode, no buffer normalisation, and the flush condition is a single integer comparison. The conceptual story from Figure 3 is unchanged. We still identify a merge partition and apply the product-rule combination from $\mathcal{L}_{ULD}$ on the merged distributions. Only the partitioning step is now grounded in source bytes rather than per-side decoded text, which is what the Llama/Qwen BOS asymmetry needed to align cleanly.
|
| 194 |
+
|
| 195 |
Having resolved sequence mismatches through token merging, we now turn to vocabulary alignment, ensuring logits are comparable even when token IDs differ.
|
| 196 |
|
| 197 |
### Vocabulary Alignment
|
app/src/content/bibliography.bib
CHANGED
|
@@ -179,6 +179,16 @@
|
|
| 179 |
url={https://huggingface.co/papers/2501.12948},
|
| 180 |
}
|
| 181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
@misc{yang2025qwen3technicalreport,
|
| 183 |
title={Qwen3 Technical Report},
|
| 184 |
author={An Yang and Anfeng Li and Baosong Yang and Beichen Zhang and Binyuan Hui and Bo Zheng and Bowen Yu and Chang Gao and Chengen Huang and Chenxu Lv and Chujie Zheng and Dayiheng Liu and Fan Zhou and Fei Huang and Feng Hu and Hao Ge and Haoran Wei and Huan Lin and Jialong Tang and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Yang and Jiaxi Yang and Jing Zhou and Jingren Zhou and Junyang Lin and Kai Dang and Keqin Bao and Kexin Yang and Le Yu and Lianghao Deng and Mei Li and Mingfeng Xue and Mingze Li and Pei Zhang and Peng Wang and Qin Zhu and Rui Men and Ruize Gao and Shixuan Liu and Shuang Luo and Tianhao Li and Tianyi Tang and Wenbiao Yin and Xingzhang Ren and Xinyu Wang and Xinyu Zhang and Xuancheng Ren and Yang Fan and Yang Su and Yichang Zhang and Yinger Zhang and Yu Wan and Yuqiong Liu and Zekun Wang and Zeyu Cui and Zhenru Zhang and Zhipeng Zhou and Zihan Qiu},
|
|
|
|
| 179 |
url={https://huggingface.co/papers/2501.12948},
|
| 180 |
}
|
| 181 |
|
| 182 |
+
@misc{sreenivas2026xtokenprojectionguidedcrosstokenizer,
|
| 183 |
+
title={X-Token: Projection-Guided Cross-Tokenizer Knowledge Distillation},
|
| 184 |
+
author={Sharath Turuvekere Sreenivas and Adithyakrishna Venkatesh Hanasoge and Mingyu Yang and Ali Taghibakhshi and Saurav Muralidharan and Ashwath Aithal and Pavlo Molchanov},
|
| 185 |
+
year={2026},
|
| 186 |
+
eprint={2605.21699},
|
| 187 |
+
archivePrefix={arXiv},
|
| 188 |
+
primaryClass={cs.CL},
|
| 189 |
+
url={https://huggingface.co/papers/2605.21699},
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
@misc{yang2025qwen3technicalreport,
|
| 193 |
title={Qwen3 Technical Report},
|
| 194 |
author={An Yang and Anfeng Li and Baosong Yang and Beichen Zhang and Binyuan Hui and Bo Zheng and Bowen Yu and Chang Gao and Chengen Huang and Chenxu Lv and Chujie Zheng and Dayiheng Liu and Fan Zhou and Fei Huang and Feng Hu and Hao Ge and Haoran Wei and Huan Lin and Jialong Tang and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Yang and Jiaxi Yang and Jing Zhou and Jingren Zhou and Junyang Lin and Kai Dang and Keqin Bao and Kexin Yang and Le Yu and Lianghao Deng and Mei Li and Mingfeng Xue and Mingze Li and Pei Zhang and Peng Wang and Qin Zhu and Rui Men and Ruize Gao and Shixuan Liu and Shuang Luo and Tianhao Li and Tianyi Tang and Wenbiao Yin and Xingzhang Ren and Xinyu Wang and Xinyu Zhang and Xuancheng Ren and Yang Fan and Yang Su and Yichang Zhang and Yinger Zhang and Yu Wan and Yuqiong Liu and Zekun Wang and Zeyu Cui and Zhenru Zhang and Zhipeng Zhou and Zihan Qiu},
|
app/src/pages/index.astro
CHANGED
|
@@ -153,7 +153,10 @@ const bibKey = `${keyAuthor}${year ?? ""}_${keyTitle}`;
|
|
| 153 |
const doi = (ArticleMod as any)?.frontmatter?.doi
|
| 154 |
? String((ArticleMod as any).frontmatter.doi)
|
| 155 |
: undefined;
|
| 156 |
-
const
|
|
|
|
|
|
|
|
|
|
| 157 |
const envCollapse = false;
|
| 158 |
const tableOfContentAutoCollapse = Boolean(
|
| 159 |
(articleFM as any)?.tableOfContentAutoCollapse ??
|
|
|
|
| 153 |
const doi = (ArticleMod as any)?.frontmatter?.doi
|
| 154 |
? String((ArticleMod as any).frontmatter.doi)
|
| 155 |
: undefined;
|
| 156 |
+
const articleUrl = (ArticleMod as any)?.frontmatter?.url
|
| 157 |
+
? String((ArticleMod as any).frontmatter.url)
|
| 158 |
+
: undefined;
|
| 159 |
+
const bibtex = `@misc{${bibKey},\n title={${titleFlat}},\n author={${authorsBib}},\n ${year ? `year={${year}},\n ` : ""}${articleUrl ? `howpublished={\\url{${articleUrl}}},\n ` : ""}${doi ? `doi={${doi}}` : ""}\n}`;
|
| 160 |
const envCollapse = false;
|
| 161 |
const tableOfContentAutoCollapse = Boolean(
|
| 162 |
(articleFM as any)?.tableOfContentAutoCollapse ??
|