SentencePieceTokenizer: charsmap entries that map to an empty string are not applied, so control characters become <unk>
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 69/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- csharp
- Domínio
- machine-learning
Direção de pesquisa
Start by locating SentencePieceTokenizer normalization and the charsmap handling used by both CreateFromTokenizerJson and the .model protobuf path. Reproduce the reported case with a\u0001b and compare the normalized output with SentencePiece; done means all listed code points mapped to an empty string are deleted and token IDs match the expected behavior.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
System Information:
- OS & Version: Debian 13 (trixie), x64
- ML.NET Version: Microsoft.ML.Tokenizers 3.0.0
- .NET Version: .NET SDK 10.0.404
Describe the bug
The precompiled nmt_nfkc charsmap used by SentencePiece Unigram models maps 30 control characters to an empty string, i.e. the normalizer deletes them. SentencePieceTokenizer does not apply these entries: the character survives normalization and is encoded as <unk>. As a result, token IDs differ from both Hugging Face tokenizers and SentencePiece C++ on any text that contains these characters.
The affected code points are U+0001–U+0008, U+000B, U+000E–U+001F, U+007F, U+008F and U+009F.
To Reproduce
Model: intfloat/multilingual-e5-small, revision 614241f622f53c4eeff9890bdc4f31cfecc418b3, file onnx/tokenizer.json.
using Microsoft.ML.Tokenizers;
using var stream = File.OpenRead("tokenizer.json");
var tokenizer = SentencePieceTokenizer.CreateFromTokenizerJson(
stream, addBeginningOfSentence: false, addEndOfSentence: false);
Console.WriteLine(string.Join(", ", tokenizer.EncodeToIds("a\u0001b")));
Console.WriteLine(string.Join(", ", tokenizer.EncodeToIds("hello\u007Fworld")));
| Input | Microsoft.ML.Tokenizers 3.0.0 | Hugging Face tokenizers 0.23.3 |
|---|---|---|
"a\u0001b" |
[10, 3, 275] (▁a, <unk>, b) |
[1563] (▁ab) |
"hello\u007Fworld" |
[33600, 31, 3, 32554] |
[33600, 31, 32554] |
Expected behavior
Charsmap entries whose replacement is an empty string should delete the matched input, as SentencePiece and Hugging Face do.
Additional context
We ran every Unicode scalar value (1,112,063 code points) through the normalizer and compared the result with SentencePiece's own normalization. 1,112,033 match; all 30 differences are the code points listed above. Removing these characters before calling the tokenizer brings the result to 1,112,063 of 1,112,063. The behavior is the same whether the tokenizer is created from tokenizer.json or from the .model protobuf.
Workaround: strip the 30 code points before encoding.
A related tie-breaking difference is reported in #7909.
- Linguagem predominante
- C#
- Estrelas
- 9.4k
- Forks
- 2k
- Merge médio
- 2d 18h
- PRs com merge (30d)
- 64
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de dotnet/machinelearning
-
area-Native untriaged
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
dotnet/machinelearning#7837 ·
Mantenedores costumam responder em até 1 dia
-
area-TensorFlow untriaged
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
dotnet/machinelearning#7836 ·
Mantenedores costumam responder em até 1 dia
-
ToArrowRecordBatches accumulates arrays from previous batches, producing invalid record batchesAbertaarea-DataFrame bug untriaged
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
dotnet/machinelearning#7799 ·
Mantenedores costumam responder em até 1 dia
-
LlamaTokenizer encodes some runs of repeated characters differently from SentencePieceTalvez já em andamento @Laurianti assumiu há 42 dias. Abertaarea-Tokenizers untriaged
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
dotnet/machinelearning#7751 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
BertTokenizer merges words separated only by `\n`, `\t` or `\r`Talvez já em andamento @Laurianti assumiu há 23 dias. Abertaarea-Tokenizers green
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
dotnet/machinelearning#7724 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de dotnet/machinelearning
Issues semelhantes
-
bug emitter:client:csharp
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
microsoft/typespec#12572 · 1 comentário · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
needs-area-label
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 2 dias
-
AWS Lambda: KeyNotFoundException drops HTTP-triggered transactions when allowAllHeaders is disabledAbertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
newrelic/newrelic-dotnet-agent#3949 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
area-networking
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
dotnet/aspnetcore#70545 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 87/100
Mantenedores costumam responder em até 1 dia