text
stringlengths
5
58.6k
source
stringclasses
470 values
url
stringlengths
49
167
source_section
stringlengths
0
90
file_type
stringclasses
1 value
id
stringlengths
3
6
Constructs a PIX2STRUCT processor which wraps a BERT tokenizer and PIX2STRUCT image processor into a single processor. [`Pix2StructProcessor`] offers all the functionalities of [`Pix2StructImageProcessor`] and [`T5TokenizerFast`]. See the docstring of [`~Pix2StructProcessor.__call__`] and [`~Pix2StructProcessor.decod...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/pix2struct.md
https://huggingface.co/docs/transformers/en/model_doc/pix2struct/#pix2structprocessor
#pix2structprocessor
.md
422_6
Constructs a Pix2Struct image processor. Args: do_convert_rgb (`bool`, *optional*, defaults to `True`): Whether to convert the image to RGB. do_normalize (`bool`, *optional*, defaults to `True`): Whether to normalize the image. Can be overridden by the `do_normalize` parameter in the `preprocess` method. According to...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/pix2struct.md
https://huggingface.co/docs/transformers/en/model_doc/pix2struct/#pix2structimageprocessor
#pix2structimageprocessor
.md
422_7
The standalone text decoder of Pix2Struct The Pix2Struct model was proposed in [Pix2Struct: Screenshot Parsing as Pretraining for Visual Language Understanding](https://arxiv.org/abs/2210.03347) by Kenton Lee, Mandar Joshi, Iulia Turc, Hexiang Hu, Fangyu Liu, Julian Eisenschlos, Urvashi Khandelwal, Peter Shaw, Ming-W...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/pix2struct.md
https://huggingface.co/docs/transformers/en/model_doc/pix2struct/#pix2structtextmodel
#pix2structtextmodel
.md
422_8
The bare Pix2StructVision Model transformer outputting raw hidden-states without any specific head on top. This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to gene...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/pix2struct.md
https://huggingface.co/docs/transformers/en/model_doc/pix2struct/#pix2structvisionmodel
#pix2structvisionmodel
.md
422_9
A conditional generation model with a language modeling head. Can be used for sequence generation tasks. The Pix2Struct model was proposed in [Pix2Struct: Screenshot Parsing as Pretraining for Visual Language Understanding](https://arxiv.org/abs/2210.03347) by Kenton Lee, Mandar Joshi, Iulia Turc, Hexiang Hu, Fangyu ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/pix2struct.md
https://huggingface.co/docs/transformers/en/model_doc/pix2struct/#pix2structforconditionalgeneration
#pix2structforconditionalgeneration
.md
422_10
<!--Copyright 2024 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/mamba2.md
https://huggingface.co/docs/transformers/en/model_doc/mamba2/
.md
423_0
The Mamba2 model was proposed in [Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality](https://arxiv.org/abs/2405.21060) by Tri Dao and Albert Gu. It is a State Space Model similar to Mamba 1, with better performances in a simplified architecture. The abstract fro...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/mamba2.md
https://huggingface.co/docs/transformers/en/model_doc/mamba2/#overview
#overview
.md
423_1
```python from transformers import Mamba2Config, Mamba2ForCausalLM, AutoTokenizer import torch model_id = 'mistralai/Mamba-Codestral-7B-v0.1' tokenizer = AutoTokenizer.from_pretrained(model_id, revision='refs/pr/9', from_slow=True, legacy=False) model = Mamba2ForCausalLM.from_pretrained(model_id, revision='refs/pr/9') ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/mamba2.md
https://huggingface.co/docs/transformers/en/model_doc/mamba2/#a-simple-generation-example
#a-simple-generation-example
.md
423_2
This is the configuration class to store the configuration of a [`Mamba2Model`]. It is used to instantiate a MAMBA2 model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of the MAMBA2 [state-spaces/mamba2-2...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/mamba2.md
https://huggingface.co/docs/transformers/en/model_doc/mamba2/#mamba2config
#mamba2config
.md
423_3
The bare MAMBA2 Model transformer outputting raw hidden-states without any specific head on top. This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning head...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/mamba2.md
https://huggingface.co/docs/transformers/en/model_doc/mamba2/#mamba2model
#mamba2model
.md
423_4
The MAMBA2 Model transformer with a language modeling head on top (linear layer with weights not tied to the input embeddings). This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/mamba2.md
https://huggingface.co/docs/transformers/en/model_doc/mamba2/#mamba2lmheadmodel
#mamba2lmheadmodel
.md
423_5
<!--Copyright 2020 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/modeling_utils.md
https://huggingface.co/docs/transformers/en/internal/modeling_utils/
.md
424_0
This page lists all the custom layers used by the library, as well as the utility functions it provides for modeling. Most of those are only useful if you are studying the code of the models in the library.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/modeling_utils.md
https://huggingface.co/docs/transformers/en/internal/modeling_utils/#custom-layers-and-utilities
#custom-layers-and-utilities
.md
424_1
pytorch_utils.Conv1D 1D-convolutional layer as defined by Radford et al. for OpenAI GPT (and also used in GPT-2). Basically works like a linear layer but the weights are transposed. Args: nf (`int`): The number of output features. nx (`int`): The number of input features. modeling_utils.PoolerStartLogits Comp...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/modeling_utils.md
https://huggingface.co/docs/transformers/en/internal/modeling_utils/#pytorch-custom-modules
#pytorch-custom-modules
.md
424_2
pytorch_utils.apply_chunking_to_forward This function chunks the `input_tensors` into smaller input tensor parts of size `chunk_size` over the dimension `chunk_dim`. It then applies a layer `forward_fn` to each chunk independently to save memory. If the `forward_fn` is independent across the `chunk_dim` this functi...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/modeling_utils.md
https://huggingface.co/docs/transformers/en/internal/modeling_utils/#pytorch-helper-functions
#pytorch-helper-functions
.md
424_3
[[autodoc]] modeling_tf_utils.TFConv1D: No module named 'h5py' [[autodoc]] modeling_tf_utils.TFSequenceSummary: No module named 'h5py'
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/modeling_utils.md
https://huggingface.co/docs/transformers/en/internal/modeling_utils/#tensorflow-custom-layers
#tensorflow-custom-layers
.md
424_4
[[autodoc]] modeling_tf_utils.TFCausalLanguageModelingLoss: No module named 'h5py' [[autodoc]] modeling_tf_utils.TFMaskedLanguageModelingLoss: No module named 'h5py' [[autodoc]] modeling_tf_utils.TFMultipleChoiceLoss: No module named 'h5py' [[autodoc]] modeling_tf_utils.TFQuestionAnsweringLoss: No module named 'h...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/modeling_utils.md
https://huggingface.co/docs/transformers/en/internal/modeling_utils/#tensorflow-loss-functions
#tensorflow-loss-functions
.md
424_5
[[autodoc]] modeling_tf_utils.get_initializer: No module named 'h5py' [[autodoc]] modeling_tf_utils.keras_serializable: No module named 'h5py' [[autodoc]] modeling_tf_utils.shape_list: No module named 'h5py'
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/modeling_utils.md
https://huggingface.co/docs/transformers/en/internal/modeling_utils/#tensorflow-helper-functions
#tensorflow-helper-functions
.md
424_6
<!--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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/file_utils.md
https://huggingface.co/docs/transformers/en/internal/file_utils/
.md
425_0
This page lists all of Transformers general utility functions that are found in the file `utils.py`. Most of those are only useful if you are studying the general code in the library.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/file_utils.md
https://huggingface.co/docs/transformers/en/internal/file_utils/#general-utilities
#general-utilities
.md
425_1
utils.ExplicitEnum Enum with more explicit error message for missing values. utils.PaddingStrategy Possible values for the `padding` argument in [`PreTrainedTokenizerBase.__call__`]. Useful for tab-completion in an IDE. utils.TensorType Possible values for the `return_tensors` argument in [`PreTrainedTokenize...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/file_utils.md
https://huggingface.co/docs/transformers/en/internal/file_utils/#enums-and-namedtuples
#enums-and-namedtuples
.md
425_2
utils.add_start_docstrings utils.add_start_docstrings_to_model_forward utils.add_end_docstrings utils.add_code_sample_docstrings utils.replace_return_docstrings
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/file_utils.md
https://huggingface.co/docs/transformers/en/internal/file_utils/#special-decorators
#special-decorators
.md
425_3
utils.cached_property Descriptor that mimics @property but caches output in member variable. From tensorflow_datasets Built-in in functools from Python 3.8.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/file_utils.md
https://huggingface.co/docs/transformers/en/internal/file_utils/#special-properties
#special-properties
.md
425_4
utils._LazyModule Module class that surfaces all objects but only performs associated imports when the objects are requested.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/file_utils.md
https://huggingface.co/docs/transformers/en/internal/file_utils/#other-utilities
#other-utilities
.md
425_5
<!--Copyright 2023 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/audio_utils.md
https://huggingface.co/docs/transformers/en/internal/audio_utils/
.md
426_0
This page lists all the utility functions that can be used by the audio [`FeatureExtractor`] in order to compute special features from a raw audio using common algorithms such as *Short Time Fourier Transform* or *log mel spectrogram*. Most of those are only useful if you are studying the code of the audio processors...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/audio_utils.md
https://huggingface.co/docs/transformers/en/internal/audio_utils/#utilities-for-featureextractors
#utilities-for-featureextractors
.md
426_1
audio_utils.hertz_to_mel Convert frequency from hertz to mels. Args: freq (`float` or `np.ndarray`): The frequency, or multiple frequencies, in hertz (Hz). mel_scale (`str`, *optional*, defaults to `"htk"`): The mel frequency scale to use, `"htk"`, `"kaldi"` or `"slaney"`. Returns: `float` or `np.ndarray`: The fr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/audio_utils.md
https://huggingface.co/docs/transformers/en/internal/audio_utils/#audio-transformations
#audio-transformations
.md
426_2
<!--Copyright 2020 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/
.md
427_0
This page lists all the utility functions used by [`~generation.GenerationMixin.generate`].
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#utilities-for-generation
#utilities-for-generation
.md
427_1
The output of [`~generation.GenerationMixin.generate`] is an instance of a subclass of [`~utils.ModelOutput`]. This output is a data structure containing all the information returned by [`~generation.GenerationMixin.generate`], but that can also be used as tuple or dictionary. Here's an example: ```python from tran...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#generate-outputs
#generate-outputs
.md
427_2
generation.GenerateDecoderOnlyOutput Outputs of decoder-only generation models, when using non-beam methods. Args: sequences (`torch.LongTensor` of shape `(batch_size, sequence_length)`): The generated sequences. The second dimension (sequence_length) is either equal to `max_length` or shorter if all batches finish...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#pytorch
#pytorch
.md
427_3
[[autodoc]] generation.TFGreedySearchEncoderDecoderOutput: module transformers.generation has no attribute TFGreedySearchEncoderDecoderOutput [[autodoc]] generation.TFGreedySearchDecoderOnlyOutput: module transformers.generation has no attribute TFGreedySearchDecoderOnlyOutput [[autodoc]] generation.TFSampleEncoder...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#tensorflow
#tensorflow
.md
427_4
[[autodoc]] generation.FlaxSampleOutput: module transformers.generation has no attribute FlaxSampleOutput [[autodoc]] generation.FlaxGreedySearchOutput: module transformers.generation has no attribute FlaxGreedySearchOutput [[autodoc]] generation.FlaxBeamSearchOutput: module transformers.generation has no attribute...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#flax
#flax
.md
427_5
A [`LogitsProcessor`] can be used to modify the prediction scores of a language model head for generation.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#logitsprocessor
#logitsprocessor
.md
427_6
[`LogitsProcessor`] enforcing alternated generation between the two codebooks of Bark. <Tip warning={true}> This logits processor is exclusively compatible with [Bark](https://huggingface.co/docs/transformers/en/model_doc/bark)'s fine submodel. See the model documentation for examples. </Tip> Args: input_start_...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#pytorch
#pytorch
.md
427_7
TFForcedBOSTokenLogitsProcessor - __call__ TFForcedEOSTokenLogitsProcessor - __call__ TFForceTokensLogitsProcessor - __call__ TFLogitsProcessor - __call__ TFLogitsProcessorList - __call__ TFLogitsWarper - __call__ TFMinLengthLogitsProcessor - __call__ TFNoBadWordsLogitsProcessor - __call__ TFNoRepeatNGr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#tensorflow
#tensorflow
.md
427_8
FlaxForcedBOSTokenLogitsProcessor - __call__ FlaxForcedEOSTokenLogitsProcessor - __call__ FlaxForceTokensLogitsProcessor - __call__ FlaxLogitsProcessor - __call__ FlaxLogitsProcessorList - __call__ FlaxLogitsWarper - __call__ FlaxMinLengthLogitsProcessor - __call__ FlaxSuppressTokensAtBeginLogitsProcessor...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#flax
#flax
.md
427_9
A [`StoppingCriteria`] can be used to change when to stop generation (other than EOS token). Please note that this is exclusively available to our PyTorch implementations. Abstract base class for all stopping criteria that can be applied during generation. If your stopping criteria depends on the `scores` input, ma...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#stoppingcriteria
#stoppingcriteria
.md
427_10
A [`Constraint`] can be used to force the generation to include specific tokens or sequences in the output. Please note that this is exclusively available to our PyTorch implementations. Abstract base class for all constraints that can be applied during generation. It must define how the constraint can be satisfied. ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#constraints
#constraints
.md
427_11
Abstract base class for all beam scorers that are used for [`~PreTrainedModel.beam_search`] and [`~PreTrainedModel.beam_sample`]. - process - finalize [`BeamScorer`] implementing standard beam search decoding. Adapted in part from [Facebook's XLM beam search code](https://github.com/facebookresearch/XLM/blob/9e6f...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#beamsearch
#beamsearch
.md
427_12
Simple text streamer that prints the token(s) to stdout as soon as entire words are formed. <Tip warning={true}> The API for the streamer classes is still under development and may change in the future. </Tip> Parameters: tokenizer (`AutoTokenizer`): The tokenized used to decode the tokens. skip_prompt (`bool`,...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#streamers
#streamers
.md
427_13
Base, abstract class for all caches. The actual data structure is specific to each subclass. - update Base, abstract class for all caches. The actual data structure is specific to each subclass. Config - update Configuration class for quantized cache settings. Attributes: backend (`str`, *optional*, defaults to...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#caches
#caches
.md
427_14
Class that holds arguments for watermark generation and should be passed into `GenerationConfig` during `generate`. See [this paper](https://arxiv.org/abs/2306.04634) for more details on the arguments. Accepts the following keys: - greenlist_ratio (`float`): Used for watermarking. The ratio of "green" tokens used to ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#watermark-utils
#watermark-utils
.md
427_15
Class that holds arguments relative to `torch.compile` behavior, when using automatic compilation in `generate`. See [`torch.compile`](https://pytorch.org/docs/stable/generated/torch.compile.html) for more details on the arguments. Args: fullgraph (`bool`, *optional*, defaults to `True`): If `True`, requires that the...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/generation_utils.md
https://huggingface.co/docs/transformers/en/internal/generation_utils/#compile-utils
#compile-utils
.md
427_16
<!--Copyright 2023 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/time_series_utils.md
https://huggingface.co/docs/transformers/en/internal/time_series_utils/
.md
428_0
This page lists all the utility functions and classes that can be used for Time Series based models. Most of those are only useful if you are studying the code of the time series models or you wish to add to the collection of distributional output classes.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/time_series_utils.md
https://huggingface.co/docs/transformers/en/internal/time_series_utils/#time-series-utilities
#time-series-utilities
.md
428_1
time_series_utils.NormalOutput Normal distribution output class. time_series_utils.StudentTOutput Student-T distribution output class. time_series_utils.NegativeBinomialOutput Negative Binomial distribution output class.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/time_series_utils.md
https://huggingface.co/docs/transformers/en/internal/time_series_utils/#distributional-output
#distributional-output
.md
428_2
<!--Copyright 2020 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/tokenization_utils.md
https://huggingface.co/docs/transformers/en/internal/tokenization_utils/
.md
429_0
This page lists all the utility functions used by the tokenizers, mainly the class [`~tokenization_utils_base.PreTrainedTokenizerBase`] that implements the common methods between [`PreTrainedTokenizer`] and [`PreTrainedTokenizerFast`] and the mixin [`~tokenization_utils_base.SpecialTokensMixin`]. Most of those are on...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/tokenization_utils.md
https://huggingface.co/docs/transformers/en/internal/tokenization_utils/#utilities-for-tokenizers
#utilities-for-tokenizers
.md
429_1
tokenization_utils_base.PreTrainedTokenizerBase Base class for [`PreTrainedTokenizer`] and [`PreTrainedTokenizerFast`]. Handles shared (mostly boiler plate) methods for those two classes. Class attributes (overridden by derived classes) - **vocab_files_names** (`Dict[str, str]`) -- A dictionary with, as keys, t...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/tokenization_utils.md
https://huggingface.co/docs/transformers/en/internal/tokenization_utils/#pretrainedtokenizerbase
#pretrainedtokenizerbase
.md
429_2
tokenization_utils_base.SpecialTokensMixin A mixin derived by [`PreTrainedTokenizer`] and [`PreTrainedTokenizerFast`] to handle specific behaviors related to special tokens. In particular, this class hold the attributes which can be used to directly access these special tokens in a model-independent manner and allow ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/tokenization_utils.md
https://huggingface.co/docs/transformers/en/internal/tokenization_utils/#specialtokensmixin
#specialtokensmixin
.md
429_3
tokenization_utils_base.TruncationStrategy Possible values for the `truncation` argument in [`PreTrainedTokenizerBase.__call__`]. Useful for tab-completion in an IDE. tokenization_utils_base.CharSpan Character span in the original string. Args: start (`int`): Index of the first character in the original string....
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/tokenization_utils.md
https://huggingface.co/docs/transformers/en/internal/tokenization_utils/#enums-and-namedtuples
#enums-and-namedtuples
.md
429_4
<!--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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/image_processing_utils.md
https://huggingface.co/docs/transformers/en/internal/image_processing_utils/
.md
430_0
This page lists all the utility functions used by the image processors, mainly the functional transformations used to process the images. Most of those are only useful if you are studying the code of the image processors in the library.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/image_processing_utils.md
https://huggingface.co/docs/transformers/en/internal/image_processing_utils/#utilities-for-image-processors
#utilities-for-image-processors
.md
430_1
image_transforms.center_crop Crops the `image` to the specified `size` using a center crop. Note that if the image is too small to be cropped to the size given, it will be padded (so the returned result will always be of size `size`). Args: image (`np.ndarray`): The image to crop. size (`Tuple[int, int]`): The targ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/image_processing_utils.md
https://huggingface.co/docs/transformers/en/internal/image_processing_utils/#image-transformations
#image-transformations
.md
430_2
image_processing_utils.ImageProcessingMixin This is an image processor mixin used to provide saving/loading functionality for sequential and image feature extractors.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/image_processing_utils.md
https://huggingface.co/docs/transformers/en/internal/image_processing_utils/#imageprocessingmixin
#imageprocessingmixin
.md
430_3
<!--Copyright 2020 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/trainer_utils.md
https://huggingface.co/docs/transformers/en/internal/trainer_utils/
.md
431_0
This page lists all the utility functions used by [`Trainer`]. Most of those are only useful if you are studying the code of the Trainer in the library.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/trainer_utils.md
https://huggingface.co/docs/transformers/en/internal/trainer_utils/#utilities-for-trainer
#utilities-for-trainer
.md
431_1
Evaluation output (always contains labels), to be used to compute metrics. Parameters: predictions (`np.ndarray`): Predictions of the model. label_ids (`np.ndarray`): Targets to be matched. inputs (`np.ndarray`, *optional*): Input data passed to the model. losses (`np.ndarray`, *optional*): Loss values computed durin...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/trainer_utils.md
https://huggingface.co/docs/transformers/en/internal/trainer_utils/#utilities
#utilities
.md
431_2
trainer_callback.CallbackHandler Internal class that just calls the list of callbacks in order.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/trainer_utils.md
https://huggingface.co/docs/transformers/en/internal/trainer_utils/#callbacks-internals
#callbacks-internals
.md
431_3
trainer_pt_utils.DistributedTensorGatherer A class responsible for properly gathering tensors (or nested list/tuple of tensors) on the CPU by chunks. If our dataset has 16 samples with a batch size of 2 on 3 processes and we gather then transfer on CPU at every step, our sampler will generate the following indices:...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/trainer_utils.md
https://huggingface.co/docs/transformers/en/internal/trainer_utils/#distributed-evaluation
#distributed-evaluation
.md
431_4
This subclass of `argparse.ArgumentParser` uses type hints on dataclasses to generate arguments. The class is designed to play well with the native argparse. In particular, you can add more (non-dataclass backed) arguments to the parser after initialization and you'll get the output back after parsing as an additiona...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/trainer_utils.md
https://huggingface.co/docs/transformers/en/internal/trainer_utils/#trainer-argument-parser
#trainer-argument-parser
.md
431_5
debug_utils.DebugUnderflowOverflow This debug class helps detect and understand where the model starts getting very large or very small, and more importantly `nan` or `inf` weight and activation elements. There are 2 working modes: 1. Underflow/overflow detection (default) 2. Specific batch absolute min/max traci...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/trainer_utils.md
https://huggingface.co/docs/transformers/en/internal/trainer_utils/#debug-utilities
#debug-utilities
.md
431_6
<!--Copyright 2020 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/pipelines_utils.md
https://huggingface.co/docs/transformers/en/internal/pipelines_utils/
.md
432_0
This page lists all the utility functions the library provides for pipelines. Most of those are only useful if you are studying the code of the models in the library.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/pipelines_utils.md
https://huggingface.co/docs/transformers/en/internal/pipelines_utils/#utilities-for-pipelines
#utilities-for-pipelines
.md
432_1
pipelines.ArgumentHandler Base interface for handling arguments for each [`~pipelines.Pipeline`]. pipelines.ZeroShotClassificationArgumentHandler Handles arguments for zero-shot for text classification by turning each possible label into an NLI premise/hypothesis pair. pipelines.QuestionAnsweringArgumentHandler...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/pipelines_utils.md
https://huggingface.co/docs/transformers/en/internal/pipelines_utils/#argument-handling
#argument-handling
.md
432_2
pipelines.PipelineDataFormat Base class for all the pipeline supported data format both for reading and writing. Supported data formats currently includes: - JSON - CSV - stdin/stdout (pipe) `PipelineDataFormat` also includes some utilities to work with multi-columns like mapping from datasets columns to pipeline...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/pipelines_utils.md
https://huggingface.co/docs/transformers/en/internal/pipelines_utils/#data-format
#data-format
.md
432_3
pipelines.PipelineException Raised by a [`Pipeline`] when handling __call__. Args: task (`str`): The task of the pipeline. model (`str`): The model used by the pipeline. reason (`str`): The error message to display.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/internal/pipelines_utils.md
https://huggingface.co/docs/transformers/en/internal/pipelines_utils/#utilities
#utilities
.md
432_4
<!--Copyright 2024 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/awq.md
https://huggingface.co/docs/transformers/en/quantization/awq/
.md
433_0
<Tip> Try AWQ quantization with this [notebook](https://colab.research.google.com/drive/1HzZH89yAXJaZgwJDhQj9LqSBux932BvY)! </Tip> [Activation-aware Weight Quantization (AWQ)](https://hf.co/papers/2306.00978) doesn't quantize all the weights in a model, and instead, it preserves a small percentage of weights that...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/awq.md
https://huggingface.co/docs/transformers/en/quantization/awq/#awq
#awq
.md
433_1
Fused modules offers improved accuracy and performance and it is supported out-of-the-box for AWQ modules for [Llama](https://huggingface.co/meta-llama) and [Mistral](https://huggingface.co/mistralai/Mistral-7B-v0.1) architectures, but you can also fuse AWQ modules for unsupported architectures. <Tip warning={true}> ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/awq.md
https://huggingface.co/docs/transformers/en/quantization/awq/#fused-modules
#fused-modules
.md
433_2
Recent versions of `autoawq` supports ExLlama-v2 kernels for faster prefill and decoding. To get started, first install the latest version of `autoawq` by running: ```bash pip install git+https://github.com/casper-hansen/AutoAWQ.git ``` Get started by passing an `AwqConfig()` with `version="exllama"`. ```python i...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/awq.md
https://huggingface.co/docs/transformers/en/quantization/awq/#exllama-v2-support
#exllama-v2-support
.md
433_3
Recent versions of `autoawq` supports CPU with ipex op optimizations. To get started, first install the latest version of `autoawq` by running: ```bash pip install intel-extension-for-pytorch pip install git+https://github.com/casper-hansen/AutoAWQ.git ``` Get started by passing an `AwqConfig()` with `version="ipex...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/awq.md
https://huggingface.co/docs/transformers/en/quantization/awq/#cpu-support
#cpu-support
.md
433_4
<!--Copyright 2024 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/eetq.md
https://huggingface.co/docs/transformers/en/quantization/eetq/
.md
434_0
The [EETQ](https://github.com/NetEase-FuXi/EETQ) library supports int8 per-channel weight-only quantization for NVIDIA GPUS. The high-performance GEMM and GEMV kernels are from FasterTransformer and TensorRT-LLM. It requires no calibration dataset and does not need to pre-quantize your model. Moreover, the accuracy deg...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/eetq.md
https://huggingface.co/docs/transformers/en/quantization/eetq/#eetq
#eetq
.md
434_1
<!--Copyright 2024 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitsandbytes.md
https://huggingface.co/docs/transformers/en/quantization/bitsandbytes/
.md
435_0
[bitsandbytes](https://github.com/TimDettmers/bitsandbytes) is the easiest option for quantizing a model to 8 and 4-bit. 8-bit quantization multiplies outliers in fp16 with non-outliers in int8, converts the non-outlier values back to fp16, and then adds them together to return the weights in fp16. This reduces the deg...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitsandbytes.md
https://huggingface.co/docs/transformers/en/quantization/bitsandbytes/#bitsandbytes
#bitsandbytes
.md
435_1
<Tip> Learn more about the details of 8-bit quantization in this [blog post](https://huggingface.co/blog/hf-bitsandbytes-integration)! </Tip> This section explores some of the specific features of 8-bit models, such as offloading, outlier thresholds, skipping module conversion, and finetuning.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitsandbytes.md
https://huggingface.co/docs/transformers/en/quantization/bitsandbytes/#8-bit-llmint8-algorithm
#8-bit-llmint8-algorithm
.md
435_2
8-bit models can offload weights between the CPU and GPU to support fitting very large models into memory. The weights dispatched to the CPU are actually stored in **float32**, and aren't converted to 8-bit. For example, to enable offloading for the [bigscience/bloom-1b7](https://huggingface.co/bigscience/bloom-1b7) mo...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitsandbytes.md
https://huggingface.co/docs/transformers/en/quantization/bitsandbytes/#offloading
#offloading
.md
435_3
An "outlier" is a hidden state value greater than a certain threshold, and these values are computed in fp16. While the values are usually normally distributed ([-3.5, 3.5]), this distribution can be very different for large models ([-60, 6] or [6, 60]). 8-bit quantization works well for values ~5, but beyond that, the...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitsandbytes.md
https://huggingface.co/docs/transformers/en/quantization/bitsandbytes/#outlier-threshold
#outlier-threshold
.md
435_4
For some models, like [Jukebox](model_doc/jukebox), you don't need to quantize every module to 8-bit which can actually cause instability. With Jukebox, there are several `lm_head` modules that should be skipped using the `llm_int8_skip_modules` parameter in [`BitsAndBytesConfig`]: ```py from transformers import Auto...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitsandbytes.md
https://huggingface.co/docs/transformers/en/quantization/bitsandbytes/#skip-module-conversion
#skip-module-conversion
.md
435_5
With the [PEFT](https://github.com/huggingface/peft) library, you can finetune large models like [flan-t5-large](https://huggingface.co/google/flan-t5-large) and [facebook/opt-6.7b](https://huggingface.co/facebook/opt-6.7b) with 8-bit quantization. You don't need to pass the `device_map` parameter for training because ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitsandbytes.md
https://huggingface.co/docs/transformers/en/quantization/bitsandbytes/#finetuning
#finetuning
.md
435_6
<Tip> Try 4-bit quantization in this [notebook](https://colab.research.google.com/drive/1ge2F1QSK8Q7h0hn3YKuBCOAS0bK8E0wf) and learn more about it's details in this [blog post](https://huggingface.co/blog/4bit-transformers-bitsandbytes). </Tip> This section explores some of the specific features of 4-bit models, ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitsandbytes.md
https://huggingface.co/docs/transformers/en/quantization/bitsandbytes/#4-bit-qlora-algorithm
#4-bit-qlora-algorithm
.md
435_7
To speedup computation, you can change the data type from float32 (the default value) to bf16 using the `bnb_4bit_compute_dtype` parameter in [`BitsAndBytesConfig`]: ```py import torch from transformers import BitsAndBytesConfig quantization_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitsandbytes.md
https://huggingface.co/docs/transformers/en/quantization/bitsandbytes/#compute-data-type
#compute-data-type
.md
435_8
NF4 is a 4-bit data type from the [QLoRA](https://hf.co/papers/2305.14314) paper, adapted for weights initialized from a normal distribution. You should use NF4 for training 4-bit base models. This can be configured with the `bnb_4bit_quant_type` parameter in the [`BitsAndBytesConfig`]: ```py from transformers import...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitsandbytes.md
https://huggingface.co/docs/transformers/en/quantization/bitsandbytes/#normal-float-4-nf4
#normal-float-4-nf4
.md
435_9
Nested quantization is a technique that can save additional memory at no additional performance cost. This feature performs a second quantization of the already quantized weights to save an additional 0.4 bits/parameter. For example, with nested quantization, you can finetune a [Llama-13b](https://huggingface.co/meta-l...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitsandbytes.md
https://huggingface.co/docs/transformers/en/quantization/bitsandbytes/#nested-quantization
#nested-quantization
.md
435_10
Once quantized, you can dequantize the model to the original precision but this might result in a small quality loss of the model. Make sure you have enough GPU RAM to fit the dequantized model. ```python from transformers import AutoModelForCausalLM, BitsAndBytesConfig, AutoTokenizer model_id = "facebook/opt-125m" ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitsandbytes.md
https://huggingface.co/docs/transformers/en/quantization/bitsandbytes/#dequantizing-bitsandbytes-models
#dequantizing-bitsandbytes-models
.md
435_11
<!--Copyright 2024 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...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/torchao.md
https://huggingface.co/docs/transformers/en/quantization/torchao/
.md
436_0
[TorchAO](https://github.com/pytorch/ao) is an architecture optimization library for PyTorch, it provides high performance dtypes, optimization techniques and kernels for inference and training, featuring composability with native PyTorch features like `torch.compile`, FSDP etc.. Some benchmark numbers can be found [he...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/torchao.md
https://huggingface.co/docs/transformers/en/quantization/torchao/#torchao
#torchao
.md
436_1
torchao quantization is implemented with [tensor subclasses](https://pytorch.org/docs/stable/notes/extending.html#subclassing-torch-tensor), it only work with huggingface non-safetensor serialization and deserialization. It relies on `torch.load(..., weights_only=True)` to avoid arbitrary user code execution during loa...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/torchao.md
https://huggingface.co/docs/transformers/en/quantization/torchao/#serialization-and-deserialization
#serialization-and-deserialization
.md
436_2
<!--Copyright 2024 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/gptq.md
https://huggingface.co/docs/transformers/en/quantization/gptq/
.md
437_0
<Tip> Try GPTQ quantization with PEFT in this [notebook](https://colab.research.google.com/drive/1_TIrmuKOFhuRRiTWN94iLKUFu6ZX4ceb?usp=sharing) and learn more about it's details in this [blog post](https://huggingface.co/blog/gptq-integration)! </Tip> Both [GPTQModel](https://github.com/ModelCloud/GPTQModel) and ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/gptq.md
https://huggingface.co/docs/transformers/en/quantization/gptq/#gptq
#gptq
.md
437_1
[Marlin](https://github.com/IST-DASLab/marlin) is a 4-bit only CUDA GPTQ kernel, highly optimized for the NVIDIA A100 GPU (Ampere) architecture. Loading, dequantization, and execution of post-dequantized weights are highly parallelized, offering a substantial inference improvement versus the original CUDA GPTQ kernel. ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/gptq.md
https://huggingface.co/docs/transformers/en/quantization/gptq/#marlin
#marlin
.md
437_2
[ExLlama](https://github.com/turboderp/exllama) is a CUDA implementation of the [Llama](model_doc/llama) model that is designed for faster inference with 4-bit GPTQ weights (check out these [benchmarks](https://github.com/huggingface/optimum/tree/main/tests/benchmark#gptq-benchmark)). The ExLlama kernel is activated by...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/gptq.md
https://huggingface.co/docs/transformers/en/quantization/gptq/#exllama
#exllama
.md
437_3
<!--Copyright 2023 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/overview.md
https://huggingface.co/docs/transformers/en/quantization/overview/
.md
438_0
Quantization techniques focus on representing data with less information while also trying to not lose too much accuracy. This often means converting a data type to represent the same information with fewer bits. For example, if your model weights are stored as 32-bit floating points and they're quantized to 16-bit flo...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/overview.md
https://huggingface.co/docs/transformers/en/quantization/overview/#quantization
#quantization
.md
438_1
The community has developed many quantization methods for various use cases. With Transformers, you can run any of these integrated methods depending on your use case because each method has their own pros and cons. For example, some quantization methods require calibrating the model with a dataset for more accurate ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/overview.md
https://huggingface.co/docs/transformers/en/quantization/overview/#when-to-use-what
#when-to-use-what
.md
438_2
<!--Copyright 2024 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/fbgemm_fp8.md
https://huggingface.co/docs/transformers/en/quantization/fbgemm_fp8/
.md
439_0
With FBGEMM FP8 quantization method, you can quantize your model in FP8 (W8A8): - the weights will be quantized in 8bit (FP8) per channel - the activation will be quantized in 8bit (FP8) per token It relies on the [FBGEMM](https://github.com/pytorch/FBGEMM) library which provides efficient low-precision general matri...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/fbgemm_fp8.md
https://huggingface.co/docs/transformers/en/quantization/fbgemm_fp8/#fbgemm-fp8
#fbgemm-fp8
.md
439_1
<!--Copyright 2024 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 agr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/optimum.md
https://huggingface.co/docs/transformers/en/quantization/optimum/
.md
440_0