ONNX export of a reloaded NgramExtractingTransformer (useAllLengths: true) writes min_gram_length = ngramLength — the exported graph counts only the longest n-grams
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
- 72/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- csharp, machine-learning
- Domínio
- backend, machine-learning
Direção de pesquisa
Start by tracing ONNX export for NgramExtractingTransformer, comparing the export path immediately after Fit with the path after Model.Save and Model.Load. The issue provides a minimal C# reproduction and expected graph attributes: min_gram_length should be 1 with useAllLengths: true. Reproduce the value mismatch on the provided text output and confirm the reloaded export counts all n-gram lengths.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
System information
- Microsoft.ML 5.0.1, Microsoft.ML.OnnxConverter 0.23.1, Microsoft.ML.OnnxRuntime 1.31.0
- .NET 10 (net10.0), macOS arm64
Describe the bug
An NgramExtractingTransformer created with useAllLengths: true exports to ONNX correctly when it is converted straight after Fit. After a Model.Save / Model.Load round trip, the same transformer exports a TfIdfVectorizer node with min_gram_length equal to max_gram_length. The resulting graph counts only the longest n-grams. The conversion reports success, so nothing shows that the graph is wrong.
To reproduce
Text column of the UCI SMS Spam Collection (4,459 training rows, 1,115 compared):
var t = ml.Transforms.Text.TokenizeIntoCharactersAsKeys("c", "text")
.Append(ml.Transforms.Text.ProduceNgrams("text", "c", ngramLength: 4, useAllLengths: true,
weighting: NgramExtractingEstimator.WeightingCriteria.Tf))
.Fit(train);
The text output vector (width 75,141) from ML.NET, compared with the same output of the exported graph run in ONNX Runtime:
| rows that differ | |
|---|---|
t exported directly (ml.Model.ConvertToOnnx(t, train, stream, "text")) |
0 / 1,115 |
ml.Model.Save(t, …) → ml.Model.Load(…) → export |
1,115 / 1,115 |
In the graph of the reloaded transformer, the TfIdfVectorizer node has min_gram_length: 4, max_gram_length: 4 while ngram_counts is [0, 112, 6500, 59291]. The pool holds 1-, 2-, 3- and 4-grams, but only 4-grams are counted, so every 1–3-gram slot is 0. A logistic regression trained on these features scores every row of the reloaded export at about its intercept (probability ≈ 0.0017; ML.NET gives 0.0000–1.0000).
Workaround: use one ProduceNgrams per length (useAllLengths: false, lengths 1..4) followed by Concatenate. This exports correctly after a reload.
Expected behavior
The exported min_gram_length is 1 when useAllLengths is true, whether or not the transformer went through Model.Save / Model.Load. In other words, the all-lengths setting survives deserialization in what the ONNX save path reads.
Why it matters
Models are usually exported from a saved file (train → save → export later). In that path the conversion succeeds and the graph silently produces different values. Only a value-by-value comparison catches it.
- 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á 24 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