要求 gpt-2 用 huggingface 变形金刚完成句子
Asking gpt-2 to finish sentence with huggingface transformers
我目前正在使用带有 gpt-2 的 huggingface transformers 库的示例脚本 run_generation.py
从左侧上下文生成文本:
$ 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
个单词之前完成一个句子?
注意:我不介意改变模型,但更喜欢自回归模型。
很遗憾,没有办法这样做。您可以将 length
参数设置为更大的值,然后在最后丢弃不完整的部分。
甚至 GPT3 也不支持在特定 length
之前完成一个句子。不过 GPT3 支持“序列”。当满足特定条件时,序列会强制模型停止。您可以在 article
中找到有关的更多信息
此参数可帮助您获得结果:
'''
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
'''
希望对您有所帮助!
我目前正在使用带有 gpt-2 的 huggingface transformers 库的示例脚本 run_generation.py
从左侧上下文生成文本:
$ 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
个单词之前完成一个句子?
注意:我不介意改变模型,但更喜欢自回归模型。
很遗憾,没有办法这样做。您可以将 length
参数设置为更大的值,然后在最后丢弃不完整的部分。
甚至 GPT3 也不支持在特定 length
之前完成一个句子。不过 GPT3 支持“序列”。当满足特定条件时,序列会强制模型停止。您可以在 article
此参数可帮助您获得结果:
'''
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
'''
希望对您有所帮助!