mirror of
https://github.com/huggingface/transformers.git
synced 2025-08-03 03:31:05 +06:00
Improve Text Generation doc (#18788)
* fix args for bram search decoding in generation utils * fix missing PAD token in gpt2 * add PAD EOS change to TF * Update src/transformers/generation_tf_utils.py Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> * Update src/transformers/generation_utils.py Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> * Update src/transformers/generation_utils.py Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
This commit is contained in:
parent
86387fe87f
commit
89514f0541
@ -2113,7 +2113,7 @@ class TFGenerationMixin:
|
||||
>>> tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
||||
>>> model = TFAutoModelForCausalLM.from_pretrained("gpt2")
|
||||
|
||||
>>> # set pad_token_id to eos_token_id because GPT2 does not have a EOS token
|
||||
>>> # set pad_token_id to eos_token_id because GPT2 does not have a PAD token
|
||||
>>> model.config.pad_token_id = model.config.eos_token_id
|
||||
|
||||
>>> input_prompt = "Today is a beautiful day, and"
|
||||
|
@ -1139,7 +1139,7 @@ class GenerationMixin:
|
||||
>>> sentence = "Paris is one of the densest populated areas in Europe."
|
||||
>>> input_ids = tokenizer(sentence, return_tensors="pt").input_ids
|
||||
|
||||
>>> outputs = model.generate(input_ids)
|
||||
>>> outputs = model.generate(input_ids, num_beams=5)
|
||||
>>> tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
||||
['Paris ist eines der dichtesten besiedelten Gebiete Europas.']
|
||||
```"""
|
||||
@ -1635,7 +1635,7 @@ class GenerationMixin:
|
||||
>>> tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
||||
>>> model = AutoModelForCausalLM.from_pretrained("gpt2")
|
||||
|
||||
>>> # set pad_token_id to eos_token_id because GPT2 does not have a EOS token
|
||||
>>> # set pad_token_id to eos_token_id because GPT2 does not have a PAD token
|
||||
>>> model.config.pad_token_id = model.config.eos_token_id
|
||||
|
||||
>>> input_prompt = "It might be possible to"
|
||||
|
Loading…
Reference in New Issue
Block a user