mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-03 12:50:06 +06:00
added cbs to notebooks, made copy-paste error fix in generation_utils (#16246)
This commit is contained in:
parent
b25b92ac4f
commit
fdc2e643c3
@ -57,6 +57,7 @@ You can open any page of the documentation as a notebook in colab (there is a bu
|
||||
| [How to fine-tune a model on audio classification](https://github.com/huggingface/notebooks/blob/master/examples/audio_classification.ipynb)| Show how to preprocess the data and fine-tune a pretrained Speech model on Keyword Spotting | [](https://colab.research.google.com/github/huggingface/notebooks/blob/master/examples/audio_classification.ipynb)| [](https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/examples/audio_classification.ipynb)|
|
||||
| [How to train a language model from scratch](https://github.com/huggingface/blog/blob/master/notebooks/01_how_to_train.ipynb)| Highlight all the steps to effectively train Transformer model on custom data | [](https://colab.research.google.com/github/huggingface/blog/blob/master/notebooks/01_how_to_train.ipynb)| [](https://studiolab.sagemaker.aws/import/github/huggingface/blog/blob/master/notebooks/01_how_to_train.ipynb)|
|
||||
| [How to generate text](https://github.com/huggingface/blog/blob/master/notebooks/02_how_to_generate.ipynb)| How to use different decoding methods for language generation with transformers | [](https://colab.research.google.com/github/huggingface/blog/blob/master/notebooks/02_how_to_generate.ipynb)| [](https://studiolab.sagemaker.aws/import/github/huggingface/blog/blob/master/notebooks/02_how_to_generate.ipynb)|
|
||||
| [How to generate text (with constraints)](https://github.com/huggingface/blog/blob/master/notebooks/53_constrained_beam_search.ipynb)| How to guide language generation with user-provided constraints | [](https://colab.research.google.com/github/huggingface/blog/blob/master/notebooks/53_constrained_beam_search.ipynb)| [](https://studiolab.sagemaker.aws/import/github/huggingface/blog/blob/master/notebooks/53_constrained_beam_search.ipynb)|
|
||||
| [How to export model to ONNX](https://github.com/huggingface/notebooks/blob/master/examples/onnx-export.ipynb)| Highlight how to export and run inference workloads through ONNX |
|
||||
| [How to use Benchmarks](https://github.com/huggingface/notebooks/blob/master/examples/benchmark.ipynb)| How to benchmark models with transformers | [](https://colab.research.google.com/github/huggingface/notebooks/blob/master/examples/benchmark.ipynb)| [](https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/examples/benchmark.ipynb)|
|
||||
| [Reformer](https://github.com/huggingface/blog/blob/master/notebooks/03_reformer.ipynb)| How Reformer pushes the limits of language modeling | [](https://colab.research.google.com/github/patrickvonplaten/blog/blob/master/notebooks/03_reformer.ipynb)| [](https://studiolab.sagemaker.aws/import/github/patrickvonplaten/blog/blob/master/notebooks/03_reformer.ipynb)|
|
||||
|
@ -3075,7 +3075,7 @@ class GenerationMixin:
|
||||
... )
|
||||
... }
|
||||
|
||||
>>> constraint_str = "sind"
|
||||
>>> constraint_str = "Sie"
|
||||
>>> constraint_token_ids = tokenizer.encode(constraint_str)[:-1] # slice to remove eos token
|
||||
>>> constraints = [PhrasalConstraint(token_ids=constraint_token_ids)]
|
||||
|
||||
@ -3175,10 +3175,6 @@ class GenerationMixin:
|
||||
continue # don't waste resources running the code we don't need
|
||||
|
||||
next_token_logits = outputs.logits[:, -1, :]
|
||||
|
||||
# hack: adjust tokens for Marian. For Marian we have to make sure that the `pad_token_id`
|
||||
# cannot be generated both before and after the `nn.functional.log_softmax` operation.
|
||||
next_token_logits = outputs.logits[:, -1, :]
|
||||
# hack: adjust tokens for Marian. For Marian we have to make sure that the `pad_token_id`
|
||||
# cannot be generated both before and after the `nn.functional.log_softmax` operation.
|
||||
next_token_logits = self.adjust_logits_during_generation(next_token_logits, cur_len=cur_len)
|
||||
|
Loading…
Reference in New Issue
Block a user