Unverified Commit aa55ff44 authored by Joao Gante's avatar Joao Gante Committed by GitHub
Browse files

Docs: fix `generate`-related rendering issues (#30600)

* does this work?

* like this?

* fix the other generate links

* missing these
parent 801894e0
...@@ -21,7 +21,7 @@ more. It also plays a role in a variety of mixed-modality applications that have ...@@ -21,7 +21,7 @@ more. It also plays a role in a variety of mixed-modality applications that have
and vision-to-text. Some of the models that can generate text include and vision-to-text. Some of the models that can generate text include
GPT2, XLNet, OpenAI GPT, CTRL, TransformerXL, XLM, Bart, T5, GIT, Whisper. GPT2, XLNet, OpenAI GPT, CTRL, TransformerXL, XLM, Bart, T5, GIT, Whisper.
Check out a few examples that use [`~transformers.generation_utils.GenerationMixin.generate`] method to produce Check out a few examples that use [`~generation.GenerationMixin.generate`] method to produce
text outputs for different tasks: text outputs for different tasks:
* [Text summarization](./tasks/summarization#inference) * [Text summarization](./tasks/summarization#inference)
* [Image captioning](./model_doc/git#transformers.GitForCausalLM.forward.example) * [Image captioning](./model_doc/git#transformers.GitForCausalLM.forward.example)
......
...@@ -382,7 +382,7 @@ Tokenize the text and return the `input_ids` as PyTorch tensors: ...@@ -382,7 +382,7 @@ Tokenize the text and return the `input_ids` as PyTorch tensors:
>>> inputs = tokenizer(prompt, return_tensors="pt").input_ids >>> inputs = tokenizer(prompt, return_tensors="pt").input_ids
``` ```
Use the [`~transformers.generation_utils.GenerationMixin.generate`] method to generate text. Use the [`~generation.GenerationMixin.generate`] method to generate text.
For more details about the different text generation strategies and parameters for controlling generation, check out the [Text generation strategies](../generation_strategies) page. For more details about the different text generation strategies and parameters for controlling generation, check out the [Text generation strategies](../generation_strategies) page.
```py ```py
......
...@@ -355,7 +355,7 @@ Tokenize the text and return the `input_ids` as PyTorch tensors: ...@@ -355,7 +355,7 @@ Tokenize the text and return the `input_ids` as PyTorch tensors:
>>> inputs = tokenizer(text, return_tensors="pt").input_ids >>> inputs = tokenizer(text, return_tensors="pt").input_ids
``` ```
Use the [`~transformers.generation_utils.GenerationMixin.generate`] method to create the summarization. For more details about the different text generation strategies and parameters for controlling generation, check out the [Text Generation](../main_classes/text_generation) API. Use the [`~generation.GenerationMixin.generate`] method to create the summarization. For more details about the different text generation strategies and parameters for controlling generation, check out the [Text Generation](../main_classes/text_generation) API.
```py ```py
>>> from transformers import AutoModelForSeq2SeqLM >>> from transformers import AutoModelForSeq2SeqLM
......
...@@ -364,7 +364,7 @@ Tokenize the text and return the `input_ids` as PyTorch tensors: ...@@ -364,7 +364,7 @@ Tokenize the text and return the `input_ids` as PyTorch tensors:
>>> inputs = tokenizer(text, return_tensors="pt").input_ids >>> inputs = tokenizer(text, return_tensors="pt").input_ids
``` ```
Use the [`~transformers.generation_utils.GenerationMixin.generate`] method to create the translation. For more details about the different text generation strategies and parameters for controlling generation, check out the [Text Generation](../main_classes/text_generation) API. Use the [`~generation.GenerationMixin.generate`] method to create the translation. For more details about the different text generation strategies and parameters for controlling generation, check out the [Text Generation](../main_classes/text_generation) API.
```py ```py
>>> from transformers import AutoModelForSeq2SeqLM >>> from transformers import AutoModelForSeq2SeqLM
......
...@@ -18,7 +18,7 @@ rendered properly in your Markdown viewer. ...@@ -18,7 +18,7 @@ rendered properly in your Markdown viewer.
テキスト生成は、オープンエンドのテキスト生成、要約、翻訳など、多くの自然言語処理タスクに不可欠です。また、テキストを出力とするさまざまな混在モダリティアプリケーションにも影響を与えており、例えば音声からテキストへの変換や画像からテキストへの変換などがあります。テキストを生成できるいくつかのモデルには、GPT2、XLNet、OpenAI GPT、CTRL、TransformerXL、XLM、Bart、T5、GIT、Whisperが含まれます。 テキスト生成は、オープンエンドのテキスト生成、要約、翻訳など、多くの自然言語処理タスクに不可欠です。また、テキストを出力とするさまざまな混在モダリティアプリケーションにも影響を与えており、例えば音声からテキストへの変換や画像からテキストへの変換などがあります。テキストを生成できるいくつかのモデルには、GPT2、XLNet、OpenAI GPT、CTRL、TransformerXL、XLM、Bart、T5、GIT、Whisperが含まれます。
[`~transformers.generation_utils.GenerationMixin.generate`] メソッドを使用して、異なるタスクのテキスト出力を生成するいくつかの例をご紹介します: [`~generation.GenerationMixin.generate`] メソッドを使用して、異なるタスクのテキスト出力を生成するいくつかの例をご紹介します:
* [テキスト要約](./tasks/summarization#inference) * [テキスト要約](./tasks/summarization#inference)
* [画像のキャプション](./model_doc/git#transformers.GitForCausalLM.forward.example) * [画像のキャプション](./model_doc/git#transformers.GitForCausalLM.forward.example)
* [音声の転記](./model_doc/whisper#transformers.WhisperForConditionalGeneration.forward.example) * [音声の転記](./model_doc/whisper#transformers.WhisperForConditionalGeneration.forward.example)
...@@ -342,4 +342,4 @@ culture, and they allow us to design the' ...@@ -342,4 +342,4 @@ culture, and they allow us to design the'
>>> outputs = model.generate(**inputs, assistant_model=assistant_model, do_sample=True, temperature=0.5) >>> outputs = model.generate(**inputs, assistant_model=assistant_model, do_sample=True, temperature=0.5)
>>> tokenizer.batch_decode(outputs, skip_special_tokens=True) >>> tokenizer.batch_decode(outputs, skip_special_tokens=True)
['Alice and Bob are going to the same party. It is a small party, in a small'] ['Alice and Bob are going to the same party. It is a small party, in a small']
``` ```
\ No newline at end of file
...@@ -388,7 +388,7 @@ TensorFlow でモデルを微調整するには、オプティマイザー関数 ...@@ -388,7 +388,7 @@ TensorFlow でモデルを微調整するには、オプティマイザー関数
>>> inputs = tokenizer(prompt, return_tensors="pt").input_ids >>> inputs = tokenizer(prompt, return_tensors="pt").input_ids
``` ```
[`~transformers.generation_utils.GenerationMixin.generate`] メソッドを使用してテキストを生成します。 [`~generation.GenerationMixin.generate`] メソッドを使用してテキストを生成します。
さまざまなテキスト生成戦略と生成を制御するためのパラメーターの詳細については、[テキスト生成戦略](../generation_strategies) ページを参照してください。 さまざまなテキスト生成戦略と生成を制御するためのパラメーターの詳細については、[テキスト生成戦略](../generation_strategies) ページを参照してください。
```py ```py
......
...@@ -358,7 +358,7 @@ Tokenize the text and return the `input_ids` as PyTorch tensors: ...@@ -358,7 +358,7 @@ Tokenize the text and return the `input_ids` as PyTorch tensors:
>>> inputs = tokenizer(text, return_tensors="pt").input_ids >>> inputs = tokenizer(text, return_tensors="pt").input_ids
``` ```
[`~transformers.generation_utils.GenerationMixin.generate`] メソッドを使用して要約を作成します。さまざまなテキスト生成戦略と生成を制御するためのパラメーターの詳細については、[Text Generation](../main_classes/text_generation) API を確認してください。 [`~generation.GenerationMixin.generate`] メソッドを使用して要約を作成します。さまざまなテキスト生成戦略と生成を制御するためのパラメーターの詳細については、[Text Generation](../main_classes/text_generation) API を確認してください。
```py ```py
>>> from transformers import AutoModelForSeq2SeqLM >>> from transformers import AutoModelForSeq2SeqLM
......
...@@ -366,7 +366,7 @@ TensorFlow でモデルを微調整するには、オプティマイザー関数 ...@@ -366,7 +366,7 @@ TensorFlow でモデルを微調整するには、オプティマイザー関数
>>> inputs = tokenizer(text, return_tensors="pt").input_ids >>> inputs = tokenizer(text, return_tensors="pt").input_ids
``` ```
[`~transformers.generation_utils.GenerationMixin.generate`] メソッドを使用して翻訳を作成します。さまざまなテキスト生成戦略と生成を制御するためのパラメーターの詳細については、[Text Generation](../main_classes/text_generation) API を確認してください。 [`~generation.GenerationMixin.generate`] メソッドを使用して翻訳を作成します。さまざまなテキスト生成戦略と生成を制御するためのパラメーターの詳細については、[Text Generation](../main_classes/text_generation) API を確認してください。
```py ```py
......
...@@ -19,7 +19,7 @@ rendered properly in your Markdown viewer. ...@@ -19,7 +19,7 @@ rendered properly in your Markdown viewer.
텍스트 생성은 개방형 텍스트 작성, 요약, 번역 등 다양한 자연어 처리(NLP) 작업에 필수적입니다. 이는 또한 음성-텍스트 변환, 시각-텍스트 변환과 같이 텍스트를 출력으로 하는 여러 혼합 모달리티 응용 프로그램에서도 중요한 역할을 합니다. 텍스트 생성을 가능하게 하는 몇몇 모델로는 GPT2, XLNet, OpenAI GPT, CTRL, TransformerXL, XLM, Bart, T5, GIT, Whisper 등이 있습니다. 텍스트 생성은 개방형 텍스트 작성, 요약, 번역 등 다양한 자연어 처리(NLP) 작업에 필수적입니다. 이는 또한 음성-텍스트 변환, 시각-텍스트 변환과 같이 텍스트를 출력으로 하는 여러 혼합 모달리티 응용 프로그램에서도 중요한 역할을 합니다. 텍스트 생성을 가능하게 하는 몇몇 모델로는 GPT2, XLNet, OpenAI GPT, CTRL, TransformerXL, XLM, Bart, T5, GIT, Whisper 등이 있습니다.
[`~transformers.generation_utils.GenerationMixin.generate`] 메서드를 활용하여 다음과 같은 다양한 작업들에 대해 텍스트 결과물을 생성하는 몇 가지 예시를 살펴보세요: [`~generation.GenerationMixin.generate`] 메서드를 활용하여 다음과 같은 다양한 작업들에 대해 텍스트 결과물을 생성하는 몇 가지 예시를 살펴보세요:
* [텍스트 요약](./tasks/summarization#inference) * [텍스트 요약](./tasks/summarization#inference)
* [이미지 캡셔닝](./model_doc/git#transformers.GitForCausalLM.forward.example) * [이미지 캡셔닝](./model_doc/git#transformers.GitForCausalLM.forward.example)
* [오디오 전사](./model_doc/whisper#transformers.WhisperForConditionalGeneration.forward.example) * [오디오 전사](./model_doc/whisper#transformers.WhisperForConditionalGeneration.forward.example)
......
...@@ -366,7 +366,7 @@ TensorFlow에서 모델을 미세 조정하려면, 먼저 옵티마이저 함수 ...@@ -366,7 +366,7 @@ TensorFlow에서 모델을 미세 조정하려면, 먼저 옵티마이저 함수
>>> inputs = tokenizer(prompt, return_tensors="pt").input_ids >>> inputs = tokenizer(prompt, return_tensors="pt").input_ids
``` ```
[`~transformers.generation_utils.GenerationMixin.generate`] 메소드를 사용하여 텍스트를 생성하세요. 생성을 제어하는 다양한 텍스트 생성 전략과 매개변수에 대한 자세한 내용은 [텍스트 생성 전략](../generation_strategies) 페이지를 확인하세요. [`~generation.GenerationMixin.generate`] 메소드를 사용하여 텍스트를 생성하세요. 생성을 제어하는 다양한 텍스트 생성 전략과 매개변수에 대한 자세한 내용은 [텍스트 생성 전략](../generation_strategies) 페이지를 확인하세요.
```py ```py
>>> from transformers import AutoModelForCausalLM >>> from transformers import AutoModelForCausalLM
......
...@@ -21,7 +21,7 @@ rendered properly in your Markdown viewer. ...@@ -21,7 +21,7 @@ rendered properly in your Markdown viewer.
<Youtube id="yHnr5Dk2zCI"/> <Youtube id="yHnr5Dk2zCI"/>
요약은 문서나 기사에서 중요한 정보를 모두 포함하되 짧게 만드는 일입니다. 요약은 문서나 기사에서 중요한 정보를 모두 포함하되 짧게 만드는 일입니다.
번역과 마찬가지로, 시퀀스-투-시퀀스 문제로 구성할 수 있는 대표적인 작업 중 하나입니다. 번역과 마찬가지로, 시퀀스-투-시퀀스 문제로 구성할 수 있는 대표적인 작업 중 하나입니다.
요약에는 아래와 같이 유형이 있습니다: 요약에는 아래와 같이 유형이 있습니다:
- 추출(Extractive) 요약: 문서에서 가장 관련성 높은 정보를 추출합니다. - 추출(Extractive) 요약: 문서에서 가장 관련성 높은 정보를 추출합니다.
...@@ -44,7 +44,7 @@ rendered properly in your Markdown viewer. ...@@ -44,7 +44,7 @@ rendered properly in your Markdown viewer.
pip install transformers datasets evaluate rouge_score pip install transformers datasets evaluate rouge_score
``` ```
Hugging Face 계정에 로그인하면 모델을 업로드하고 커뮤니티에 공유할 수 있습니다. Hugging Face 계정에 로그인하면 모델을 업로드하고 커뮤니티에 공유할 수 있습니다.
토큰을 입력하여 로그인하세요. 토큰을 입력하여 로그인하세요.
```py ```py
...@@ -114,14 +114,14 @@ Hugging Face 계정에 로그인하면 모델을 업로드하고 커뮤니티에 ...@@ -114,14 +114,14 @@ Hugging Face 계정에 로그인하면 모델을 업로드하고 커뮤니티에
... return model_inputs ... return model_inputs
``` ```
전체 데이터셋에 전처리 함수를 적용하려면 🤗 Datasets의 [`~datasets.Dataset.map`] 메소드를 사용하세요. 전체 데이터셋에 전처리 함수를 적용하려면 🤗 Datasets의 [`~datasets.Dataset.map`] 메소드를 사용하세요.
`batched=True`로 설정하여 데이터셋의 여러 요소를 한 번에 처리하면 `map` 함수의 속도를 높일 수 있습니다. `batched=True`로 설정하여 데이터셋의 여러 요소를 한 번에 처리하면 `map` 함수의 속도를 높일 수 있습니다.
```py ```py
>>> tokenized_billsum = billsum.map(preprocess_function, batched=True) >>> tokenized_billsum = billsum.map(preprocess_function, batched=True)
``` ```
이제 [`DataCollatorForSeq2Seq`]를 사용하여 예제 배치를 만드세요. 이제 [`DataCollatorForSeq2Seq`]를 사용하여 예제 배치를 만드세요.
전체 데이터셋을 최대 길이로 패딩하는 것보다 배치마다 가장 긴 문장 길이에 맞춰 *동적 패딩*하는 것이 더 효율적입니다. 전체 데이터셋을 최대 길이로 패딩하는 것보다 배치마다 가장 긴 문장 길이에 맞춰 *동적 패딩*하는 것이 더 효율적입니다.
<frameworkcontent> <frameworkcontent>
...@@ -143,9 +143,9 @@ Hugging Face 계정에 로그인하면 모델을 업로드하고 커뮤니티에 ...@@ -143,9 +143,9 @@ Hugging Face 계정에 로그인하면 모델을 업로드하고 커뮤니티에
## 평가[[evaluate]] ## 평가[[evaluate]]
학습 중에 평가 지표를 포함하면 모델의 성능을 평가하는 데 도움이 되는 경우가 많습니다. 학습 중에 평가 지표를 포함하면 모델의 성능을 평가하는 데 도움이 되는 경우가 많습니다.
🤗 [Evaluate](https://huggingface.co/docs/evaluate/index) 라이브러리를 사용하면 평가 방법을 빠르게 불러올 수 있습니다. 🤗 [Evaluate](https://huggingface.co/docs/evaluate/index) 라이브러리를 사용하면 평가 방법을 빠르게 불러올 수 있습니다.
이 작업에서는 [ROUGE](https://huggingface.co/spaces/evaluate-metric/rouge) 평가 지표를 가져옵니다. 이 작업에서는 [ROUGE](https://huggingface.co/spaces/evaluate-metric/rouge) 평가 지표를 가져옵니다.
(평가 지표를 불러오고 계산하는 방법은 🤗 Evaluate [둘러보기](https://huggingface.co/docs/evaluate/a_quick_tour)를 참조하세요.) (평가 지표를 불러오고 계산하는 방법은 🤗 Evaluate [둘러보기](https://huggingface.co/docs/evaluate/a_quick_tour)를 참조하세요.)
```py ```py
...@@ -196,9 +196,9 @@ Hugging Face 계정에 로그인하면 모델을 업로드하고 커뮤니티에 ...@@ -196,9 +196,9 @@ Hugging Face 계정에 로그인하면 모델을 업로드하고 커뮤니티에
이제 세 단계만 남았습니다: 이제 세 단계만 남았습니다:
1. [`Seq2SeqTrainingArguments`]에서 학습 하이퍼파라미터를 정의하세요. 1. [`Seq2SeqTrainingArguments`]에서 학습 하이퍼파라미터를 정의하세요.
유일한 필수 매개변수는 모델을 저장할 위치를 지정하는 `output_dir`입니다. 유일한 필수 매개변수는 모델을 저장할 위치를 지정하는 `output_dir`입니다.
`push_to_hub=True`를 설정하여 이 모델을 Hub에 푸시할 수 있습니다(모델을 업로드하려면 Hugging Face에 로그인해야 합니다.) `push_to_hub=True`를 설정하여 이 모델을 Hub에 푸시할 수 있습니다(모델을 업로드하려면 Hugging Face에 로그인해야 합니다.)
[`Trainer`]는 각 에폭이 끝날 때마다 ROUGE 지표를 평가하고 학습 체크포인트를 저장합니다. [`Trainer`]는 각 에폭이 끝날 때마다 ROUGE 지표를 평가하고 학습 체크포인트를 저장합니다.
2. 모델, 데이터셋, 토크나이저, 데이터 콜레이터 및 `compute_metrics` 함수와 함께 학습 인수를 [`Seq2SeqTrainer`]에 전달하세요. 2. 모델, 데이터셋, 토크나이저, 데이터 콜레이터 및 `compute_metrics` 함수와 함께 학습 인수를 [`Seq2SeqTrainer`]에 전달하세요.
3. [`~Trainer.train`]을 호출하여 모델을 파인튜닝하세요. 3. [`~Trainer.train`]을 호출하여 모델을 파인튜닝하세요.
...@@ -285,7 +285,7 @@ TensorFlow에서 모델을 파인튜닝하려면, 먼저 옵티마이저, 학습 ...@@ -285,7 +285,7 @@ TensorFlow에서 모델을 파인튜닝하려면, 먼저 옵티마이저, 학습
>>> model.compile(optimizer=optimizer) >>> model.compile(optimizer=optimizer)
``` ```
학습을 시작하기 전에 설정해야 할 마지막 두 가지는 예측에서 ROUGE 점수를 계산하고 모델을 Hub에 푸시하는 방법을 제공하는 것입니다. 학습을 시작하기 전에 설정해야 할 마지막 두 가지는 예측에서 ROUGE 점수를 계산하고 모델을 Hub에 푸시하는 방법을 제공하는 것입니다.
두 작업 모두 [Keras callbacks](../main_classes/keras_callbacks)으로 수행할 수 있습니다. 두 작업 모두 [Keras callbacks](../main_classes/keras_callbacks)으로 수행할 수 있습니다.
[`~transformers.KerasMetricCallback`]에 `compute_metrics` 함수를 전달하세요: [`~transformers.KerasMetricCallback`]에 `compute_metrics` 함수를 전달하세요:
...@@ -313,7 +313,7 @@ TensorFlow에서 모델을 파인튜닝하려면, 먼저 옵티마이저, 학습 ...@@ -313,7 +313,7 @@ TensorFlow에서 모델을 파인튜닝하려면, 먼저 옵티마이저, 학습
>>> callbacks = [metric_callback, push_to_hub_callback] >>> callbacks = [metric_callback, push_to_hub_callback]
``` ```
드디어 모델 학습을 시작할 준비가 되었습니다! 드디어 모델 학습을 시작할 준비가 되었습니다!
학습 및 검증 데이터셋, 에폭 수 및 콜백과 함께 [`fit`](https://keras.io/api/models/model_training_apis/#fit-method)을 호출하여 모델을 파인튜닝하세요. 학습 및 검증 데이터셋, 에폭 수 및 콜백과 함께 [`fit`](https://keras.io/api/models/model_training_apis/#fit-method)을 호출하여 모델을 파인튜닝하세요.
```py ```py
...@@ -326,7 +326,7 @@ TensorFlow에서 모델을 파인튜닝하려면, 먼저 옵티마이저, 학습 ...@@ -326,7 +326,7 @@ TensorFlow에서 모델을 파인튜닝하려면, 먼저 옵티마이저, 학습
<Tip> <Tip>
요약을 위해 모델을 파인튜닝하는 방법에 대한 더 자세한 예제를 보려면 [PyTorch notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization.ipynb) 요약을 위해 모델을 파인튜닝하는 방법에 대한 더 자세한 예제를 보려면 [PyTorch notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization.ipynb)
또는 [TensorFlow notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization-tf.ipynb)을 참고하세요. 또는 [TensorFlow notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization-tf.ipynb)을 참고하세요.
</Tip> </Tip>
...@@ -341,7 +341,7 @@ TensorFlow에서 모델을 파인튜닝하려면, 먼저 옵티마이저, 학습 ...@@ -341,7 +341,7 @@ TensorFlow에서 모델을 파인튜닝하려면, 먼저 옵티마이저, 학습
>>> text = "summarize: The Inflation Reduction Act lowers prescription drug costs, health care costs, and energy costs. It's the most aggressive action on tackling the climate crisis in American history, which will lift up American workers and create good-paying, union jobs across the country. It'll lower the deficit and ask the ultra-wealthy and corporations to pay their fair share. And no one making under $400,000 per year will pay a penny more in taxes." >>> text = "summarize: The Inflation Reduction Act lowers prescription drug costs, health care costs, and energy costs. It's the most aggressive action on tackling the climate crisis in American history, which will lift up American workers and create good-paying, union jobs across the country. It'll lower the deficit and ask the ultra-wealthy and corporations to pay their fair share. And no one making under $400,000 per year will pay a penny more in taxes."
``` ```
추론을 위해 파인튜닝한 모델을 시험해 보는 가장 간단한 방법은 [`pipeline`]에서 사용하는 것입니다. 추론을 위해 파인튜닝한 모델을 시험해 보는 가장 간단한 방법은 [`pipeline`]에서 사용하는 것입니다.
모델을 사용하여 요약을 수행할 [`pipeline`]을 인스턴스화하고 텍스트를 전달하세요: 모델을 사용하여 요약을 수행할 [`pipeline`]을 인스턴스화하고 텍스트를 전달하세요:
```py ```py
...@@ -366,7 +366,7 @@ TensorFlow에서 모델을 파인튜닝하려면, 먼저 옵티마이저, 학습 ...@@ -366,7 +366,7 @@ TensorFlow에서 모델을 파인튜닝하려면, 먼저 옵티마이저, 학습
>>> inputs = tokenizer(text, return_tensors="pt").input_ids >>> inputs = tokenizer(text, return_tensors="pt").input_ids
``` ```
요약문을 생성하려면 [`~transformers.generation_utils.GenerationMixin.generate`] 메소드를 사용하세요. 요약문을 생성하려면 [`~generation.GenerationMixin.generate`] 메소드를 사용하세요.
텍스트 생성에 대한 다양한 전략과 생성을 제어하기 위한 매개변수에 대한 자세한 내용은 [텍스트 생성](../main_classes/text_generation) API를 참조하세요. 텍스트 생성에 대한 다양한 전략과 생성을 제어하기 위한 매개변수에 대한 자세한 내용은 [텍스트 생성](../main_classes/text_generation) API를 참조하세요.
```py ```py
...@@ -393,7 +393,7 @@ TensorFlow에서 모델을 파인튜닝하려면, 먼저 옵티마이저, 학습 ...@@ -393,7 +393,7 @@ TensorFlow에서 모델을 파인튜닝하려면, 먼저 옵티마이저, 학습
>>> inputs = tokenizer(text, return_tensors="tf").input_ids >>> inputs = tokenizer(text, return_tensors="tf").input_ids
``` ```
요약문을 생성하려면 [`~transformers.generation_tf_utils.TFGenerationMixin.generate`] 메소드를 사용하세요. 요약문을 생성하려면 [`~transformers.generation_tf_utils.TFGenerationMixin.generate`] 메소드를 사용하세요.
텍스트 생성에 대한 다양한 전략과 생성을 제어하기 위한 매개변수에 대한 자세한 내용은 [텍스트 생성](../main_classes/text_generation) API를 참조하세요. 텍스트 생성에 대한 다양한 전략과 생성을 제어하기 위한 매개변수에 대한 자세한 내용은 [텍스트 생성](../main_classes/text_generation) API를 참조하세요.
```py ```py
......
...@@ -341,7 +341,7 @@ TensorFlow에서 모델을 파인튜닝하려면 우선 optimizer 함수, 학습 ...@@ -341,7 +341,7 @@ TensorFlow에서 모델을 파인튜닝하려면 우선 optimizer 함수, 학습
```py ```py
>>> from transformers import pipeline >>> from transformers import pipeline
# Change `xx` to the language of the input and `yy` to the language of the desired output. # Change `xx` to the language of the input and `yy` to the language of the desired output.
# Examples: "en" for English, "fr" for French, "de" for German, "es" for Spanish, "zh" for Chinese, etc; translation_en_to_fr translates English to French # Examples: "en" for English, "fr" for French, "de" for German, "es" for Spanish, "zh" for Chinese, etc; translation_en_to_fr translates English to French
# You can view all the lists of languages here - https://huggingface.co/languages # You can view all the lists of languages here - https://huggingface.co/languages
>>> translator = pipeline("translation_xx_to_yy", model="my_awesome_opus_books_model") >>> translator = pipeline("translation_xx_to_yy", model="my_awesome_opus_books_model")
...@@ -362,7 +362,7 @@ TensorFlow에서 모델을 파인튜닝하려면 우선 optimizer 함수, 학습 ...@@ -362,7 +362,7 @@ TensorFlow에서 모델을 파인튜닝하려면 우선 optimizer 함수, 학습
>>> inputs = tokenizer(text, return_tensors="pt").input_ids >>> inputs = tokenizer(text, return_tensors="pt").input_ids
``` ```
[`~transformers.generation_utils.GenerationMixin.generate`] 메서드로 번역을 생성하세요. 다양한 텍스트 생성 전략 및 생성을 제어하기 위한 매개변수에 대한 자세한 내용은 [Text Generation](../main_classes/text_generation) API를 살펴보시기 바랍니다. [`~generation.GenerationMixin.generate`] 메서드로 번역을 생성하세요. 다양한 텍스트 생성 전략 및 생성을 제어하기 위한 매개변수에 대한 자세한 내용은 [Text Generation](../main_classes/text_generation) API를 살펴보시기 바랍니다.
```py ```py
>>> from transformers import AutoModelForSeq2SeqLM >>> from transformers import AutoModelForSeq2SeqLM
......
...@@ -218,8 +218,7 @@ class GenerationConfig(PushToHubMixin): ...@@ -218,8 +218,7 @@ class GenerationConfig(PushToHubMixin):
Switch to sequential beam search and sequential topk for contrastive search to reduce peak memory. Switch to sequential beam search and sequential topk for contrastive search to reduce peak memory.
Used with beam search and contrastive search. Used with beam search and contrastive search.
> Parameters that define the output variables of generate
> Parameters that define the output variables of `generate`
num_return_sequences(`int`, *optional*, defaults to 1): num_return_sequences(`int`, *optional*, defaults to 1):
The number of independently computed returned sequences for each element in the batch. The number of independently computed returned sequences for each element in the batch.
...@@ -256,25 +255,21 @@ class GenerationConfig(PushToHubMixin): ...@@ -256,25 +255,21 @@ class GenerationConfig(PushToHubMixin):
`batch_size`. Indicating a list enables different start ids for each element in the batch `batch_size`. Indicating a list enables different start ids for each element in the batch
(e.g. multilingual models with different target languages in one batch) (e.g. multilingual models with different target languages in one batch)
> Generation parameters exclusive to assistant generation
> Generation parameters exclusive to [assistant generation](https://arxiv.org/abs/2211.17192)
num_assistant_tokens (`int`, *optional*, defaults to 5): num_assistant_tokens (`int`, *optional*, defaults to 5):
Defines the number of _speculative tokens_ that shall be generated by the assistant model before being Defines the number of _speculative tokens_ that shall be generated by the assistant model before being
checked by the target model at each iteration. Higher values for `num_assistant_tokens` make the generation checked by the target model at each iteration. Higher values for `num_assistant_tokens` make the generation
more _speculative_ : If the assistant model is performant larger speed-ups can be reached, if the assistant more _speculative_ : If the assistant model is performant larger speed-ups can be reached, if the assistant
model requires lots of corrections, lower speed-ups are reached. model requires lots of corrections, lower speed-ups are reached.
num_assistant_tokens_schedule (`str`, *optional*, defaults to `"heuristic"`): num_assistant_tokens_schedule (`str`, *optional*, defaults to `"heuristic"`):
Defines the schedule at which max assistant tokens shall be changed during inference. Defines the schedule at which max assistant tokens shall be changed during inference.
- `"heuristic"`: When all speculative tokens are correct, increase `num_assistant_tokens` by 2 else - `"heuristic"`: When all speculative tokens are correct, increase `num_assistant_tokens` by 2 else
reduce by 1. `num_assistant_tokens` value is persistent over multiple generation calls with the same assistant model. reduce by 1. `num_assistant_tokens` value is persistent over multiple generation calls with the same assistant model.
- `"heuristic_transient"`: Same as `"heuristic"` but `num_assistant_tokens` is reset to its initial value after each generation call. - `"heuristic_transient"`: Same as `"heuristic"` but `num_assistant_tokens` is reset to its initial value after each generation call.
- `"constant"`: `num_assistant_tokens` stays unchanged during generation - `"constant"`: `num_assistant_tokens` stays unchanged during generation
prompt_lookup_num_tokens (`int`, *optional*, default to `None`): prompt_lookup_num_tokens (`int`, *optional*, default to `None`):
The number of tokens to be output as candidate tokens. The number of tokens to be output as candidate tokens.
max_matching_ngram_size (`int`, *optional*, default to `None`): max_matching_ngram_size (`int`, *optional*, default to `None`):
The maximum ngram size to be considered for matching in the prompt. Default to 2 if not provided. The maximum ngram size to be considered for matching in the prompt. Default to 2 if not provided.
...@@ -283,7 +278,6 @@ class GenerationConfig(PushToHubMixin): ...@@ -283,7 +278,6 @@ class GenerationConfig(PushToHubMixin):
cache_implementation (`str`, *optional*, default to `None`): cache_implementation (`str`, *optional*, default to `None`):
Cache class that should be used when generating. Cache class that should be used when generating.
> Wild card > Wild card
generation_kwargs: generation_kwargs:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment