修正 F1(词频)的量级, 让候选顺序能被学习纠正 - #423
Open
jzksnsjswkw wants to merge 2 commits into
Open
jzksnsjswkw wants to merge 2 commits into
jzksnsjswkw wants to merge 2 commits into
Conversation
F1 的语义是「用户选中次数」: 官方词典里绝大多数是 1、最高约 140, 用户每选一次 +1。 早期版本用「按 Rank 降序分配全局唯一递降值 n..1」, 让每个导入词的 F1 落在 1..13900 的大跨度上, 于是所有导入词的 F1 都远高于 Gboard 之后学到的词, 候选顺序被永久冻死。 设备实测(2026-09-16): 导入后 亟需 F1=7775, 用户反复选中的 继续 才涨到 33, 结果打 jixu 第一个候选永远是亟需, 无论打多少次都纠不回来。 现在改为: F1 = 词库给的词频(超过 255 时按最大值线性压缩到 1..255, 保持相对顺序)。 平局是正常的 —— 官方词典里 8619 个词同为 F1=1, 且正是"平局可被学习打破"这一点 让候选顺序能跟着用户习惯走。 新增测试 Export_KeepsFrequenciesInGboardScale: 断言 F1 等于词库给的词频, 而不是按名次重排的值(即旧实现的 3/2/1), 锁住这个回归。
导入时写 Rank = F1 + 1 会让每轮「导入→导出」把全部词频抬 1, 反复往返后会 一起撞到上限、同音词的相对顺序丢失。 当时加 +1 是为了躲开上游 DefaultWordRankGenerator 把 Rank==0 覆盖成 1, 现在构建器自己就会把 Rank<=0 归为 1(符合官方语义: F1=0 和 1 都是「几乎没用过」), 所以不需要偏移。 实测: ggpy → gboardbin → ggpy, 13933 个词的词频 100% 一致(此前整体 +1)。 从官方词典导出时词频范围也回到严格的 1~140。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FPT2 的 F1 是「用户选中次数」:官方词典里 62% 的词是 1、最高约 140,用户每选一次 +1。
旧实现按名次摊成
1..n的大跨度,使导入词的 F1 远高于 Gboard 之后学到的词,候选顺序被永久冻死。设备实测:导入后亟需F1=7775,反复选中的继续才涨到 33,打jixu第一个候选永远是「亟需」,选多少次都纠不回来。改动
Rank = F1 + 1偏移。它会让每轮「导入→导出」把所有词频抬 1,反复往返后全部撞到上限、相对顺序丢失Export_KeepsFrequenciesInGboardScale,断言 F1 等于词库给的词频,而不是按名次重排的值(旧实现输出 3/2/1,直接挂)验证
140 → 输出 F1 1140,相邻 40 名内 0 处逆序