source
stringclasses
470 values
url
stringlengths
49
167
file_type
stringclasses
1 value
chunk
stringlengths
1
512
chunk_id
stringlengths
5
9
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#react-agents
.md
This agent that solves the given task step by step, using the ReAct framework: While the objective is not reached, the agent will perform a cycle of thinking and acting. The action will be parsed from the LLM output: it consists in calls to tools from the toolbox, with arguments chosen by the LLM engine. This agent that solves the given task step by step, using the ReAct framework: While the objective is not reached, the agent will perform a cycle of thinking and acting.
449_5_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#react-agents
.md
While the objective is not reached, the agent will perform a cycle of thinking and acting. The tool calls will be formulated by the LLM in JSON format, then parsed and executed. This agent that solves the given task step by step, using the ReAct framework: While the objective is not reached, the agent will perform a cycle of thinking and acting. The tool calls will be formulated by the LLM in code format, then parsed and executed.
449_5_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#managedagent
.md
ManagedAgent
449_6_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#loadtool
.md
Main function to quickly load a tool, be it on the Hub or in the Transformers library. <Tip warning={true}> Loading a tool means that you'll download the tool and execute it locally. ALWAYS inspect the tool you're downloading before loading it within your runtime, as you would do when installing a package using pip/npm/apt. </Tip> Args: task_or_repo_id (`str`): The task for which to load the tool or a repo ID of a tool on the Hub. Tasks implemented in Transformers are:
449_7_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#loadtool
.md
The task for which to load the tool or a repo ID of a tool on the Hub. Tasks implemented in Transformers are: - `"document_question_answering"` - `"image_question_answering"` - `"speech_to_text"` - `"text_to_speech"` - `"translation"` model_repo_id (`str`, *optional*): Use this argument to use a different model than the default one for the tool you selected. token (`str`, *optional*): The token to identify you on hf.co. If unset, will use the token generated when running `huggingface-cli
449_7_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#loadtool
.md
The token to identify you on hf.co. If unset, will use the token generated when running `huggingface-cli login` (stored in `~/.huggingface`). kwargs (additional keyword arguments, *optional*): Additional keyword arguments that will be split in two: all arguments relevant to the Hub (such as `cache_dir`, `revision`, `subfolder`) will be used when downloading the files for your tool, and the others will be passed along to its init.
449_7_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#tool
.md
Converts a function into an instance of a Tool subclass. Args: tool_function: Your function. Should have type hints for each input and a type hint for the output. Should also have a docstring description including an 'Args:' part where each argument is described.
449_8_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#tool
.md
A base class for the functions used by the agent. Subclass this and implement the `__call__` method as well as the following class attributes: - **description** (`str`) -- A short description of what your tool does, the inputs it expects and the output(s) it will return. For instance 'This is a tool that downloads a file from a `url`. It takes the `url` as input, and returns the text contained in the file'.
449_9_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#tool
.md
returns the text contained in the file'. - **name** (`str`) -- A performative name that will be used for your tool in the prompt to the agent. For instance `"text-classifier"` or `"image_generator"`. - **inputs** (`Dict[str, Dict[str, Union[str, type]]]`) -- The dict of modalities expected for the inputs. It has one `type`key and a `description`key. This is used by `launch_gradio_demo` or to make a nice space from your tool, and also can be used in the generated description for your tool.
449_9_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#tool
.md
description for your tool. - **output_type** (`type`) -- The type of the tool output. This is used by `launch_gradio_demo` or to make a nice space from your tool, and also can be used in the generated description for your tool. You can also override the method [`~Tool.setup`] if your tool as an expensive operation to perform before being usable (such as loading a model). [`~Tool.setup`] will be called the first time you use your tool, but not at instantiation.
449_9_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#toolbox
.md
A base class for the functions used by the agent. Subclass this and implement the `__call__` method as well as the following class attributes: - **description** (`str`) -- A short description of what your tool does, the inputs it expects and the output(s) it will return. For instance 'This is a tool that downloads a file from a `url`. It takes the `url` as input, and returns the text contained in the file'.
449_10_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#toolbox
.md
returns the text contained in the file'. - **name** (`str`) -- A performative name that will be used for your tool in the prompt to the agent. For instance `"text-classifier"` or `"image_generator"`. - **inputs** (`Dict[str, Dict[str, Union[str, type]]]`) -- The dict of modalities expected for the inputs. It has one `type`key and a `description`key. This is used by `launch_gradio_demo` or to make a nice space from your tool, and also can be used in the generated description for your tool.
449_10_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#toolbox
.md
description for your tool. - **output_type** (`type`) -- The type of the tool output. This is used by `launch_gradio_demo` or to make a nice space from your tool, and also can be used in the generated description for your tool. You can also override the method [`~Tool.setup`] if your tool as an expensive operation to perform before being usable (such as loading a model). [`~Tool.setup`] will be called the first time you use your tool, but not at instantiation. box
449_10_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#pipelinetool
.md
A [`Tool`] tailored towards Transformer models. On top of the class attributes of the base class [`Tool`], you will need to specify: - **model_class** (`type`) -- The class to use to load the model in this tool. - **default_checkpoint** (`str`) -- The default checkpoint that should be used when the user doesn't specify one. - **pre_processor_class** (`type`, *optional*, defaults to [`AutoProcessor`]) -- The class to use to load the pre-processor
449_11_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#pipelinetool
.md
- **pre_processor_class** (`type`, *optional*, defaults to [`AutoProcessor`]) -- The class to use to load the pre-processor - **post_processor_class** (`type`, *optional*, defaults to [`AutoProcessor`]) -- The class to use to load the post-processor (when different from the pre-processor). Args: model (`str` or [`PreTrainedModel`], *optional*): The name of the checkpoint to use for the model, or the instantiated model. If unset, will default to the value of the class attribute `default_checkpoint`.
449_11_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#pipelinetool
.md
value of the class attribute `default_checkpoint`. pre_processor (`str` or `Any`, *optional*): The name of the checkpoint to use for the pre-processor, or the instantiated pre-processor (can be a tokenizer, an image processor, a feature extractor or a processor). Will default to the value of `model` if unset. post_processor (`str` or `Any`, *optional*): The name of the checkpoint to use for the post-processor, or the instantiated pre-processor (can be a
449_11_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#pipelinetool
.md
The name of the checkpoint to use for the post-processor, or the instantiated pre-processor (can be a tokenizer, an image processor, a feature extractor or a processor). Will default to the `pre_processor` if unset. device (`int`, `str` or `torch.device`, *optional*): The device on which to execute the model. Will default to any accelerator available (GPU, MPS etc...), the CPU otherwise. device_map (`str` or `dict`, *optional*): If passed along, will be used to instantiate the model.
449_11_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#pipelinetool
.md
CPU otherwise. device_map (`str` or `dict`, *optional*): If passed along, will be used to instantiate the model. model_kwargs (`dict`, *optional*): Any keyword argument to send to the model instantiation. token (`str`, *optional*): The token to use as HTTP bearer authorization for remote files. If unset, will use the token generated when running `huggingface-cli login` (stored in `~/.huggingface`). hub_kwargs (additional keyword arguments, *optional*):
449_11_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#pipelinetool
.md
running `huggingface-cli login` (stored in `~/.huggingface`). hub_kwargs (additional keyword arguments, *optional*): Any additional keyword argument to send to the methods that will load the data from the Hub.
449_11_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#launchgradiodemo
.md
Launches a gradio demo for a tool. The corresponding tool class needs to properly implement the class attributes `inputs` and `output_type`. Args: tool_class (`type`): The class of the tool for which to launch the demo.
449_12_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#streamtogradio
.md
Runs an agent with the given task and streams the messages from the agent as gradio ChatMessages.
449_13_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#toolcollection
.md
A base class for the functions used by the agent. Subclass this and implement the `__call__` method as well as the following class attributes: - **description** (`str`) -- A short description of what your tool does, the inputs it expects and the output(s) it will return. For instance 'This is a tool that downloads a file from a `url`. It takes the `url` as input, and returns the text contained in the file'.
449_14_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#toolcollection
.md
returns the text contained in the file'. - **name** (`str`) -- A performative name that will be used for your tool in the prompt to the agent. For instance `"text-classifier"` or `"image_generator"`. - **inputs** (`Dict[str, Dict[str, Union[str, type]]]`) -- The dict of modalities expected for the inputs. It has one `type`key and a `description`key. This is used by `launch_gradio_demo` or to make a nice space from your tool, and also can be used in the generated description for your tool.
449_14_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#toolcollection
.md
description for your tool. - **output_type** (`type`) -- The type of the tool output. This is used by `launch_gradio_demo` or to make a nice space from your tool, and also can be used in the generated description for your tool. You can also override the method [`~Tool.setup`] if your tool as an expensive operation to perform before being usable (such as loading a model). [`~Tool.setup`] will be called the first time you use your tool, but not at instantiation. Collection
449_14_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#engines
.md
You're free to create and use your own engines to be usable by the Agents framework. These engines have the following specification: 1. Follow the [messages format](../chat_templating.md) for its input (`List[Dict[str, str]]`) and return a string. 2. Stop generating outputs *before* the sequences passed in the argument `stop_sequences`
449_15_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#transformersengine
.md
For convenience, we have added a `TransformersEngine` that implements the points above, taking a pre-initialized `Pipeline` as input. ```python >>> from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline, TransformersEngine >>> model_name = "HuggingFaceTB/SmolLM-135M-Instruct" >>> tokenizer = AutoTokenizer.from_pretrained(model_name) >>> model = AutoModelForCausalLM.from_pretrained(model_name) >>> pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
449_16_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#transformersengine
.md
>>> pipe = pipeline("text-generation", model=model, tokenizer=tokenizer) >>> engine = TransformersEngine(pipe) >>> engine([{"role": "user", "content": "Ok!"}], stop_sequences=["great"]) "What a " ``` This engine uses a pre-initialized local text-generation pipeline.
449_16_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#hfapiengine
.md
The `HfApiEngine` is an engine that wraps an [HF Inference API](https://huggingface.co/docs/api-inference/index) client for the execution of the LLM. ```python >>> from transformers import HfApiEngine >>> messages = [ ... {"role": "user", "content": "Hello, how are you?"}, ... {"role": "assistant", "content": "I'm doing great. How can I help you today?"}, ... {"role": "user", "content": "No need to help, take it easy."}, ... ] >>> HfApiEngine()(messages, stop_sequences=["conversation"])
449_17_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#hfapiengine
.md
"That's very kind of you to say! It's always nice to have a relaxed " ``` A class to interact with Hugging Face's Inference API for language model interaction. This engine allows you to communicate with Hugging Face's models using the Inference API. It can be used in both serverless mode or with a dedicated endpoint, supporting features like stop sequences and grammar customization. Parameters: model (`str`, *optional*, defaults to `"meta-llama/Meta-Llama-3.1-8B-Instruct"`):
449_17_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#hfapiengine
.md
Parameters: model (`str`, *optional*, defaults to `"meta-llama/Meta-Llama-3.1-8B-Instruct"`): The Hugging Face model ID to be used for inference. This can be a path or model identifier from the Hugging Face model hub. token (`str`, *optional*): Token used by the Hugging Face API for authentication. If not provided, the class will use the token stored in the Hugging Face CLI configuration. max_tokens (`int`, *optional*, defaults to 1500): The maximum number of tokens allowed in the output.
449_17_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#hfapiengine
.md
max_tokens (`int`, *optional*, defaults to 1500): The maximum number of tokens allowed in the output. timeout (`int`, *optional*, defaults to 120): Timeout for the API request, in seconds. Raises: ValueError: If the model name is not provided.
449_17_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#agent-types
.md
Agents can handle any type of object in-between tools; tools, being completely multimodal, can accept and return text, image, audio, video, among other types. In order to increase compatibility between tools, as well as to correctly render these returns in ipython (jupyter, colab, ipython notebooks, ...), we implement wrapper classes around these types. The wrapped objects should continue behaving as initially; a text object should still behave as a string, an image
449_18_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#agent-types
.md
The wrapped objects should continue behaving as initially; a text object should still behave as a string, an image object should still behave as a `PIL.Image`. These types have three specific purposes: - Calling `to_raw` on the type should return the underlying object - Calling `to_string` on the type should return the object as a string: that can be the string in case of an `AgentText` but will be the path of the serialized version of the object in other instances
449_18_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#agent-types
.md
but will be the path of the serialized version of the object in other instances - Displaying it in an ipython kernel should display the object correctly
449_18_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#agenttext
.md
Text type returned by the agent. Behaves as a string.
449_19_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#agentimage
.md
Image type returned by the agent. Behaves as a PIL.Image.
449_20_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#agentaudio
.md
Audio type returned by the agent.
449_21_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/feature_extractor.md
https://huggingface.co/docs/transformers/en/main_classes/feature_extractor/
.md
<!--Copyright 2021 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
450_0_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/feature_extractor.md
https://huggingface.co/docs/transformers/en/main_classes/feature_extractor/
.md
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
450_0_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/feature_extractor.md
https://huggingface.co/docs/transformers/en/main_classes/feature_extractor/#feature-extractor
.md
A feature extractor is in charge of preparing input features for audio or vision models. This includes feature extraction from sequences, e.g., pre-processing audio files to generate Log-Mel Spectrogram features, feature extraction from images, e.g., cropping image files, but also padding, normalization, and conversion to NumPy, PyTorch, and TensorFlow tensors.
450_1_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/feature_extractor.md
https://huggingface.co/docs/transformers/en/main_classes/feature_extractor/#featureextractionmixin
.md
feature_extraction_utils.FeatureExtractionMixin This is a feature extraction mixin used to provide saving/loading functionality for sequential and image feature extractors. - from_pretrained - save_pretrained
450_2_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/feature_extractor.md
https://huggingface.co/docs/transformers/en/main_classes/feature_extractor/#sequencefeatureextractor
.md
This is a general feature extraction class for speech recognition. Args: feature_size (`int`): The feature dimension of the extracted features. sampling_rate (`int`): The sampling rate at which the audio files should be digitalized expressed in hertz (Hz). padding_value (`float`): The value that is used to fill the padding values / vectors. - pad
450_3_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/feature_extractor.md
https://huggingface.co/docs/transformers/en/main_classes/feature_extractor/#batchfeature
.md
Holds the output of the [`~SequenceFeatureExtractor.pad`] and feature extractor specific `__call__` methods. This class is derived from a python dictionary and can be used as a dictionary. Args: data (`dict`, *optional*): Dictionary of lists/arrays/tensors returned by the __call__/pad methods ('input_values', 'attention_mask', etc.). tensor_type (`Union[None, str, TensorType]`, *optional*): You can give a tensor_type here to convert the lists of integers in PyTorch/TensorFlow/Numpy Tensors at
450_4_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/feature_extractor.md
https://huggingface.co/docs/transformers/en/main_classes/feature_extractor/#batchfeature
.md
You can give a tensor_type here to convert the lists of integers in PyTorch/TensorFlow/Numpy Tensors at initialization.
450_4_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/feature_extractor.md
https://huggingface.co/docs/transformers/en/main_classes/feature_extractor/#imagefeatureextractionmixin
.md
image_utils.ImageFeatureExtractionMixin Mixin that contain utilities for preparing image features.
450_5_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/executorch.md
https://huggingface.co/docs/transformers/en/main_classes/executorch/
.md
<!--Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
451_0_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/executorch.md
https://huggingface.co/docs/transformers/en/main_classes/executorch/
.md
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
451_0_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/executorch.md
https://huggingface.co/docs/transformers/en/main_classes/executorch/#executorch
.md
[`ExecuTorch`](https://github.com/pytorch/executorch) is an end-to-end solution for enabling on-device inference capabilities across mobile and edge devices including wearables, embedded devices and microcontrollers. It is part of the PyTorch ecosystem and supports the deployment of PyTorch models with a focus on portability, productivity, and performance.
451_1_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/executorch.md
https://huggingface.co/docs/transformers/en/main_classes/executorch/#executorch
.md
ExecuTorch introduces well defined entry points to perform model, device, and/or use-case specific optimizations such as backend delegation, user-defined compiler transformations, memory planning, and more. The first step in preparing a PyTorch model for execution on an edge device using ExecuTorch is to export the model. This is achieved through the use of a PyTorch API called [`torch.export`](https://pytorch.org/docs/stable/export.html).
451_1_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/executorch.md
https://huggingface.co/docs/transformers/en/main_classes/executorch/#executorch-integration
.md
An integration point is being developed to ensure that 🤗 Transformers can be exported using `torch.export`. The goal of this integration is not only to enable export but also to ensure that the exported artifact can be further lowered and optimized to run efficiently in `ExecuTorch`, particularly for mobile and edge use cases. A wrapper module designed to make a `PreTrainedModel` exportable with `torch.export`, specifically for use with static caching. This module ensures that the exported model
451_2_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/executorch.md
https://huggingface.co/docs/transformers/en/main_classes/executorch/#executorch-integration
.md
specifically for use with static caching. This module ensures that the exported model is compatible with further lowering and execution in `ExecuTorch`. Note: This class is specifically designed to support export process using `torch.export` in a way that ensures the model can be further lowered and run efficiently in `ExecuTorch`. - forward Convert a `PreTrainedModel` into an exportable module and export it using `torch.export`, ensuring the exported model is compatible with `ExecuTorch`. Args:
451_2_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/executorch.md
https://huggingface.co/docs/transformers/en/main_classes/executorch/#executorch-integration
.md
ensuring the exported model is compatible with `ExecuTorch`. Args: model (`PreTrainedModel`): The pretrained model to be exported. example_input_ids (`torch.Tensor`): Example input token id used by `torch.export`. example_cache_position (`torch.Tensor`): Example current cache position used by `torch.export`. Returns: Exported program (`torch.export.ExportedProgram`): The exported program generated via `torch.export`.
451_2_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/
.md
<!--Copyright 2022 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
452_0_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/
.md
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
452_0_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generation
.md
Each framework has a generate method for text generation implemented in their respective `GenerationMixin` class: - PyTorch [`~generation.GenerationMixin.generate`] is implemented in [`~generation.GenerationMixin`]. - TensorFlow [`~generation.TFGenerationMixin.generate`] is implemented in [`~generation.TFGenerationMixin`]. - Flax/JAX [`~generation.FlaxGenerationMixin.generate`] is implemented in [`~generation.FlaxGenerationMixin`].
452_1_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generation
.md
- Flax/JAX [`~generation.FlaxGenerationMixin.generate`] is implemented in [`~generation.FlaxGenerationMixin`]. Regardless of your framework of choice, you can parameterize the generate method with a [`~generation.GenerationConfig`] class instance. Please refer to this class for the complete list of generation parameters, which control the behavior of the generation method. To learn how to inspect a model's generation configuration, what are the defaults, how to change the parameters ad hoc,
452_1_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generation
.md
To learn how to inspect a model's generation configuration, what are the defaults, how to change the parameters ad hoc, and how to create and save a customized generation configuration, refer to the [text generation strategies guide](../generation_strategies). The guide also explains how to use related features, like token streaming.
452_1_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
generation.GenerationConfig Class that holds a configuration for a generation task. A `generate` call supports the following generation methods for text-decoder, text-to-text, speech-to-text, and vision-to-text models: - *greedy decoding* if `num_beams=1` and `do_sample=False` - *contrastive search* if `penalty_alpha>0.` and `top_k>1` - *multinomial sampling* if `num_beams=1` and `do_sample=True` - *beam-search decoding* if `num_beams>1` and `do_sample=False`
452_2_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
- *multinomial sampling* if `num_beams=1` and `do_sample=True` - *beam-search decoding* if `num_beams>1` and `do_sample=False` - *beam-search multinomial sampling* if `num_beams>1` and `do_sample=True` - *diverse beam-search decoding* if `num_beams>1` and `num_beam_groups>1` - *constrained beam-search decoding* if `constraints!=None` or `force_words_ids!=None` - *assisted decoding* if `assistant_model` or `prompt_lookup_num_tokens` is passed to `.generate()`
452_2_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
- *assisted decoding* if `assistant_model` or `prompt_lookup_num_tokens` is passed to `.generate()` - *dola decoding* if `dola_layers` is passed to `.generate()` To learn more about decoding strategies refer to the [text generation strategies guide](../generation_strategies). <Tip> A large number of these flags control the logits or the stopping criteria of the generation. Make sure you check the [generate-related classes](https://huggingface.co/docs/transformers/internal/generation_utils) for a full
452_2_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
the [generate-related classes](https://huggingface.co/docs/transformers/internal/generation_utils) for a full description of the possible manipulations, as well as examples of their usage. </Tip> Arg: > Parameters that control the length of the output max_length (`int`, *optional*, defaults to 20): The maximum length the generated tokens can have. Corresponds to the length of the input prompt + `max_new_tokens`. Its effect is overridden by `max_new_tokens`, if also set.
452_2_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
`max_new_tokens`. Its effect is overridden by `max_new_tokens`, if also set. max_new_tokens (`int`, *optional*): The maximum numbers of tokens to generate, ignoring the number of tokens in the prompt. min_length (`int`, *optional*, defaults to 0): The minimum length of the sequence to be generated. Corresponds to the length of the input prompt + `min_new_tokens`. Its effect is overridden by `min_new_tokens`, if also set. min_new_tokens (`int`, *optional*):
452_2_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
`min_new_tokens`. Its effect is overridden by `min_new_tokens`, if also set. min_new_tokens (`int`, *optional*): The minimum numbers of tokens to generate, ignoring the number of tokens in the prompt. early_stopping (`bool` or `str`, *optional*, defaults to `False`): Controls the stopping condition for beam-based methods, like beam-search. It accepts the following values: `True`, where the generation stops as soon as there are `num_beams` complete candidates; `False`, where an
452_2_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
`True`, where the generation stops as soon as there are `num_beams` complete candidates; `False`, where an heuristic is applied and the generation stops when is it very unlikely to find better candidates; `"never"`, where the beam search procedure only stops when there cannot be better candidates (canonical beam search algorithm). max_time (`float`, *optional*): The maximum amount of time you allow the computation to run for in seconds. generation will still finish
452_2_6
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
The maximum amount of time you allow the computation to run for in seconds. generation will still finish the current pass after allocated time has been passed. stop_strings (`str or List[str]`, *optional*): A string or a list of strings that should terminate generation if the model outputs them. > Parameters that control the generation strategy used do_sample (`bool`, *optional*, defaults to `False`): Whether or not to use sampling ; use greedy decoding otherwise.
452_2_7
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
do_sample (`bool`, *optional*, defaults to `False`): Whether or not to use sampling ; use greedy decoding otherwise. num_beams (`int`, *optional*, defaults to 1): Number of beams for beam search. 1 means no beam search. num_beam_groups (`int`, *optional*, defaults to 1): Number of groups to divide `num_beams` into in order to ensure diversity among different groups of beams. [this paper](https://arxiv.org/pdf/1610.02424.pdf) for more details. penalty_alpha (`float`, *optional*):
452_2_8
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
[this paper](https://arxiv.org/pdf/1610.02424.pdf) for more details. penalty_alpha (`float`, *optional*): The values balance the model confidence and the degeneration penalty in contrastive search decoding. dola_layers (`str` or `List[int]`, *optional*): The layers to use for DoLa decoding. If `None`, DoLa decoding is not used. If a string, it must be one of "low" or "high", which means using the lower part or higher part of the model layers, respectively.
452_2_9
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
be one of "low" or "high", which means using the lower part or higher part of the model layers, respectively. "low" means the first half of the layers up to the first 20 layers, and "high" means the last half of the layers up to the last 20 layers. If a list of integers, it must contain the indices of the layers to use for candidate premature layers in DoLa. The 0-th layer is the word embedding layer of the model. Set to `'low'` to improve long-answer reasoning tasks,
452_2_10
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
The 0-th layer is the word embedding layer of the model. Set to `'low'` to improve long-answer reasoning tasks, `'high'` to improve short-answer tasks. Check the [documentation](https://github.com/huggingface/transformers/blob/main/docs/source/en/generation_strategies.md) or [the paper](https://arxiv.org/abs/2309.03883) for more details. > Parameters that control the cache use_cache (`bool`, *optional*, defaults to `True`):
452_2_11
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
> Parameters that control the cache use_cache (`bool`, *optional*, defaults to `True`): Whether or not the model should use the past last key/values attentions (if applicable to the model) to speed up decoding. cache_implementation (`str`, *optional*, default to `None`): Name of the cache class that will be instantiated in `generate`, for faster decoding. Possible values are: - `"static"`: [`StaticCache`] - `"offloaded_static"`: [`OffloadedStaticCache`] - `"sliding_window"`: [`SlidingWindowCache`]
452_2_12
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
- `"static"`: [`StaticCache`] - `"offloaded_static"`: [`OffloadedStaticCache`] - `"sliding_window"`: [`SlidingWindowCache`] - `"hybrid"`: [`HybridCache`] - `"mamba"`: [`MambaCache`] - `"quantized"`: [`QuantizedCache`] We support other cache types, but they must be manually instantiated and passed to `generate` through the `past_key_values` argument. See our [cache documentation](https://huggingface.co/docs/transformers/en/kv_cache) for further information.
452_2_13
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
[cache documentation](https://huggingface.co/docs/transformers/en/kv_cache) for further information. cache_config (`CacheConfig` or `dict`, *optional*, default to `None`): Arguments used in the key-value cache class can be passed in `cache_config`. Can be passed as a `Dict` and it will be converted to its repsective `CacheConfig` internally. Otherwise can be passed as a `CacheConfig` class matching the indicated `cache_implementation`. return_legacy_cache (`bool`, *optional*, default to `True`):
452_2_14
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
return_legacy_cache (`bool`, *optional*, default to `True`): Whether to return the legacy or new format of the cache when `DynamicCache` is used by default. > Parameters for manipulation of the model output logits temperature (`float`, *optional*, defaults to 1.0): The value used to module the next token probabilities. This value is set in a model's `generation_config.json` file. If it isn't set, the default value is 1.0 top_k (`int`, *optional*, defaults to 50):
452_2_15
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
top_k (`int`, *optional*, defaults to 50): The number of highest probability vocabulary tokens to keep for top-k-filtering. This value is set in a model's `generation_config.json` file. If it isn't set, the default value is 50. top_p (`float`, *optional*, defaults to 1.0): If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to
452_2_16
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to `top_p` or higher are kept for generation. This value is set in a model's `generation_config.json` file. If it isn't set, the default value is 1.0 min_p (`float`, *optional*): Minimum token probability, which will be scaled by the probability of the most likely token. It must be a value between 0 and 1. Typical values are in the 0.01-0.2 range, comparably selective as setting `top_p` in
452_2_17
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
value between 0 and 1. Typical values are in the 0.01-0.2 range, comparably selective as setting `top_p` in the 0.99-0.8 range (use the opposite of normal `top_p` values). typical_p (`float`, *optional*, defaults to 1.0): Local typicality measures how similar the conditional probability of predicting a target token next is to the expected conditional probability of predicting a random token next, given the partial text already
452_2_18
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
the expected conditional probability of predicting a random token next, given the partial text already generated. If set to float < 1, the smallest set of the most locally typical tokens with probabilities that add up to `typical_p` or higher are kept for generation. See [this paper](https://arxiv.org/pdf/2202.00666.pdf) for more details. epsilon_cutoff (`float`, *optional*, defaults to 0.0): If set to float strictly between 0 and 1, only tokens with a conditional probability greater than
452_2_19
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
If set to float strictly between 0 and 1, only tokens with a conditional probability greater than `epsilon_cutoff` will be sampled. In the paper, suggested values range from 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language Model Desmoothing](https://arxiv.org/abs/2210.15191) for more details. eta_cutoff (`float`, *optional*, defaults to 0.0): Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to float strictly between
452_2_20
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to float strictly between 0 and 1, a token is only considered if it is greater than either `eta_cutoff` or `sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits)))`. The latter term is intuitively the expected next token probability, scaled by `sqrt(eta_cutoff)`. In the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. See [Truncation Sampling as Language Model
452_2_21
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
depending on the size of the model. See [Truncation Sampling as Language Model Desmoothing](https://arxiv.org/abs/2210.15191) for more details. diversity_penalty (`float`, *optional*, defaults to 0.0): This value is subtracted from a beam's score if it generates a token same as any beam from other group at a particular time. Note that `diversity_penalty` is only effective if `group beam search` is enabled. repetition_penalty (`float`, *optional*, defaults to 1.0):
452_2_22
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
repetition_penalty (`float`, *optional*, defaults to 1.0): The parameter for repetition penalty. 1.0 means no penalty. See [this paper](https://arxiv.org/pdf/1909.05858.pdf) for more details. encoder_repetition_penalty (`float`, *optional*, defaults to 1.0): The paramater for encoder_repetition_penalty. An exponential penalty on sequences that are not in the original input. 1.0 means no penalty. length_penalty (`float`, *optional*, defaults to 1.0):
452_2_23
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
original input. 1.0 means no penalty. length_penalty (`float`, *optional*, defaults to 1.0): Exponential penalty to the length that is used with beam-based generation. It is applied as an exponent to the sequence length, which in turn is used to divide the score of the sequence. Since the score is the log likelihood of the sequence (i.e. negative), `length_penalty` > 0.0 promotes longer sequences, while `length_penalty` < 0.0 encourages shorter sequences.
452_2_24
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
`length_penalty` < 0.0 encourages shorter sequences. no_repeat_ngram_size (`int`, *optional*, defaults to 0): If set to int > 0, all ngrams of that size can only occur once. bad_words_ids (`List[List[int]]`, *optional*): List of list of token ids that are not allowed to be generated. Check [`~generation.NoBadWordsLogitsProcessor`] for further documentation and examples. force_words_ids (`List[List[int]]` or `List[List[List[int]]]`, *optional*):
452_2_25
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
force_words_ids (`List[List[int]]` or `List[List[List[int]]]`, *optional*): List of token ids that must be generated. If given a `List[List[int]]`, this is treated as a simple list of words that must be included, the opposite to `bad_words_ids`. If given `List[List[List[int]]]`, this triggers a [disjunctive constraint](https://github.com/huggingface/transformers/issues/14081), where one can allow different forms of each word. renormalize_logits (`bool`, *optional*, defaults to `False`):
452_2_26
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
can allow different forms of each word. renormalize_logits (`bool`, *optional*, defaults to `False`): Whether to renormalize the logits after applying all the logits processors (including the custom ones). It's highly recommended to set this flag to `True` as the search algorithms suppose the score logits are normalized but some logit processors break the normalization. constraints (`List[Constraint]`, *optional*):
452_2_27
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
are normalized but some logit processors break the normalization. constraints (`List[Constraint]`, *optional*): Custom constraints that can be added to the generation to ensure that the output will contain the use of certain tokens as defined by `Constraint` objects, in the most sensible way possible. forced_bos_token_id (`int`, *optional*, defaults to `model.config.forced_bos_token_id`): The id of the token to force as the first generated token after the `decoder_start_token_id`. Useful for
452_2_28
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
The id of the token to force as the first generated token after the `decoder_start_token_id`. Useful for multilingual models like [mBART](../model_doc/mbart) where the first generated token needs to be the target language token. forced_eos_token_id (`int` or List[int]`, *optional*, defaults to `model.config.forced_eos_token_id`): The id of the token to force as the last generated token when `max_length` is reached. Optionally, use a list to set multiple *end-of-sequence* tokens.
452_2_29
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
list to set multiple *end-of-sequence* tokens. remove_invalid_values (`bool`, *optional*, defaults to `model.config.remove_invalid_values`): Whether to remove possible *nan* and *inf* outputs of the model to prevent the generation method to crash. Note that using `remove_invalid_values` can slow down generation. exponential_decay_length_penalty (`tuple(int, float)`, *optional*): This Tuple adds an exponentially increasing length penalty, after a certain amount of tokens have been
452_2_30
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
This Tuple adds an exponentially increasing length penalty, after a certain amount of tokens have been generated. The tuple shall consist of: `(start_index, decay_factor)` where `start_index` indicates where penalty starts and `decay_factor` represents the factor of exponential decay suppress_tokens (`List[int]`, *optional*): A list of tokens that will be suppressed at generation. The `SupressTokens` logit processor will set their log probs to `-inf` so that they are not sampled.
452_2_31
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
log probs to `-inf` so that they are not sampled. begin_suppress_tokens (`List[int]`, *optional*): A list of tokens that will be suppressed at the beginning of the generation. The `SupressBeginTokens` logit processor will set their log probs to `-inf` so that they are not sampled. forced_decoder_ids (`List[List[int]]`, *optional*): A list of pairs of integers which indicates a mapping from generation indices to token indices that will be
452_2_32
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
A list of pairs of integers which indicates a mapping from generation indices to token indices that will be forced before sampling. For example, `[[1, 123]]` means the second generated token will always be a token of index 123. sequence_bias (`Dict[Tuple[int], float]`, *optional*)): Dictionary that maps a sequence of tokens to its bias term. Positive biases increase the odds of the sequence being selected, while negative biases do the opposite. Check
452_2_33
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
sequence being selected, while negative biases do the opposite. Check [`~generation.SequenceBiasLogitsProcessor`] for further documentation and examples. token_healing (`bool`, *optional*, defaults to `False`): Heal tail tokens of prompts by replacing them with their appropriate extensions. This enhances the quality of completions for prompts affected by greedy tokenization bias. guidance_scale (`float`, *optional*):
452_2_34
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
guidance_scale (`float`, *optional*): The guidance scale for classifier free guidance (CFG). CFG is enabled by setting `guidance_scale > 1`. Higher guidance scale encourages the model to generate samples that are more closely linked to the input prompt, usually at the expense of poorer quality. low_memory (`bool`, *optional*): Switch to sequential beam search and sequential topk for contrastive search to reduce peak memory. Used with beam search and contrastive search.
452_2_35
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
Used with beam search and contrastive search. watermarking_config (`BaseWatermarkingConfig` or `dict`, *optional*): Arguments used to watermark the model outputs by adding a small bias to randomly selected set of "green" tokens. See the docs of [`SynthIDTextWatermarkingConfig`] and [`WatermarkingConfig`] for more details. If passed as `Dict`, it will be converted to a `WatermarkingConfig` internally. > Parameters that define the output variables of generate
452_2_36
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
> Parameters that define the output variables of generate num_return_sequences (`int`, *optional*, defaults to 1): The number of independently computed returned sequences for each element in the batch. output_attentions (`bool`, *optional*, defaults to `False`): Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned tensors for more details. output_hidden_states (`bool`, *optional*, defaults to `False`):
452_2_37
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
tensors for more details. output_hidden_states (`bool`, *optional*, defaults to `False`): Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for more details. output_scores (`bool`, *optional*, defaults to `False`): Whether or not to return the prediction scores. See `scores` under returned tensors for more details. output_logits (`bool`, *optional*): Whether or not to return the unprocessed prediction logit scores. See `logits` under returned tensors for
452_2_38
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
Whether or not to return the unprocessed prediction logit scores. See `logits` under returned tensors for more details. return_dict_in_generate (`bool`, *optional*, defaults to `False`): Whether or not to return a [`~utils.ModelOutput`], as opposed to returning exclusively the generated sequence. This flag must be set to `True` to return the generation cache (when `use_cache` is `True`) or optional outputs (see flags starting with `output_`) > Special tokens that can be used at generation time
452_2_39
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
or optional outputs (see flags starting with `output_`) > Special tokens that can be used at generation time pad_token_id (`int`, *optional*): The id of the *padding* token. bos_token_id (`int`, *optional*): The id of the *beginning-of-sequence* token. eos_token_id (`Union[int, List[int]]`, *optional*): The id of the *end-of-sequence* token. Optionally, use a list to set multiple *end-of-sequence* tokens. > Generation parameters exclusive to encoder-decoder models
452_2_40
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
> Generation parameters exclusive to encoder-decoder models encoder_no_repeat_ngram_size (`int`, *optional*, defaults to 0): If set to int > 0, all ngrams of that size that occur in the `encoder_input_ids` cannot occur in the `decoder_input_ids`. decoder_start_token_id (`int` or `List[int]`, *optional*): If an encoder-decoder model starts decoding with a different token than *bos*, the id of that token or a list of length
452_2_41
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#generationconfig
.md
If an encoder-decoder model starts decoding with a different token than *bos*, the id of that token or a list of length `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) > Generation parameters exclusive to assistant generation is_assistant (`bool`, *optional*, defaults to `False`): Whether the model is an assistant (draft) model. num_assistant_tokens (`int`, *optional*, defaults to 20):
452_2_42