[new] Add a trick for StaticEmbedding#317
Conversation
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.
Description:修改StaticEmbedding类中的_load_with_vocab方法,首先读取所有预训练词向量,然后遍历vocab中的word,依次判断原始word、全小写的word、全大写的word以及首字母大写的word是否存在于预训练词向量中,即:原始word匹配失败的话就为word分配一个语义尽可能相似的预训练词向量,从而提升vocab中word匹配到预训练词向量的概率。
Main reason: 原始的_load_with_vocab方法只在读入预训练词向量时,对预训练词向量中的word与vocab中的word进行硬匹配,因此匹配成功率很低,对最终的实验效果影响很大。
Checklist 检查下面各项是否完成
Please feel free to remove inapplicable items for your PR.
Changes: 逐项描述修改的内容
Mention: 找人review你的PR
@修改过这个文件的人
@核心开发人员