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
The [Optimum](https://huggingface.co/docs/optimum/index) library supports quantization for Intel, Furiosa, ONNX Runtime, GPTQ, and lower-level PyTorch quantization functions. Consider using Optimum for quantization if you're using specific and optimized hardware like Intel CPUs, Furiosa NPUs or a model accelerator like...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/optimum.md
https://huggingface.co/docs/transformers/en/quantization/optimum/#optimum
#optimum
.md
440_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/quanto.md
https://huggingface.co/docs/transformers/en/quantization/quanto/
.md
441_0
<Tip> Try optimum-quanto + transformers with this [notebook](https://colab.research.google.com/drive/16CXfVmtdQvciSh9BopZUDYcmXCDpvgrT?usp=sharing)! </Tip> [🤗 optimum-quanto](https://github.com/huggingface/optimum-quanto) library is a versatile pytorch quantization toolkit. The quantization method used is the li...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/quanto.md
https://huggingface.co/docs/transformers/en/quantization/quanto/#optimum-quanto
#optimum-quanto
.md
441_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/contribute.md
https://huggingface.co/docs/transformers/en/quantization/contribute/
.md
442_0
Transformers supports and integrates many quantization methods such as QLoRA, GPTQ, LLM.int8, and AWQ. However, there are other quantization approaches that are not yet integrated. To make adding and using these quantization methods with Transformers models easier, you should use the [`HfQuantizer`] class. The [`HfQuan...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/contribute.md
https://huggingface.co/docs/transformers/en/quantization/contribute/#contribute-new-quantization-method
#contribute-new-quantization-method
.md
442_1
Before integrating a new quantization method into Transformers, ensure the method you are trying to add meets the following prerequisites. Only quantization methods that can be run with PyTorch modules are currently supported. - The quantization method is available through a Python package that is pip-installable by ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/contribute.md
https://huggingface.co/docs/transformers/en/quantization/contribute/#requirements
#requirements
.md
442_2
1. Create a new quantization config class inside [src/transformers/utils/quantization_config.py](https://github.com/huggingface/transformers/blob/abbffc4525566a48a9733639797c812301218b83/src/transformers/utils/quantization_config.py) and make sure to expose the new quantization config inside Transformers main `init` by...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/contribute.md
https://huggingface.co/docs/transformers/en/quantization/contribute/#build-a-new-hfquantizer-class
#build-a-new-hfquantizer-class
.md
442_3
<!--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/hqq.md
https://huggingface.co/docs/transformers/en/quantization/hqq/
.md
443_0
Half-Quadratic Quantization (HQQ) implements on-the-fly quantization via fast robust optimization. It doesn't require calibration data and can be used to quantize any model. Please refer to the <a href="https://github.com/mobiusml/hqq/">official package</a> for more details. For installation, we recommend you use the...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/hqq.md
https://huggingface.co/docs/transformers/en/quantization/hqq/#hqq
#hqq
.md
443_1
HQQ supports various backends, including pure PyTorch and custom dequantization CUDA kernels. These backends are suitable for older gpus and peft/QLoRA training. For faster inference, HQQ supports 4-bit fused kernels (TorchAO and Marlin), reaching up to 200 tokens/sec on a single 4090. For more details on how to use th...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/hqq.md
https://huggingface.co/docs/transformers/en/quantization/hqq/#optimized-runtime
#optimized-runtime
.md
443_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/compressed_tensors.md
https://huggingface.co/docs/transformers/en/quantization/compressed_tensors/
.md
444_0
The [`compressed-tensors`](https://github.com/neuralmagic/compressed-tensors) library provides a versatile and efficient way to store and manage compressed model checkpoints. This library supports various quantization and sparsity schemes, making it a unified format for handling different model optimizations like GPTQ,...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/compressed_tensors.md
https://huggingface.co/docs/transformers/en/quantization/compressed_tensors/#compressed-tensors
#compressed-tensors
.md
444_1
- Weight and activation precisions: FP8, INT4, INT8 (for Q/DQ arbitrary precision is allowed for INT) - Quantization scales and zero-points strategies: [tensor, channel, group, block, token](https://github.com/neuralmagic/compressed-tensors/blob/83b2e7a969d70606421a76b9a3d112646077c8de/src/compressed_tensors/quantizati...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/compressed_tensors.md
https://huggingface.co/docs/transformers/en/quantization/compressed_tensors/#features
#features
.md
444_2
It is recommended to install stable releases of compressed-tensors from [PyPI](https://pypi.org/project/compressed-tensors): ```bash pip install compressed-tensors ``` Developers who want to experiment with the latest features can also install the package from source: ```bash git clone https://github.com/neuralmagic/...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/compressed_tensors.md
https://huggingface.co/docs/transformers/en/quantization/compressed_tensors/#installation
#installation
.md
444_3
Quantized models can be easily loaded for inference as shown below. Only models that have already been quantized can be loaded at the moment. To quantize a model into the compressed-tensors format see [llm-compressor](https://github.com/vllm-project/llm-compressor). ```python from transformers import AutoModelForCaus...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/compressed_tensors.md
https://huggingface.co/docs/transformers/en/quantization/compressed_tensors/#quickstart-model-load
#quickstart-model-load
.md
444_4
```python from transformers import AutoModelForCausalLM, AutoTokenizer prompt = [ "Hello, my name is", "The capital of France is", "The future of AI is" ] model_name = "nm-testing/Meta-Llama-3-8B-Instruct-fp8-hf_compat" quantized_model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto") tokenizer =...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/compressed_tensors.md
https://huggingface.co/docs/transformers/en/quantization/compressed_tensors/#sample-use-cases---load-and-run-an-fp8-model
#sample-use-cases---load-and-run-an-fp8-model
.md
444_5
In this example we will examine how the compressed-tensors model nm-testing/Meta-Llama-3.1-8B-Instruct-FP8-hf is defined through its configuration entry and see how this translates to the loaded model representation. First, let us look at the [`quantization_config` of the model](https://huggingface.co/nm-testing/Meta...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/compressed_tensors.md
https://huggingface.co/docs/transformers/en/quantization/compressed_tensors/#deep-dive-into-a-compressed-tensors-model-checkpoint
#deep-dive-into-a-compressed-tensors-model-checkpoint
.md
444_6
<!--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/bitnet.md
https://huggingface.co/docs/transformers/en/quantization/bitnet/
.md
445_0
[BitNet](https://arxiv.org/abs/2402.17764) replaces traditional Linear layers in Multi-Head Attention and Feed-Forward Networks with specialized layers called BitLinear with ternary (or binary in the older version) precision. The BitLinear layers introduced here quantize the weights using ternary precision (with values...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitnet.md
https://huggingface.co/docs/transformers/en/quantization/bitnet/#bitnet
#bitnet
.md
445_1
BitNet models can't be quantized on the fly—they need to be pre-trained or fine-tuned with the quantization applied (it's a Quantization aware training technique). Once trained, these models are already quantized and available as packed versions on the hub. A quantized model can be load : ```py from transformers im...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitnet.md
https://huggingface.co/docs/transformers/en/quantization/bitnet/#load-a-bitnet-model-from-the-hub
#load-a-bitnet-model-from-the-hub
.md
445_2
If you're looking to pre-train or fine-tune your own 1.58-bit model using Nanotron, check out this [PR](https://github.com/huggingface/nanotron/pull/180), all you need to get started is there ! For fine-tuning, you'll need to convert the model from Hugging Face format to Nanotron format (which has some differences). ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitnet.md
https://huggingface.co/docs/transformers/en/quantization/bitnet/#pre-training--fine-tuning-a-bitnet-model
#pre-training--fine-tuning-a-bitnet-model
.md
445_3
In our initial version, we chose to use `@torch.compile` to unpack the weights and perform the forward pass. It’s very straightforward to implement and delivers significant speed improvements. We plan to integrate additional optimized kernels in future versions.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/bitnet.md
https://huggingface.co/docs/transformers/en/quantization/bitnet/#kernels
#kernels
.md
445_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/vptq.md
https://huggingface.co/docs/transformers/en/quantization/vptq/
.md
446_0
> [!TIP] > Try VPTQ on [Hugging Face](https://huggingface.co/spaces/microsoft/VPTQ)! > Try VPTQ on [Google Colab](https://colab.research.google.com/github/microsoft/VPTQ/blob/main/notebooks/vptq_example.ipynb)! > Know more about VPTQ on [ArXiv](https://arxiv.org/pdf/2409.17066)! Vector Post-Training Quantization ([VP...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/vptq.md
https://huggingface.co/docs/transformers/en/quantization/vptq/#vptq
#vptq
.md
446_1
**Run Llama 3.1 70b on RTX4090 (24G @ ~2bits) in real time** ![Llama3 1-70b-prompt](https://github.com/user-attachments/assets/d8729aca-4e1d-4fe1-ac71-c14da4bdd97f) ```python from transformers import AutoTokenizer, AutoModelForCausalLM quantized_model = AutoModelForCausalLM.from_pretrained( "VPTQ-community/Meta-Llam...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/vptq.md
https://huggingface.co/docs/transformers/en/quantization/vptq/#inference-example
#inference-example
.md
446_2
VPTQ algorithm early-released at [VPTQ ](https://github.com/microsoft/VPTQ/tree/algorithm), and checkout the [tutorial](https://github.com/microsoft/VPTQ/blob/algorithm/algorithm.md).
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/vptq.md
https://huggingface.co/docs/transformers/en/quantization/vptq/#quantize-your-own-model
#quantize-your-own-model
.md
446_3
VPTQ achieves better accuracy and higher throughput with lower quantization overhead across models of different sizes. The following experimental results are for reference only; VPTQ can achieve better outcomes under reasonable parameters, especially in terms of model accuracy and inference speed. | Model | bit...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/vptq.md
https://huggingface.co/docs/transformers/en/quantization/vptq/#early-results-from-tech-report
#early-results-from-tech-report
.md
446_4
⚠️ The repository only provides a method of model quantization algorithm. ⚠️ The open-source community VPTQ-community provides models based on the technical report and quantization algorithm. **Quick Estimation of Model Bitwidth (Excluding Codebook Overhead)**: - **Model Naming Convention**: The model's name incl...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/vptq.md
https://huggingface.co/docs/transformers/en/quantization/vptq/#more-models-in-vptq-communityhttpshuggingfacecovptq-community
#more-models-in-vptq-communityhttpshuggingfacecovptq-community
.md
446_5
<!--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/higgs.md
https://huggingface.co/docs/transformers/en/quantization/higgs/
.md
447_0
HIGGS is a 0-shot quantization algorithm that combines Hadamard preprocessing with MSE-Optimal quantization grids to achieve lower quantization error and SOTA performance. You can find more information in the paper [arxiv.org/abs/2411.17525](https://arxiv.org/abs/2411.17525). Runtime support for HIGGS is implemented ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/higgs.md
https://huggingface.co/docs/transformers/en/quantization/higgs/#higgs
#higgs
.md
447_1
```python from transformers import AutoModelForCausalLM, AutoTokenizer, HiggsConfig model = AutoModelForCausalLM.from_pretrained( "google/gemma-2-9b-it", quantization_config=HiggsConfig(bits=4), device_map="auto", ) tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b-it") tokenizer.decode(model.generate( **...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/higgs.md
https://huggingface.co/docs/transformers/en/quantization/higgs/#quantization-example
#quantization-example
.md
447_2
Some pre-quantized models can be found in the [official collection](https://huggingface.co/collections/ISTA-DASLab/higgs-675308e432fd56b7f6dab94e) on Hugging Face Hub.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/higgs.md
https://huggingface.co/docs/transformers/en/quantization/higgs/#pre-quantized-models
#pre-quantized-models
.md
447_3
**Architectures** Currently, FLUTE, and HIGGS by extension, **only support Llama 3 and 3.0 of 8B, 70B and 405B parameters, as well as Gemma-2 9B and 27B**. We're working on allowing to run more diverse models as well as allow arbitrary models by modifying the FLUTE compilation procedure. **torch.compile** HIGGS i...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/higgs.md
https://huggingface.co/docs/transformers/en/quantization/higgs/#current-limitations
#current-limitations
.md
447_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/aqlm.md
https://huggingface.co/docs/transformers/en/quantization/aqlm/
.md
448_0
> [!TIP] > Try AQLM on [Google Colab](https://colab.research.google.com/drive/1-xZmBRXT5Fm3Ghn4Mwa2KRypORXb855X?usp=sharing)! Additive Quantization of Language Models ([AQLM](https://arxiv.org/abs/2401.06118)) is a Large Language Models compression method. It quantizes multiple weights together and takes advantage of...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/aqlm.md
https://huggingface.co/docs/transformers/en/quantization/aqlm/#aqlm
#aqlm
.md
448_1
Starting with version `aqlm 1.0.2`, AQLM supports Parameter-Efficient Fine-Tuning in a form of [LoRA](https://huggingface.co/docs/peft/package_reference/lora) integrated into the [PEFT](https://huggingface.co/blog/peft) library.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/aqlm.md
https://huggingface.co/docs/transformers/en/quantization/aqlm/#peft
#peft
.md
448_2
AQLM quantization setups vary mainly on the number of codebooks used as well as codebook sizes in bits. The most popular setups, as well as inference kernels they support are: | Kernel | Number of codebooks | Codebook size, bits | Notation | Accuracy | Speedup | Fast GPU inference | Fast CPU inference | |---|----...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/quantization/aqlm.md
https://huggingface.co/docs/transformers/en/quantization/aqlm/#aqlm-configurations
#aqlm-configurations
.md
448_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/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/
.md
449_0
<Tip warning={true}> Transformers Agents is an experimental API which is subject to change at any time. Results returned by the agents can vary as the APIs or underlying models are prone to change. </Tip> To learn more about agents and tools make sure to read the [introductory guide](../transformers_agents). This...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#agents--tools
#agents--tools
.md
449_1
We provide two types of agents, based on the main [`Agent`] class: - [`CodeAgent`] acts in one shot, generating code to solve the task, then executes it at once. - [`ReactAgent`] acts step by step, each step consisting of one thought, then one tool call and execution. It has two classes: - [`ReactJsonAgent`] writes its...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#agents
#agents
.md
449_2
Agent
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#agent
#agent
.md
449_3
A class for an agent that solves the given task using a single block of code. It plans all its actions, then executes all in one shot.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#codeagent
#codeagent
.md
449_4
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 t...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#react-agents
#react-agents
.md
449_5
ManagedAgent
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#managedagent
#managedagent
.md
449_6
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...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#loadtool
#loadtool
.md
449_7
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.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#tool
#tool
.md
449_8
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 ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#tool
#tool
.md
449_9
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 ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#toolbox
#toolbox
.md
449_10
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 speci...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#pipelinetool
#pipelinetool
.md
449_11
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.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#launchgradiodemo
#launchgradiodemo
.md
449_12
Runs an agent with the given task and streams the messages from the agent as gradio ChatMessages.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#streamtogradio
#streamtogradio
.md
449_13
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 ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#toolcollection
#toolcollection
.md
449_14
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...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#engines
#engines
.md
449_15
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 = AutoToke...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#transformersengine
#transformersengine
.md
449_16
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...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#hfapiengine
#hfapiengine
.md
449_17
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 ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#agent-types
#agent-types
.md
449_18
Text type returned by the agent. Behaves as a string.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#agenttext
#agenttext
.md
449_19
Image type returned by the agent. Behaves as a PIL.Image.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#agentimage
#agentimage
.md
449_20
Audio type returned by the agent.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/agent.md
https://huggingface.co/docs/transformers/en/main_classes/agent/#agentaudio
#agentaudio
.md
449_21
<!--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/main_classes/feature_extractor.md
https://huggingface.co/docs/transformers/en/main_classes/feature_extractor/
.md
450_0
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...
/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
#feature-extractor
.md
450_1
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
/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
#featureextractionmixin
.md
450_2
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 p...
/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
#sequencefeatureextractor
.md
450_3
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', 'atte...
/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
#batchfeature
.md
450_4
image_utils.ImageFeatureExtractionMixin Mixin that contain utilities for preparing image features.
/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
#imagefeatureextractionmixin
.md
450_5
<!--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 applica...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/executorch.md
https://huggingface.co/docs/transformers/en/main_classes/executorch/
.md
451_0
[`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 porta...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/executorch.md
https://huggingface.co/docs/transformers/en/main_classes/executorch/#executorch
#executorch
.md
451_1
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 u...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/executorch.md
https://huggingface.co/docs/transformers/en/main_classes/executorch/#executorch-integration
#executorch-integration
.md
451_2
<!--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/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/
.md
452_0
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.TFGenerationMi...
/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
#generation
.md
452_1
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_alp...
/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
#generationconfig
.md
452_2
A class containing all functions for auto-regressive text generation, to be used as a mixin in [`PreTrainedModel`]. The class exposes [`~generation.GenerationMixin.generate`], which can be used for: - *greedy decoding* if `num_beams=1` and `do_sample=False` - *contrastive search* if `penalty_alpha>0` and `top_k>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/#generationmixin
#generationmixin
.md
452_3
TFGenerationMixin - generate - compute_transition_scores
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#tfgenerationmixin
#tfgenerationmixin
.md
452_4
FlaxGenerationMixin - generate
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/text_generation.md
https://huggingface.co/docs/transformers/en/main_classes/text_generation/#flaxgenerationmixin
#flaxgenerationmixin
.md
452_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/main_classes/tokenizer.md
https://huggingface.co/docs/transformers/en/main_classes/tokenizer/
.md
453_0
A tokenizer is in charge of preparing the inputs for a model. The library contains tokenizers for all the models. Most of the tokenizers are available in two flavors: a full python implementation and a "Fast" implementation based on the Rust library [🤗 Tokenizers](https://github.com/huggingface/tokenizers). The "Fast"...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/tokenizer.md
https://huggingface.co/docs/transformers/en/main_classes/tokenizer/#tokenizer
#tokenizer
.md
453_1
Apart from that each tokenizer can be a "multimodal" tokenizer which means that the tokenizer will hold all relevant special tokens as part of tokenizer attributes for easier access. For example, if the tokenizer is loaded from a vision-language model like LLaVA, you will be able to access `tokenizer.image_token_id` to...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/tokenizer.md
https://huggingface.co/docs/transformers/en/main_classes/tokenizer/#multimodal-tokenizer
#multimodal-tokenizer
.md
453_2
Base class for all slow tokenizers. Inherits from [`~tokenization_utils_base.PreTrainedTokenizerBase`]. Handle all the shared methods for tokenization and special tokens as well as methods downloading/caching/loading pretrained tokenizers as well as adding tokens to the vocabulary. This class also contain the add...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/tokenizer.md
https://huggingface.co/docs/transformers/en/main_classes/tokenizer/#pretrainedtokenizer
#pretrainedtokenizer
.md
453_3
The [`PreTrainedTokenizerFast`] depend on the [tokenizers](https://huggingface.co/docs/tokenizers) library. The tokenizers obtained from the 🤗 tokenizers library can be loaded very simply into 🤗 transformers. Take a look at the [Using tokenizers from 🤗 tokenizers](../fast_tokenizers) page to understand how this is d...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/tokenizer.md
https://huggingface.co/docs/transformers/en/main_classes/tokenizer/#pretrainedtokenizerfast
#pretrainedtokenizerfast
.md
453_4
Holds the output of the [`~tokenization_utils_base.PreTrainedTokenizerBase.__call__`], [`~tokenization_utils_base.PreTrainedTokenizerBase.encode_plus`] and [`~tokenization_utils_base.PreTrainedTokenizerBase.batch_encode_plus`] methods (tokens, attention_masks, etc). This class is derived from a python dictionary and ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/tokenizer.md
https://huggingface.co/docs/transformers/en/main_classes/tokenizer/#batchencoding
#batchencoding
.md
453_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/main_classes/optimizer_schedules.md
https://huggingface.co/docs/transformers/en/main_classes/optimizer_schedules/
.md
454_0
The `.optimization` module provides: - an optimizer with weight decay fixed that can be used to fine-tuned models, and - several schedules in the form of schedule objects that inherit from `_LRSchedule`: - a gradient accumulation class to accumulate the gradients of multiple batches
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/optimizer_schedules.md
https://huggingface.co/docs/transformers/en/main_classes/optimizer_schedules/#optimization
#optimization
.md
454_1
Implements Adam algorithm with weight decay fix as introduced in [Decoupled Weight Decay Regularization](https://arxiv.org/abs/1711.05101). Parameters: params (`Iterable[nn.parameter.Parameter]`): Iterable of parameters to optimize or dictionaries defining parameter groups. lr (`float`, *optional*, defaults to 0.001)...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/optimizer_schedules.md
https://huggingface.co/docs/transformers/en/main_classes/optimizer_schedules/#adamw-pytorch
#adamw-pytorch
.md
454_2
AdaFactor pytorch implementation can be used as a drop in replacement for Adam original fairseq code: https://github.com/pytorch/fairseq/blob/master/fairseq/optim/adafactor.py Paper: *Adafactor: Adaptive Learning Rates with Sublinear Memory Cost* https://arxiv.org/abs/1804.04235 Note that this optimizer internally ad...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/optimizer_schedules.md
https://huggingface.co/docs/transformers/en/main_classes/optimizer_schedules/#adafactor-pytorch
#adafactor-pytorch
.md
454_3
Implements Adam algorithm with weight decay fix as introduced in [Decoupled Weight Decay Regularization](https://arxiv.org/abs/1711.05101). Parameters: params (`Iterable[nn.parameter.Parameter]`): Iterable of parameters to optimize or dictionaries defining parameter groups. lr (`float`, *optional*, defaults to 0.001)...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/optimizer_schedules.md
https://huggingface.co/docs/transformers/en/main_classes/optimizer_schedules/#adamweightdecay-tensorflow
#adamweightdecay-tensorflow
.md
454_4
Scheduler names for the parameter `lr_scheduler_type` in [`TrainingArguments`]. By default, it uses "linear". Internally, this retrieves `get_linear_schedule_with_warmup` scheduler from [`Trainer`]. Scheduler types: - "linear" = get_linear_schedule_with_warmup - "cosine" = get_cosine_schedule_with_warmup - "cosine_with...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/optimizer_schedules.md
https://huggingface.co/docs/transformers/en/main_classes/optimizer_schedules/#learning-rate-schedules-pytorch
#learning-rate-schedules-pytorch
.md
454_5
WarmUp
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/optimizer_schedules.md
https://huggingface.co/docs/transformers/en/main_classes/optimizer_schedules/#warmup-tensorflow
#warmup-tensorflow
.md
454_6
GradientAccumulator
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/optimizer_schedules.md
https://huggingface.co/docs/transformers/en/main_classes/optimizer_schedules/#gradientaccumulator-tensorflow
#gradientaccumulator-tensorflow
.md
454_7
<!--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/main_classes/model.md
https://huggingface.co/docs/transformers/en/main_classes/model/
.md
455_0
The base classes [`PreTrainedModel`], [`TFPreTrainedModel`], and [`FlaxPreTrainedModel`] implement the common methods for loading/saving a model either from a local file or directory, or from a pretrained model configuration provided by the library (downloaded from HuggingFace's AWS S3 repository). [`PreTrainedModel`...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/model.md
https://huggingface.co/docs/transformers/en/main_classes/model/#models
#models
.md
455_1
Base class for all models. [`PreTrainedModel`] takes care of storing the configuration of the models and handles methods for loading, downloading and saving models as well as a few methods common to all models to: - resize the input embeddings, - prune heads in the self-attention heads. Class attributes (overridd...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/model.md
https://huggingface.co/docs/transformers/en/main_classes/model/#pretrainedmodel
#pretrainedmodel
.md
455_2
modeling_utils.ModuleUtilsMixin A few utilities for `torch.nn.Modules`, to be used as a mixin.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/model.md
https://huggingface.co/docs/transformers/en/main_classes/model/#moduleutilsmixin
#moduleutilsmixin
.md
455_3
TFPreTrainedModel - push_to_hub - all
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/model.md
https://huggingface.co/docs/transformers/en/main_classes/model/#tfpretrainedmodel
#tfpretrainedmodel
.md
455_4
[[autodoc]] modeling_tf_utils.TFModelUtilsMixin: No module named 'h5py'
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/model.md
https://huggingface.co/docs/transformers/en/main_classes/model/#tfmodelutilsmixin
#tfmodelutilsmixin
.md
455_5
FlaxPreTrainedModel - push_to_hub - all
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/model.md
https://huggingface.co/docs/transformers/en/main_classes/model/#flaxpretrainedmodel
#flaxpretrainedmodel
.md
455_6
utils.PushToHubMixin A Mixin containing the functionality to push a model or tokenizer to the hub.
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/model.md
https://huggingface.co/docs/transformers/en/main_classes/model/#pushing-to-the-hub
#pushing-to-the-hub
.md
455_7
modeling_utils.load_sharded_checkpoint This is the same as [`torch.nn.Module.load_state_dict`](https://pytorch.org/docs/stable/generated/torch.nn.Module.html?highlight=load_state_dict#torch.nn.Module.load_state_dict) but for a sharded checkpoint. This load is performed efficiently: each checkpoint shard is loaded o...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/model.md
https://huggingface.co/docs/transformers/en/main_classes/model/#sharded-checkpoints
#sharded-checkpoints
.md
455_8
<!--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/main_classes/pipelines.md
https://huggingface.co/docs/transformers/en/main_classes/pipelines/
.md
456_0
The pipelines are a great and easy way to use models for inference. These pipelines are objects that abstract most of the complex code from the library, offering a simple API dedicated to several tasks, including Named Entity Recognition, Masked Language Modeling, Sentiment Analysis, Feature Extraction and Question Ans...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/pipelines.md
https://huggingface.co/docs/transformers/en/main_classes/pipelines/#pipelines
#pipelines
.md
456_1
The *pipeline* abstraction is a wrapper around all the other available pipelines. It is instantiated as any other pipeline but can provide additional quality of life. Simple call on one item: ```python >>> pipe = pipeline("text-classification") >>> pipe("This restaurant is awesome") [{'label': 'POSITIVE', 'score': ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/main_classes/pipelines.md
https://huggingface.co/docs/transformers/en/main_classes/pipelines/#the-pipeline-abstraction
#the-pipeline-abstraction
.md
456_2