Spacy词汇中的单词,但没有相关的向量

发布于 2025-02-05 16:38:55 字数 579 浏览 2 评论 0原文

我培训了一个模型,但是当我无法检索NLP识别并在其词汇中的实体的向量时。

我的理解是,无论是从自定义模型还是预验证的模型中,一个词汇中的每个单词都与向量相关联?

例子:

 sample_string = "DNP is a thing."
 for ent in doc.ents:
     print(f"Named Entity '{ent.text}' with label '{ent.label_}'") 
     #prints Named Entity 'DNP' with label 'SUBSTANCE'
 print(nlp("DNP").vector) -> # []
 print(nlp.vocab.strings["DNP"]) # -> 12623617258395969273
 print(nlp.vocab.vectors[nlp.vocab.strings["DNP"]]) # -> Could not retrieve vector for key 12623617258395969273.'
 print("DNP" in list(nlp.vocab.strings)) #-> True

I trained a model on curated text, but when I cannot retrieve vectors for entities that the nlp recognizes and are in its vocabulary.

My understanding is that every word in a SpaCy vocabulary, whether a from a custom or pretrained model, is associated with a vector?

Example:

 sample_string = "DNP is a thing."
 for ent in doc.ents:
     print(f"Named Entity '{ent.text}' with label '{ent.label_}'") 
     #prints Named Entity 'DNP' with label 'SUBSTANCE'
 print(nlp("DNP").vector) -> # []
 print(nlp.vocab.strings["DNP"]) # -> 12623617258395969273
 print(nlp.vocab.vectors[nlp.vocab.strings["DNP"]]) # -> Could not retrieve vector for key 12623617258395969273.'
 print("DNP" in list(nlp.vocab.strings)) #-> True

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文