Microsoft.ML.TorchSharp QuestionAnswer: training takes the answer's last token as inclusive but the decoder cuts the span as exclusive — every answer comes back without its last token (a one-token answer is the empty string)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- csharp
调研方向
Read QATrainer.cs at the training end-index calculation and decoder span slice, then trace the existing QuestionAnswer tests. Add a regression test using a trivially learnable one-token answer set and verify that fitted predictions match the training answers, including the one-token case. The issue is done when decoding returns the complete answer and the regression test passes.
由索引模型根据 Issue 内容生成。
描述
Package: Microsoft.ML.TorchSharp 0.23.1 (Microsoft.ML 5.0.x), mlContext.MulticlassClassification.Trainers.QuestionAnswer(...). Related: the NER report #7889 (an off-by-one between what the trainer is taught and what the decoder returns).
Observed. Train on 300 synthetic extractive questions (Where does Leo work? over Leo works at Tyrell in Oslo. It opened last year., answer Tyrell, and Which city is Tyrell in?, answer Oslo), maxEpochs 10; the training loss falls to 0.011. Then answer 60 held-out questions and compare PredictedAnswer[0] with the expected text:
- exact matches: 0 of 60;
- empty string: 33; strict prefix of the expected answer (
TyforTyrell,UmbforUmbrella,WonforWonka): 27; anything else: 0.
So the span the model finds is right and the decoder cuts its last token.
Cause (read from QATrainer.cs, not stepped through): training computes the inclusive end answerEnd = answerIndex + answer.Length - 1 and the target token of that character; the decoder slices .AsSpan(predictStart - questionLength - 2, predictEnd - predictStart), a length that is correct for an exclusive end. A one-token answer (start == end) therefore decodes to the empty string.
Check that it is the cut and not the model: train the same data with every answer extended through the first character of the next token (a space has no token — the example is skipped — so extend past the whitespace to the next word's first character) and with a . appended to every passage so the last answer also has a next token: the same trainer then answers 56 of 60 held-out questions exactly (exact_match 0.93, char_f1 0.96).
Workaround on our side: that training-side extension plus the passage padding. Models trained with it would answer one token too long once a release decodes the span the way it trains it.
Request: decode the end index as inclusive (predictEnd - predictStart + 1) or train an exclusive end, with a test that a model fitted on a trivially learnable one-token-answer set returns its own training answers.
- 主要语言
- C#
- 星标
- 9.4k
- 派生
- 2k
- 平均合并
- 2 天 18 小时
- 30 天内合并 PR
- 64
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 天内回复
-
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 个 reaction ·
维护者通常 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 天内回复