📜  文本生成 gpt 2 huggingface - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:26.483000             🧑  作者: Mango

代码示例1
from transformers import GPT2Tokenizer, TFGPT2Model
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
model = TFGPT2Model.from_pretrained('gpt2')
text = "Replace me by any text you'd like."
encoded_input = tokenizer(text, return_tensors='tf')
output = model(encoded_input)