Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
829e8894
Unverified
Commit
829e8894
authored
Dec 21, 2022
by
Joao Gante
Committed by
GitHub
Dec 21, 2022
Browse files
Generate: post-generate config doctest fix (#20804)
* fix doctests * revert unwanted change
parent
39e620c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
src/transformers/generation/utils.py
src/transformers/generation/utils.py
+3
-3
No files found.
src/transformers/generation/utils.py
View file @
829e8894
...
@@ -2024,7 +2024,7 @@ class GenerationMixin:
...
@@ -2024,7 +2024,7 @@ class GenerationMixin:
>>> model = AutoModelForCausalLM.from_pretrained("gpt2")
>>> model = AutoModelForCausalLM.from_pretrained("gpt2")
>>> # set pad_token_id to eos_token_id because GPT2 does not have a PAD 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
>>> model.
generation_
config.pad_token_id = model.
generation_
config.eos_token_id
>>> input_prompt = "It might be possible to"
>>> input_prompt = "It might be possible to"
>>> input_ids = tokenizer(input_prompt, return_tensors="pt").input_ids
>>> input_ids = tokenizer(input_prompt, return_tensors="pt").input_ids
...
@@ -2032,7 +2032,7 @@ class GenerationMixin:
...
@@ -2032,7 +2032,7 @@ class GenerationMixin:
>>> # instantiate logits processors
>>> # instantiate logits processors
>>> logits_processor = LogitsProcessorList(
>>> logits_processor = LogitsProcessorList(
... [
... [
... MinLengthLogitsProcessor(10, eos_token_id=model.config.eos_token_id),
... MinLengthLogitsProcessor(10, eos_token_id=model.
generation_
config.eos_token_id),
... ]
... ]
... )
... )
>>> stopping_criteria = StoppingCriteriaList([MaxLengthCriteria(max_length=20)])
>>> stopping_criteria = StoppingCriteriaList([MaxLengthCriteria(max_length=20)])
...
@@ -2272,7 +2272,7 @@ class GenerationMixin:
...
@@ -2272,7 +2272,7 @@ class GenerationMixin:
>>> # instantiate logits processors
>>> # instantiate logits processors
>>> logits_processor = LogitsProcessorList(
>>> logits_processor = LogitsProcessorList(
... [
... [
... MinLengthLogitsProcessor(15, eos_token_id=model.config.eos_token_id),
... MinLengthLogitsProcessor(15, eos_token_id=model.
generation_
config.eos_token_id),
... ]
... ]
... )
... )
>>> # instantiate logits processors
>>> # instantiate logits processors
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment