Skip to content

Commit 2d50d7f

Browse files
authored
Merge branch 'main' into upgrade_get_text_config
2 parents 2b7f8dc + 8564e21 commit 2d50d7f

File tree

19 files changed

+516
-1234
lines changed

19 files changed

+516
-1234
lines changed

docs/source/ar/notebooks.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
| [كيفية ضبط نموذج بدقة على التلخيص](https://github.com/huggingface/notebooks/blob/main/examples/summarization.ipynb)| يوضح كيفية معالجة البيانات مسبقًا وضبط نموذج مُدرَّب مسبقًا بدقة على XSUM. | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization.ipynb)| [![Open in AWS Studio](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/examples/summarization.ipynb)|
4040
| [كيفية تدريب نموذج لغة من البداية](https://github.com/huggingface/blog/blob/main/notebooks/01_how_to_train.ipynb)| تسليط الضوء على جميع الخطوات لتدريب نموذج Transformer بشكل فعال على بيانات مخصصة | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/blog/blob/main/notebooks/01_how_to_train.ipynb)| [![Open in AWS Studio](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/huggingface/blog/blob/main/notebooks/01_how_to_train.ipynb)|
4141
| [كيفية إنشاء نص](https://github.com/huggingface/blog/blob/main/notebooks/02_how_to_generate.ipynb)| كيفية استخدام أساليب فك التشفير المختلفة لإنشاء اللغة باستخدام المحولات | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/blog/blob/main/notebooks/02_how_to_generate.ipynb)| [![Open in AWS Studio](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/huggingface/blog/blob/main/notebooks/02_how_to_generate.ipynb)|
42-
| [كيفية إنشاء نص (مع قيود)](https://github.com/huggingface/blog/blob/main/notebooks/53_constrained_beam_search.ipynb)| كيفية توجيه إنشاء اللغة باستخدام القيود التي يوفرها المستخدم | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/blog/blob/main/notebooks/53_constrained_beam_search.ipynb)| [![Open in AWS Studio](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/huggingface/blog/blob/main/notebooks/53_constrained_beam_search.ipynb)|
4342
| [Reformer](https://github.com/huggingface/blog/blob/main/notebooks/03_reformer.ipynb)| كيف يدفع Reformer حدود النمذجة اللغوية | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/patrickvonplaten/blog/blob/main/notebooks/03_reformer.ipynb)| [![Open in AWS Studio](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/patrickvonplaten/blog/blob/main/notebooks/03_reformer.ipynb)|
4443

4544
#### رؤية الكمبيوتر[[pytorch-cv]]

docs/source/ja/internal/generation_utils.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -300,28 +300,6 @@ generation_output[:2]
300300
[[autodoc]] MaxTimeCriteria
301301
- __call__
302302

303-
## Constraints
304-
305-
[`Constraint`] を使用すると、生成時に出力に特定のトークンまたはシーケンスが含まれるように強制できます。これは PyTorch 実装でのみ利用可能であることに注意してください。
306-
307-
[[autodoc]] Constraint
308-
309-
[[autodoc]] PhrasalConstraint
310-
311-
[[autodoc]] DisjunctiveConstraint
312-
313-
[[autodoc]] ConstraintListState
314-
315-
## BeamSearch
316-
317-
[[autodoc]] BeamScorer
318-
- process
319-
- finalize
320-
321-
[[autodoc]] ConstrainedBeamSearchScorer
322-
- process
323-
- finalize
324-
325303
## Streamers
326304

327305
[[autodoc]] TextStreamer

docs/source/ko/internal/generation_utils.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -305,28 +305,6 @@ generation_output[:2]
305305
[[autodoc]] EosTokenCriteria
306306
- __call__
307307

308-
## Constraint [[transformers.Constraint]]
309-
310-
[`Constraint`]는 생성 출력에 특정 토큰이나 시퀀스를 강제로 포함시키는 데 사용됩니다. 이 기능은 PyTorch 구현에만 제공됩니다.
311-
312-
[[autodoc]] Constraint
313-
314-
[[autodoc]] PhrasalConstraint
315-
316-
[[autodoc]] DisjunctiveConstraint
317-
318-
[[autodoc]] ConstraintListState
319-
320-
## 빔 검색 (BeamSearch) [[transformers.BeamScorer]]
321-
322-
[[autodoc]] BeamScorer
323-
- process
324-
- finalize
325-
326-
[[autodoc]] ConstrainedBeamSearchScorer
327-
- process
328-
- finalize
329-
330308
## 스트리머 (Streamers) [[transformers.TextStreamer]]
331309

332310
[[autodoc]] TextStreamer

docs/source/zh/internal/generation_utils.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -295,28 +295,6 @@ generation_output[:2]
295295
[[autodoc]] MaxTimeCriteria
296296
- __call__
297297

298-
## Constraints
299-
300-
可以使用[`Constraint`]来强制生成结果包含输出中的特定tokens或序列。请注意,这仅适用于我们的PyTorch实现。
301-
302-
[[autodoc]] Constraint
303-
304-
[[autodoc]] PhrasalConstraint
305-
306-
[[autodoc]] DisjunctiveConstraint
307-
308-
[[autodoc]] ConstraintListState
309-
310-
## BeamSearch
311-
312-
[[autodoc]] BeamScorer
313-
- process
314-
- finalize
315-
316-
[[autodoc]] ConstrainedBeamSearchScorer
317-
- process
318-
- finalize
319-
320298
## Streamers
321299

322300
[[autodoc]] TextStreamer

notebooks/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ You can open any page of the documentation as a notebook in Colab (there is a bu
5656
| [How to fine-tune a model on summarization](https://github.com/huggingface/notebooks/blob/main/examples/summarization.ipynb)| Show how to preprocess the data and fine-tune a pretrained model on XSUM. | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization.ipynb)| [![Open in AWS Studio](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/examples/summarization.ipynb)|
5757
| [How to train a language model from scratch](https://github.com/huggingface/blog/blob/main/notebooks/01_how_to_train.ipynb)| Highlight all the steps to effectively train Transformer model on custom data | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/blog/blob/main/notebooks/01_how_to_train.ipynb)| [![Open in AWS Studio](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/huggingface/blog/blob/main/notebooks/01_how_to_train.ipynb)|
5858
| [How to generate text](https://github.com/huggingface/blog/blob/main/notebooks/02_how_to_generate.ipynb)| How to use different decoding methods for language generation with transformers | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/blog/blob/main/notebooks/02_how_to_generate.ipynb)| [![Open in AWS Studio](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/huggingface/blog/blob/main/notebooks/02_how_to_generate.ipynb)|
59-
| [How to generate text (with constraints)](https://github.com/huggingface/blog/blob/main/notebooks/53_constrained_beam_search.ipynb)| How to guide language generation with user-provided constraints | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/blog/blob/main/notebooks/53_constrained_beam_search.ipynb)| [![Open in AWS Studio](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/huggingface/blog/blob/main/notebooks/53_constrained_beam_search.ipynb)|
6059
| [Reformer](https://github.com/huggingface/blog/blob/main/notebooks/03_reformer.ipynb)| How Reformer pushes the limits of language modeling | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/patrickvonplaten/blog/blob/main/notebooks/03_reformer.ipynb)| [![Open in AWS Studio](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/patrickvonplaten/blog/blob/main/notebooks/03_reformer.ipynb)|
6160

6261
#### Computer Vision[[pytorch-cv]]

src/transformers/generation/beam_constraints.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
from abc import ABC, abstractmethod
22
from typing import Optional
33

4+
from ..utils import logging
45

6+
7+
logger = logging.get_logger(__name__)
8+
9+
10+
# TODO joao, manuel: remove in v4.58.0
511
class Constraint(ABC):
612
r"""Abstract base class for all constraints that can be applied during generation.
713
It must define how the constraint can be satisfied.
@@ -18,6 +24,9 @@ class Constraint(ABC):
1824
"""
1925

2026
def __init__(self):
27+
logger.warning_once(
28+
"Importing `Constraint` classes is deprecated and will be removed in v4.58.0. Constrained beam search has been moved to the Hub: https://hf.co/transformers-community/constrained-beam-search. Please import using `from transformers.generation import Constraint` instead."
29+
)
2130
# test for the above condition
2231
self.test()
2332

0 commit comments

Comments
 (0)