【问题标题】:Spacy-Transformers: Access GPT-2?Spacy-Transformers:访问 GPT-2?
【发布时间】:2021-10-27 00:07:06
【问题描述】:

我正在使用 Spacy-Transformers 构建一些 NLP 模型。

Spacy-Transformers docs 说:

空间转换器

用于预训练的 BERT、XLNet 和 GPT-2 的 spaCy 管道

该页面上的示例代码显示:

import spacy

nlp = spacy.load("en_core_web_trf")
doc = nlp("Apple shares rose on the news. Apple pie is delicious.")

根据我从 this video 了解到的信息,“en_core_web_trf”似乎是使用 BERT 模型的 spacy.load() 包。我已经搜索了Spacy-Transformers docs,但还没有看到一个等效的包来访问 GPT-2。是否有特定的 spacy.load() 包要加载以使用 GPT-2 模型?

【问题讨论】:

    标签: machine-learning nlp spacy gpt-2


    【解决方案1】:

    en_core_web_trf 使用特定的 Transformers 模型,但您可以使用来自 spacy-transformersTransformerModel 包装类指定任意模型。请参阅the docs。示例配置:

    [model]
    @architectures = "spacy-transformers.TransformerModel.v1"
    name = "roberta-base" # this can be the name of any hub model
    tokenizer_config = {"use_fast": true}
    

    【讨论】:

    猜你喜欢
    • 2020-11-23
    • 2019-12-06
    • 1970-01-01
    • 2020-01-24
    • 1970-01-01
    • 2020-01-06
    • 1970-01-01
    • 2021-07-03
    • 2020-05-22
    相关资源
    最近更新 更多