Commit d545d5d
committed
Fix detokenizer for byte-level tokenizers with an SPM-style decoder
Mistral tekken v13 tokenizers (Devstral-Small-2, etc.) carry an SPM-style
decoder ("Replace ▁->space, ByteFallback, Fuse, Strip") but a ByteLevel
pre-tokenizer, so their vocabulary uses GPT-2 byte markers. load() selected
the detokenizer from the decoder field alone, matching _is_spm_decoder and
routing them to SPMStreamingDetokenizer, which only strips the "▁" marker and
left the byte-level space marker "Ġ" (U+0120) in the output.
Trust the pre-tokenizer: a ByteLevel vocabulary must use BPEStreamingDetokenizer
regardless of the decoder shape. Genuine SPM tokenizers (no ByteLevel
pre-tokenizer) are unaffected.
Fixes #1041.1 parent df1d3f3 commit d545d5d
2 files changed
Lines changed: 80 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
548 | 568 | | |
549 | 569 | | |
550 | 570 | | |
| |||
598 | 618 | | |
599 | 619 | | |
600 | 620 | | |
601 | | - | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
602 | 632 | | |
603 | | - | |
| 633 | + | |
604 | 634 | | |
605 | | - | |
606 | | - | |
607 | 635 | | |
608 | 636 | | |
609 | 637 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
112 | 160 | | |
113 | 161 | | |
114 | 162 | | |
0 commit comments