标签: allennlp

消息“错误:需要 Microsoft Visual C++ 14.0 或更高版本。”

在下载的时候pip install allennlp==1.0.0 allennlp-models==1.0.0,我遇到了这样的问题:

\n
        [6 lines of output]\n        running bdist_wheel\n        running build\n        running build_py\n        running build_ext\n        building \'srsly.msgpack._unpacker\' extension\n        error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/\n        [end of output]\n\n        note: This error originates from a subprocess, and is likely not a problem with pip.\n        ERROR: Failed building wheel for srsly\n      Failed to build thinc blis srsly\n      ERROR: Could not build wheels for srsly, which is required to …
Run Code Online (Sandbox Code Playgroud)

pip python-packaging allennlp

48
推荐指数
4
解决办法
53万
查看次数

pytorch 从 gpu 中删除模型

我想在基于 Pytorch 的项目中进行交叉验证。而且我也没有找到pytorch提供的删除当前模型和清空GPU内存的方法。你能告诉我该怎么做吗?

gpu pytorch allennlp

15
推荐指数
1
解决办法
2万
查看次数

pip-无法安装特定的软件包版本

我正在尝试通过安装库(allennlppip3。但它抱怨PyTorch版本。虽然allennlp需要torch=0.4.0我有torch=0.4.1

...
Collecting torch==0.4.0 (from allennlp)
  Could not find a version that satisfies the requirement torch==0.4.0 (from allennlp) (from versions: 0.1.2, 0.1.2.post1, 0.4.1)
No matching distribution found for torch==0.4.0 (from allennlp)
Run Code Online (Sandbox Code Playgroud)

也可以手动安装:

pip3 install torch==0.4.0
Run Code Online (Sandbox Code Playgroud)

也不起作用:

  Could not find a version that satisfies the requirement torch==0.4.0 (from versions: 0.1.2, 0.1.2.post1, 0.4.1)
No matching distribution found for torch==0.4.0
Run Code Online (Sandbox Code Playgroud)

其他版本也一样。

Python是在Mac OS上Python 3.7.0通过安装的版本brew

我记得前段时间我可以在版本0.4.00.3.1使用之间进行切换 …

homebrew pip python-3.x pytorch allennlp

5
推荐指数
1
解决办法
4832
查看次数

文本二元分类训练期间的波动损失

我做了的细化和微调Longformer文档中的文本二元分类任务使用Huggingface教练班,我监视一些检查站与Tensorboard的措施。

即使 F1 分数和准确率都相当高,但我对训练损失波动感到困惑。

我在网上阅读的原因可能是:

  • 过高的学习速率,但我试图与3个值(1E-4,1E-5和1E-6)和它们全部由相同的效果
  • 一个小批量的大小。我正在使用具有 8xK80 GPU的Sagemaker 笔记本 p2.8xlarge。我可以用来避免CUDA 内存不足错误的每个 GPU 的批量大小为 1。所以总批量大小为8。我的直觉是 bs 为 8 对于包含 57K 个示例(每个 epoch 7K 步)的数据集来说太小了。不幸的是,这是我可以使用的最高值。

这里我已经报告了 F1、准确率、损失和平滑损失的趋势。灰线是 1e-6 的学习率,而粉红色的是 1e-5。

我恢复了我训练的所有信息

  • 批量大小:1 x 8GPU = 8
  • 学习率1e-41e-51e-6(所有这些都经过测试,损失没有改善)
  • 型号: Longformer
  • 数据集
    • 训练集57K 个例子
    • 开发集12K 示例
    • 测试集 …

python machine-learning pytorch allennlp huggingface-transformers

5
推荐指数
1
解决办法
182
查看次数

如何在 AllenNLP 中加载微调的 sciBERT 模型?

我已经在 SciIE 数据集上微调了 SciBERT 模型。存储库使用 AllenNLP 来微调模型。训练执行如下:

python -m allennlp.run train $CONFIG_FILE  --include-package scibert -s "$@" 
Run Code Online (Sandbox Code Playgroud)

成功训练后,我有一个 model.tar.gz 文件作为输出,其中包含 weights.th、config.json 和词汇文件夹。我试图将它加载到 allenlp 预测器中:

from allennlp.predictors.predictor import Predictor
predictor = Predictor.from_path("model.tar.gz")
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

配置错误:bert-pretrained 不是 dataset_reader.token_indexers.bert.type 可接受的选择:['single_id', 'characters', 'elmo_characters', 'spacy', 'pretrained_transformer', 'pretrained_transformer_mismatched']。您应该使用 --include-package 标志来确保加载了正确的模块,或者在配置文件中使用完全限定的类名,例如 {"model": "my_module.models.MyModel"} 以使其自动导入.

我从未与 allenNLP 合作过,所以我很困惑该怎么做。

作为参考,这是描述令牌索引器的配置的一部分

"token_indexers": {
            "bert": {
                "type": "bert-pretrained",
                "do_lowercase": "false",
                "pretrained_model": "/home/tomaz/neo4j/scibert/model/vocab.txt",
                "use_starting_offsets": true
            }
        }
Run Code Online (Sandbox Code Playgroud)

我正在使用 allenlp 版本

名称:allennlp 版本:1.2.1

编辑:

我想我已经取得了很大的进步,我必须使用与训练模型相同的版本,我可以像这样导入模块:

from allennlp.predictors.predictor import Predictor
from scibert.models.bert_crf_tagger import *
from scibert.models.bert_text_classifier …
Run Code Online (Sandbox Code Playgroud)

python allennlp

5
推荐指数
1
解决办法
851
查看次数

无法在 Mac 上使用 pip 安装 allennlp

我正在尝试在我的 mac 上安装 allennlp。我尝试安装 macOS 头文件,它解决了缺少头文件的问题,但现在我遇到了新问题。

我运行时的错误pip install allennlp

Running setup.py bdist_wheel for jsonnet ... error
  Complete output from command /anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/qf/jkn4v43j08xgst0r9yxyl0dc0000gn/T/pip-install-i4nyb384/jsonnet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/qf/jkn4v43j08xgst0r9yxyl0dc0000gn/T/pip-wheel-eof7cc6k --python-tag cp37:
  running bdist_wheel
  running build
  running build_ext
  x86_64-apple-darwin13.4.0-clang++ -c -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0 core/desugarer.cpp -o core/desugarer.o
  In file included from core/desugarer.cpp:17:
  In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/cassert:21:
  In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/assert.h:44:
  /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:111:82: error: use …
Run Code Online (Sandbox Code Playgroud)

macos command-line-tool python-3.x clang++ allennlp

4
推荐指数
1
解决办法
1296
查看次数

KeyError: 'predictions' 当使用 SimpleSeq2SeqPredictor 来预测字符串时

请首先在我们的 GitHub 存储库中搜索类似问题。如果您没有找到类似的示例,您可以使用以下模板:

系统(请填写以下信息): - 操作系统:Ubunti 18.04 - Python 版本:3.6.7 - AllenNLP 版本:v0.8.3 - PyTorch 版本:1.1.0

问题 当我尝试使用 SimpleSeq2SeqPredictor 预测字符串时,它总是显示

Traceback (most recent call last):
  File "predict.py", line 96, in <module>
    p = predictor.predict(i)
  File "venv/lib/python3.6/site-packages/allennlp/predictors/seq2seq.py", line 17, in predict
    return self.predict_json({"source" : source})
  File "/venv/lib/python3.6/site-packages/allennlp/predictors/predictor.py", line 56, in predict_json
    return self.predict_instance(instance)
  File "/venv/lib/python3.6/site-packages/allennlp/predictors/predictor.py", line 93, in predict_instance
    outputs = self._model.forward_on_instance(instance)
  File "/venv/lib/python3.6/site-packages/allennlp/models/model.py", line 124, in forward_on_instance
    return self.forward_on_instances([instance])[0]
  File "/venv/lib/python3.6/site-packages/allennlp/models/model.py", line 153, in forward_on_instances
    outputs = self.decode(self(**model_input))
  File "/venv/lib/python3.6/site-packages/allennlp/models/encoder_decoders/simple_seq2seq.py", …
Run Code Online (Sandbox Code Playgroud)

python pytorch allennlp

3
推荐指数
1
解决办法
1164
查看次数

Google Colab 最近引发错误 ModuleNotFoundError:没有名为“google.cloud.storage.retry”的模块

我的代码在本地和 colab 上运行正常,但是最近在 colab 上遇到以下错误。我使用 google colab 来运行我的代码。allennlp 软件包已安装。

运行代码时出错

google-cloud-storage pytorch google-colaboratory allennlp

3
推荐指数
1
解决办法
2847
查看次数

如何在自定义模型上使用 Allen NLP 解释

我希望使用 Allen NLP Interpret 进行集成可视化和显着性映射。关于自定义变压器模型,您能告诉我该怎么做吗?

heatmap allennlp

1
推荐指数
1
解决办法
596
查看次数