首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >要求gpt-2用拥抱式变形金刚完成句子

要求gpt-2用拥抱式变形金刚完成句子
EN

Stack Overflow用户
提问于 2020-04-09 13:12:13
回答 2查看 1.5K关注 0票数 4

目前,我正在使用包含gpt-2的拥抱面转换器库的示例脚本run_generation.py从左侧上下文生成文本:

代码语言:javascript
复制
$ python transformers/examples/run_generation.py \
  --model_type gpt2 \
  --model_name_or_path gpt2 \
  --prompt "Hi, " --length 5

=== GENERATED SEQUENCE 1 ===
Hi,  could anyone please inform me

我想要生成简短的完整句子。有没有办法告诉模型在length单词之前完成一个句子?

注:我不介意改变模式,但更喜欢自回归模式。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-10-26 18:25:41

不幸的是,没有办法这样做。您可以将length参数设置为更大的值,然后在末尾丢弃不完整的部分。

甚至GPT3也不支持在特定的length之前完成一个句子。不过,GPT3支持“序列”。序列迫使模型在满足一定条件时停止。您可以在thi 文章中找到更多有关信息。

票数 3
EN

Stack Overflow用户

发布于 2022-04-30 02:20:17

此参数帮助您获得结果:

代码语言:javascript
复制
    '''
model_name is the model name, such as "124M" or "345M" and relies on 
models_dir.
• models_dir defines the directory containing the models.
• seed sets a random integer for random generators. The seed can be set to 
reproduce results.
• nsamples is the number of samples to return. If it is set to 0, it will continue 
to generate samples until you double-click on the run button of the cell or 
press Ctrl + M.
• batch_size determines the size of a batch and has an impact on memory 
and speed.
• length is the number of tokens of generated text. If set to none, it relies on 
the hyperparameters of the model.
• temperature determines the level of Boltzmann distributions. If the 
temperature is high, the completions will be more random. If the temperature 
is low, the results will become more deterministic.
• top_k controls the number of tokens taken into consideration by Top-k at 
each step. 0 means no restrictions. 40 is the recommended value.
• top_p controls Top-p
'''

希望它能帮到你!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61121982

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档