问题标签 [elmo]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
98 浏览

nlp - 是否可以将特定领域的 word2vec 嵌入和现成的 ELMo 嵌入结合起来用于下游无监督任务?

我想知道我是否正确使用了词嵌入。

我将上下文化的词向量与静态词向量结合起来,因为:

  • 我的领域语料库太小,无法从头开始有效地训练模型
  • 我的领域太专业了,无法使用通用嵌入。

我使用现成的 ELMo 小型模型,并在一个小型领域特定语料库(大约 500 篇学术论文)上训练了 word2vec 模型。然后,我对来自两个不同嵌入的向量进行了简单的串联。

我大致遵循了本文中的方法: https ://www.aclweb.org/anthology/P19-2041.pdf 但本文中的方法训练了特定任务的嵌入。在我的领域中,没有标记的训练数据。因此,我只在语料库上训练嵌入。

我是 NLP 新手,如果我问了一个愚蠢的问题,我深表歉意。

0 投票
1 回答
35 浏览

python - 使用 BERT 迭代多个文件以进行 QA 不会返回任何结果

我正在努力减轻我的工作。我需要对 BERT 为我提供的数千个文件的答案进行一些分析。我的主要目标是遍历每个文件并提出一个问题。

我一直在尝试使用以下代码使其自动化

上面的代码什么也不返回。然而,如果我一一做。它工作正常。所以我试着改变它。

有没有人有任何见解?上面的代码非常适合 Allen 的 ELMo。

0 投票
1 回答
815 浏览

python - 如何在 sklearn 中使用 BERT 和 Elmo 嵌入

我使用 sklearn 创建了一个使用 Tf-Idf 的文本分类器,并且我想使用 BERT 和 Elmo 嵌入而不是 Tf-Idf。

如何做到这一点?

我正在使用以下代码嵌入 Bert:

0 投票
2 回答
238 浏览

python - ELMo嵌入中的“Highway.forward:输入必须存在”?

我将Elmo Embeddings用于我的 NLP 任务。预训练是来自这个git的印度尼西亚语。使用语法导入库

from elmoformanylangs import Embedder

导致以下错误:

TypeError: Highway.forward: input must be present

请帮助我理解错误消息的含义。

0 投票
1 回答
363 浏览

python - 为什么我得到 Highway.forward:运行时必须存在“输入”:从 elmoformanylangs 导入嵌入器

我正在尝试通过使用 Embedder python 对象以编程方式使用 ELMoForManyLangs。

当我运行时,我收到以下错误:

你有什么建议来解决它吗?

0 投票
1 回答
66 浏览

neural-network - NLP ELMo model pruning input

I am trying to retrieve embeddings for words based on the pretrained ELMo model available on tensorflow hub. The code I am using is modified from here: https://www.geeksforgeeks.org/overview-of-word-embedding-using-embeddings-from-language-models-elmo/

The sentence that I am inputting is
bod =" is coming up in and every project is expected to do a video due on we look forward to discussing this with you at our meeting this this time they have laid out the selection criteria for the video award s go for the top spot this time "

and these are the keywords I want embeddings for:
words=["do", "a", "video"]

this sentence is 236 characters in length. this is the picture showing that lenbod

but when I put this sentence into the ELMo model, the tensor that is returned is only contains a string of length 48 tensor dim

and this becomes a problem when i try to extract embeddings for keywords that are outside the 48 length limit because the indices of the keywords are shown to be outside this length: kywordlen

this is the code I used to get the indices for the words in 'bod'(as shown above)

But i keep running into this error: error

I tried looking for ELMo documentation to explain why this is happening but I have not found anything related to this problem of pruned input.

Any advice is much appreciated!

Thank You

0 投票
1 回答
197 浏览

python - 计算 elmo 模型的余弦相似度

我正在尝试使用 Elmo 模型计算 wordsim 集的余弦相似度。这可能没有意义,因为它是为句子词嵌入而设计的,但我想看看模型在这种情况下的表现如何。我使用的 Elmo 来自:

https://tfhub.dev/google/elmo/3

如果我运行以下代码(它是从文档页面修改以符合 TF 2.0),它将生成单词的张量表示。

如果我尝试直接计算余弦相似度,我会得到错误, NotImplementedError: Cannot convert a symbolic Tensor (strided_slice_59:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported . 我不确定如何将张量直接转换为 numpy 数组,或者是否有更好的张量评估器而不是余弦相似度?

编辑:这就是我为计算余弦相似度所做的

0 投票
0 回答
112 浏览

python - 无法在 Colab 中安装 allennlp 0.5.0

我想使用 Elmo 的 ElmoEmbedder。

要求:Python 3.6 - 较低版本的 Python 不起作用 AllenNLP 0.5.1 - 计算 ELMo 表示 Keras 2.2.0 - 用于创建 BiLSTM-CNN-CRF 架构

当我安装 allennlp 0.5.0 时,出现这样的错误。

所以我安装了torch 0.4.0,但它给了我另一个这样的错误

那么,我该如何安装 allennlp 0.5.0?

0 投票
0 回答
387 浏览

python - ValueError: 层双向的输入 0 与层不兼容:预期 ndim=3,发现 ndim=4。收到的完整形状:(无、120、1024、1024)

我正在尝试命名实体识别,这里是我的 x_train 和 x_test 的详细信息: Shape X_train: (3555, 120, 1024) Shape X_test: (887, 120, 1024)

错误是: ValueError: Input 0 of layer bidirectional_14 is incompatible with the layer: expected ndim=3, found ndim=4. Full shape received: (None, 120, 1024, 1024)

这是model.summary()在此处输入图像描述

请帮帮我,我无法通过其他答案解决。

0 投票
0 回答
37 浏览

elmo - 为什么小型预训练 elmo 模型的 gpu 内存比 Original emlo 模型使用的多?

首先,我在项目中使用名为 small 的预训练 elmo 模型。第一个预训练模型有 13.6M 参数,其输出大小为 256。然后显示我使用了 10803M GPU 内存。其次,我在我的项目中使用了名为 Original 的预训练 elmo 模型。第二个预训练模型有 96.6M 参数,其输出大小为 1024。然后它显示我使用了 9649M GPU 内存。第三,除了两个不同的预训练模型的路径之外,什么都没有改变。我认为小型模型应该计算得更快并且使用更少的 GPU 内存。但是,事实并非如此。所以我的问题是为什么小型模型会花费更多的 GPU 内存?