知识卡片
预训练向量只存查询所需状态
KeyedVectors保存词键与向量,适于近邻和相似度查询;完整Word2Vec还保存继续训练所需状态。只加载通用向量格式通常不能接着原训练;选择保存格式前应区分推断、更新和复现实验的需求。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
- · 用词嵌入推理
原书出处 · 1 处
- · 查看原书依据
>>> from gensim.models.keyedvectors import KeyedVectors >>> word_vectors = KeyedVectors.load_word2vec_format(\ ... '/path/to/GoogleNews-vectors-negative300.bin.gz', binary=True) Working with word vectors can be memory intensive. If your available memory is limited or you don’t want to wait minutes for the word vector model to load, you can reduce the number of words loaded into memory by passing in the limit keyword argument. In the following example, you’ll load the 200,000
参考来源
- 位置:《Natural Language Processing in Action, Second Edition》第06章《用词嵌入推理》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Natural Language Processing in Action, Second Edition/_epub-src/OEBPS/Text/chapter-6.html)
- 结论依据:摘录中关于预训练向量只存查询所需状态的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。
- 原始内容:>>> from gensim.models.keyedvectors import KeyedVectors >>> word_vectors = KeyedVectors.load_word2vec_format(\ ... '/path/to/GoogleNews-vectors-negative300.bin.gz', binary=True) Working with word vectors can be memory intensive. If your available memory is limited or you don’t want to wait minutes for the word vector model to load, you can reduce the number of words loaded into memory by passing in the limit keyword argument. In the following example, you’ll load the 200,000