QuestionAnsweringTrainer cannot produce answers with characters above U+00FF (answer is decoded one byte per character)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 74/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- csharp
調査の方向性
Start in Roberta/QATrainer.cs, where the mapper fills PredictedAnswersBuffer, and reproduce the issue with the Korean SQuAD-format dataset described in the report. Inspect the tokenizer offsets from EncodeToTokens and the TokenizerExtensions.GetInstance path. Done means predicted answers preserve non-Latin characters and match the corresponding context substrings, with the existing reproduction completing normally.
索引モデルが issue の本文から書いたものです。
説明
Description
QuestionAnsweringTrainer (Microsoft.ML.TorchSharp, Roberta/QATrainer.cs) cannot produce an answer that contains characters above U+00FF. For Korean, Chinese, Japanese, Cyrillic and similar text, the predicted answer comes out with those characters missing, so exact match is unreachable whatever the model learned.
Cause
The predicted answer is not sliced out of the context string. It is decoded from the span's token ids:
// QATrainer.cs (main), in the mapper that fills PredictedAnswersBuffer
_parent.Tokenizer.Decode(
_parent.Tokenizer.RobertaModel().ConvertOccurrenceRanksToIds(contextIds).ToArray()
.AsSpan(predictStart - questionLength - 2, predictEnd - predictStart).ToArray())
The tokenizer comes from TokenizerExtensions.GetInstance, which calls EnglishRobertaTokenizer.Create(...) with the default filterUnsupportedChars = true. On that path EnglishRobertaTokenizer.MapIdToToken maps each token character through UnicodeToByte and appends the byte value as a char. Every output character is therefore ≤ U+00FF, and multi-byte UTF-8 sequences are never reassembled into the original characters.
Reproduction
- Train
mlContext.MulticlassClassification.Trainers.QuestionAnswer(...)on a small SQuAD-format dataset whose contexts and answers are in Korean (any non-Latin script shows the same behavior). - Transform a test set and read the
Answercolumn.
Observed with 26 training rows and 10 epochs: training completes normally, but all 8 predicted answers contain only the digits, ASCII punctuation and spaces of their spans, with every Hangul character missing, e.g. "12 , 1 100". Character-level F1 is about 0.05–0.08 and exact match is 0.
Expected behavior
The predicted answer is the corresponding substring of the context, in whatever script the context uses.
Suggested fix
Map the predicted token span back to character offsets in the original context (the tokenizer already provides offsets via EncodeToTokens) and return context.Substring(start, length), instead of decoding the ids. Alternatively, decode byte-level tokens to bytes and UTF-8-decode them (filterUnsupportedChars: false with proper byte reassembly).
Environment
- Microsoft.ML 5.0.0, Microsoft.ML.TorchSharp 0.23.0 (behavior also matches the current
mainsource) - .NET 10, Windows 11, CPU
- 主要言語
- C#
- スター
- 9.4k
- フォーク
- 2k
- 平均マージ
- 2日 18時間
- マージ済み PR(30日)
- 64
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/machinelearning のほかの issue
-
area-Native untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
dotnet/machinelearning#7837 ·
メンテナーはふだん 1 日以内に返信
-
area-TensorFlow untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
dotnet/machinelearning#7836 ·
メンテナーはふだん 1 日以内に返信
-
ToArrowRecordBatches accumulates arrays from previous batches, producing invalid record batchesオープンarea-DataFrame bug untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
dotnet/machinelearning#7799 ·
メンテナーはふだん 1 日以内に返信
-
LlamaTokenizer encodes some runs of repeated characters differently from SentencePiece対応中かも @Laurianti が 42 日前に担当しました。 オープンarea-Tokenizers untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
dotnet/machinelearning#7751 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
BertTokenizer merges words separated only by `\n`, `\t` or `\r`対応中かも @Laurianti が 23 日前に担当しました。 オープンarea-Tokenizers green
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
dotnet/machinelearning#7724 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
dotnet/machinelearning の issue をすべて見る
似ている issue
-
bug emitter:client:csharp
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/typespec#12572 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
needs-area-label
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
AWS Lambda: KeyNotFoundException drops HTTP-triggered transactions when allowAllHeaders is disabledオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
newrelic/newrelic-dotnet-agent#3949 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-networking
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/aspnetcore#70545 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
メンテナーはふだん 1 日以内に返信