source
stringclasses 470
values | url
stringlengths 49
167
| file_type
stringclasses 1
value | chunk
stringlengths 1
512
| chunk_id
stringlengths 5
9
|
---|---|---|---|---|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5forconditionalgeneration
|
.md
|
text-to-text denoising generative setting.
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 heads
etc.)
This model is also 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 general usage
|
264_8_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5forconditionalgeneration
|
.md
|
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.
Parameters:
config ([`UMT5Config`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Examples:
```python
|
264_8_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5forconditionalgeneration
|
.md
|
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Examples:
```python
>>> from transformers import UMT5ForConditionalGeneration, AutoTokenizer
|
264_8_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5forconditionalgeneration
|
.md
|
>>> model = UMT5ForConditionalGeneration.from_pretrained("google/umt5-small")
>>> tokenizer = AutoTokenizer.from_pretrained("google/umt5-small")
>>> article = "UN Offizier sagt, dass weiter verhandelt werden muss in Syrien."
>>> summary = "Weiter Verhandlung in Syrien."
>>> inputs = tokenizer(article, text_target=summary, return_tensors="pt")
>>> outputs = model(**inputs)
>>> loss = outputs.loss
```
Methods: forward
|
264_8_4
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5encodermodel
|
.md
|
The bare UMT5 Model transformer outputting encoder's raw hidden-states without any specific head on top.
The UMT5 model was proposed in [Exploring the Limits of Transfer Learning with a Unified Text-to-Text
Transformer](https://arxiv.org/abs/1910.10683) by Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan
Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J. Liu. It's an encoder decoder transformer pre-trained in a
text-to-text denoising generative setting.
|
264_9_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5encodermodel
|
.md
|
text-to-text denoising generative setting.
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 heads
etc.)
This model is also 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 general usage
|
264_9_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5encodermodel
|
.md
|
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.
Parameters:
config ([`UMT5Config`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Examples:
```python
>>> from transformers import UMT5EncoderModel, AutoTokenizer
|
264_9_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5encodermodel
|
.md
|
>>> model = UMT5EncoderModel.from_pretrained("google/umt5-small")
>>> tokenizer = AutoTokenizer.from_pretrained("google/umt5-small")
>>> article = "UN Offizier sagt, dass weiter verhandelt werden muss in Syrien."
>>> input_ids = tokenizer(article, return_tensors="pt").input_ids
>>> outputs = model(input_ids)
>>> hidden_state = outputs.last_hidden_state
```
Methods: forward
|
264_9_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5forsequenceclassification
|
.md
|
UMT5 model with a sequence classification/head on top (a linear layer on top of the pooled output) e.g. for GLUE
tasks.
The UMT5 model was proposed in [Exploring the Limits of Transfer Learning with a Unified Text-to-Text
Transformer](https://arxiv.org/abs/1910.10683) by Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan
Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J. Liu. It's an encoder decoder transformer pre-trained in a
text-to-text denoising generative setting.
|
264_10_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5forsequenceclassification
|
.md
|
text-to-text denoising generative setting.
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 heads
etc.)
This model is also 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 general usage
|
264_10_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5forsequenceclassification
|
.md
|
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.
Parameters:
config ([`UMT5Config`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
264_10_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5fortokenclassification
|
.md
|
UMT5 Encoder Model with a token classification head on top (a linear layer on top of the hidden-states output)
e.g. for Named-Entity-Recognition (NER) tasks.
The UMT5 model was proposed in [Exploring the Limits of Transfer Learning with a Unified Text-to-Text
Transformer](https://arxiv.org/abs/1910.10683) by Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan
Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J. Liu. It's an encoder decoder transformer pre-trained in a
|
264_11_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5fortokenclassification
|
.md
|
Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J. Liu. It's an encoder decoder transformer pre-trained in a
text-to-text denoising generative setting.
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 heads
etc.)
This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
|
264_11_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5fortokenclassification
|
.md
|
etc.)
This model is also 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 general usage
and behavior.
Parameters:
config ([`UMT5Config`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
|
264_11_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5fortokenclassification
|
.md
|
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
264_11_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5forquestionanswering
|
.md
|
UMT5 Model with a span classification head on top for extractive question-answering tasks like SQuAD (linear layers
on top of the hidden-states output to compute `span start logits` and `span end logits`).
The UMT5 model was proposed in [Exploring the Limits of Transfer Learning with a Unified Text-to-Text
Transformer](https://arxiv.org/abs/1910.10683) by Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan
|
264_12_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5forquestionanswering
|
.md
|
Transformer](https://arxiv.org/abs/1910.10683) by Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan
Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J. Liu. It's an encoder decoder transformer pre-trained in a
text-to-text denoising generative setting.
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 heads
etc.)
|
264_12_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5forquestionanswering
|
.md
|
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)
This model is also 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 general usage
and behavior.
Parameters:
config ([`UMT5Config`]): Model configuration class with all the parameters of the model.
|
264_12_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/umt5.md
|
https://huggingface.co/docs/transformers/en/model_doc/umt5/#umt5forquestionanswering
|
.md
|
and behavior.
Parameters:
config ([`UMT5Config`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
264_12_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/
|
.md
|
<!--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 in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
265_0_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/
|
.md
|
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->
|
265_0_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#overview
|
.md
|
The UDOP model was proposed in [Unifying Vision, Text, and Layout for Universal Document Processing](https://arxiv.org/abs/2212.02623) by Zineng Tang, Ziyi Yang, Guoxin Wang, Yuwei Fang, Yang Liu, Chenguang Zhu, Michael Zeng, Cha Zhang, Mohit Bansal.
UDOP adopts an encoder-decoder Transformer architecture based on [T5](t5) for document AI tasks like document image classification, document parsing and document visual question answering.
The abstract from the paper is the following:
|
265_1_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#overview
|
.md
|
We propose Universal Document Processing (UDOP), a foundation Document AI model which unifies text, image, and layout modalities together with varied task formats, including document understanding and generation. UDOP leverages the spatial correlation between textual content and document image to model image, text, and layout modalities with one uniform representation. With a novel Vision-Text-Layout Transformer, UDOP unifies pretraining and multi-domain downstream tasks into a prompt-based sequence
|
265_1_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#overview
|
.md
|
a novel Vision-Text-Layout Transformer, UDOP unifies pretraining and multi-domain downstream tasks into a prompt-based sequence generation scheme. UDOP is pretrained on both large-scale unlabeled document corpora using innovative self-supervised objectives and diverse labeled data. UDOP also learns to generate document images from text and layout modalities via masked image reconstruction. To the best of our knowledge, this is the first time in the field of document AI that one model simultaneously
|
265_1_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#overview
|
.md
|
reconstruction. To the best of our knowledge, this is the first time in the field of document AI that one model simultaneously achieves high-quality neural document editing and content customization. Our method sets the state-of-the-art on 9 Document AI tasks, e.g., document understanding and QA, across diverse data domains like finance reports, academic papers, and websites. UDOP ranks first on the leaderboard of the Document Understanding Benchmark (DUE).*
|
265_1_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#overview
|
.md
|
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/udop_architecture.jpg"
alt="drawing" width="600"/>
<small> UDOP architecture. Taken from the <a href="https://arxiv.org/abs/2212.02623">original paper.</a> </small>
|
265_1_4
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#usage-tips
|
.md
|
- In addition to *input_ids*, [`UdopForConditionalGeneration`] also expects the input `bbox`, which are
the bounding boxes (i.e. 2D-positions) of the input tokens. These can be obtained using an external OCR engine such
|
265_2_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#usage-tips
|
.md
|
the bounding boxes (i.e. 2D-positions) of the input tokens. These can be obtained using an external OCR engine such
as Google's [Tesseract](https://github.com/tesseract-ocr/tesseract) (there's a [Python wrapper](https://pypi.org/project/pytesseract/) available). Each bounding box should be in (x0, y0, x1, y1) format, where (x0, y0) corresponds to the position of the upper left corner in the bounding box, and (x1, y1) represents the
|
265_2_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#usage-tips
|
.md
|
position of the lower right corner. Note that one first needs to normalize the bounding boxes to be on a 0-1000
scale. To normalize, you can use the following function:
```python
def normalize_bbox(bbox, width, height):
return [
int(1000 * (bbox[0] / width)),
int(1000 * (bbox[1] / height)),
int(1000 * (bbox[2] / width)),
int(1000 * (bbox[3] / height)),
]
```
Here, `width` and `height` correspond to the width and height of the original document in which the token
|
265_2_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#usage-tips
|
.md
|
]
```
Here, `width` and `height` correspond to the width and height of the original document in which the token
occurs. Those can be obtained using the Python Image Library (PIL) library for example, as follows:
```python
from PIL import Image
|
265_2_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#usage-tips
|
.md
|
# Document can be a png, jpg, etc. PDFs must be converted to images.
image = Image.open(name_of_your_document).convert("RGB")
|
265_2_4
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#usage-tips
|
.md
|
width, height = image.size
```
|
265_2_5
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#usage-tips
|
.md
|
One can use [`UdopProcessor`] to prepare images and text for the model, which takes care of all of this. By default, this class uses the Tesseract engine to extract a list of words and boxes (coordinates) from a given document. Its functionality is equivalent to that of [`LayoutLMv3Processor`], hence it supports passing either `apply_ocr=False` in case you prefer to use your own OCR engine or `apply_ocr=True` in case you want the default OCR engine to be used. Refer to the [usage guide of
|
265_2_6
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#usage-tips
|
.md
|
to use your own OCR engine or `apply_ocr=True` in case you want the default OCR engine to be used. Refer to the [usage guide of LayoutLMv2](layoutlmv2#usage-layoutlmv2processor) regarding all possible use cases (the functionality of `UdopProcessor` is identical).
|
265_2_7
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#usage-tips
|
.md
|
- If using an own OCR engine of choice, one recommendation is Azure's [Read API](https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/how-to/call-read-api), which supports so-called line segments. Use of segment position embeddings typically results in better performance.
- At inference time, it's recommended to use the `generate` method to autoregressively generate text given a document image.
|
265_2_8
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#usage-tips
|
.md
|
- The model has been pre-trained on both self-supervised and supervised objectives. One can use the various task prefixes (prompts) used during pre-training to test out the out-of-the-box capabilities. For instance, the model can be prompted with "Question answering. What is the date?", as "Question answering." is the task prefix used during pre-training for DocVQA. Refer to the [paper](https://arxiv.org/abs/2212.02623) (table 1) for all task prefixes.
|
265_2_9
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#usage-tips
|
.md
|
- One can also fine-tune [`UdopEncoderModel`], which is the encoder-only part of UDOP, which can be seen as a LayoutLMv3-like Transformer encoder. For discriminative tasks, one can just add a linear classifier on top of it and fine-tune it on a labeled dataset.
This model was contributed by [nielsr](https://huggingface.co/nielsr).
The original code can be found [here](https://github.com/microsoft/UDOP).
|
265_2_10
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#resources
|
.md
|
A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with UDOP. If
you're interested in submitting a resource to be included here, please feel free to open a Pull Request and we'll
review it! The resource should ideally demonstrate something new instead of duplicating an existing resource.
- Demo notebooks regarding UDOP can be found [here](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/UDOP) that show how
|
265_3_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#resources
|
.md
|
to fine-tune UDOP on a custom dataset as well as inference. 🌎
- [Document question answering task guide](../tasks/document_question_answering)
|
265_3_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopconfig
|
.md
|
This is the configuration class to store the configuration of a [`UdopForConditionalGeneration`]. It is used to
instantiate a UDOP 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 UDOP
[microsoft/udop-large](https://huggingface.co/microsoft/udop-large) architecture.
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
265_4_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopconfig
|
.md
|
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
documentation from [`PretrainedConfig`] for more information.
Arguments:
vocab_size (`int`, *optional*, defaults to 33201):
Vocabulary size of the UDOP model. Defines the number of different tokens that can be represented by the
`inputs_ids` passed when calling [`UdopForConditionalGeneration`].
d_model (`int`, *optional*, defaults to 1024):
Size of the encoder layers and the pooler layer.
|
265_4_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopconfig
|
.md
|
d_model (`int`, *optional*, defaults to 1024):
Size of the encoder layers and the pooler layer.
d_kv (`int`, *optional*, defaults to 64):
Size of the key, query, value projections per attention head. The `inner_dim` of the projection layer will
be defined as `num_heads * d_kv`.
d_ff (`int`, *optional*, defaults to 4096):
Size of the intermediate feed forward layer in each `UdopBlock`.
num_layers (`int`, *optional*, defaults to 24):
Number of hidden layers in the Transformer encoder and decoder.
|
265_4_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopconfig
|
.md
|
num_layers (`int`, *optional*, defaults to 24):
Number of hidden layers in the Transformer encoder and decoder.
num_decoder_layers (`int`, *optional*):
Number of hidden layers in the Transformer decoder. Will use the same value as `num_layers` if not set.
num_heads (`int`, *optional*, defaults to 16):
Number of attention heads for each attention layer in the Transformer encoder and decoder.
relative_attention_num_buckets (`int`, *optional*, defaults to 32):
|
265_4_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopconfig
|
.md
|
relative_attention_num_buckets (`int`, *optional*, defaults to 32):
The number of buckets to use for each attention layer.
relative_attention_max_distance (`int`, *optional*, defaults to 128):
The maximum distance of the longer sequences for the bucket separation.
relative_bias_args (`List[dict]`, *optional*, defaults to `[{'type': '1d'}, {'type': 'horizontal'}, {'type': 'vertical'}]`):
A list of dictionaries containing the arguments for the relative bias layers.
|
265_4_4
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopconfig
|
.md
|
A list of dictionaries containing the arguments for the relative bias layers.
dropout_rate (`float`, *optional*, defaults to 0.1):
The ratio for all dropout layers.
layer_norm_epsilon (`float`, *optional*, defaults to 1e-06):
The epsilon used by the layer normalization layers.
initializer_factor (`float`, *optional*, defaults to 1.0):
A factor for initializing all weight matrices (should be kept to 1, used internally for initialization
testing).
|
265_4_5
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopconfig
|
.md
|
A factor for initializing all weight matrices (should be kept to 1, used internally for initialization
testing).
feed_forward_proj (`string`, *optional*, defaults to `"relu"`):
Type of feed forward layer to be used. Should be one of `"relu"` or `"gated-gelu"`. Udopv1.1 uses the
`"gated-gelu"` feed forward projection. Original Udop uses `"relu"`.
is_encoder_decoder (`bool`, *optional*, defaults to `True`):
Whether the model should behave as an encoder/decoder or not.
|
265_4_6
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopconfig
|
.md
|
is_encoder_decoder (`bool`, *optional*, defaults to `True`):
Whether the model should behave as an encoder/decoder or not.
use_cache (`bool`, *optional*, defaults to `True`):
Whether or not the model should return the last key/values attentions (not used by all models).
pad_token_id (`int`, *optional*, defaults to 0):
The id of the padding token in the vocabulary.
eos_token_id (`int`, *optional*, defaults to 1):
The id of the end-of-sequence token in the vocabulary.
|
265_4_7
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopconfig
|
.md
|
eos_token_id (`int`, *optional*, defaults to 1):
The id of the end-of-sequence token in the vocabulary.
max_2d_position_embeddings (`int`, *optional*, defaults to 1024):
The maximum absolute position embeddings for relative position encoding.
image_size (`int`, *optional*, defaults to 224):
The size of the input images.
patch_size (`int`, *optional*, defaults to 16):
The patch size used by the vision encoder.
num_channels (`int`, *optional*, defaults to 3):
The number of channels in the input images.
|
265_4_8
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizer
|
.md
|
Adapted from [`LayoutXLMTokenizer`] and [`T5Tokenizer`]. Based on
[SentencePiece](https://github.com/google/sentencepiece).
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.
Args:
vocab_file (`str`):
Path to the vocabulary file.
eos_token (`str`, *optional*, defaults to `"</s>"`):
The end of sequence token.
<Tip>
|
265_5_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizer
|
.md
|
Path to the vocabulary file.
eos_token (`str`, *optional*, defaults to `"</s>"`):
The end of sequence token.
<Tip>
When building a sequence using special tokens, this is not the token that is used for the end of sequence.
The token used is the `sep_token`.
</Tip>
unk_token (`str`, *optional*, defaults to `"<unk>"`):
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
token instead.
sep_token (`str`, *optional*, defaults to `"</s>"`):
|
265_5_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizer
|
.md
|
token instead.
sep_token (`str`, *optional*, defaults to `"</s>"`):
The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
sequence classification or for a text and a question for question answering. It is also used as the last
token of a sequence built with special tokens.
pad_token (`str`, *optional*, defaults to `"<pad>"`):
The token used for padding, for example when batching sequences of different lengths.
|
265_5_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizer
|
.md
|
The token used for padding, for example when batching sequences of different lengths.
sep_token_box (`List[int]`, *optional*, defaults to `[1000, 1000, 1000, 1000]`):
The bounding box to use for the special [SEP] token.
pad_token_box (`List[int]`, *optional*, defaults to `[0, 0, 0, 0]`):
The bounding box to use for the special [PAD] token.
pad_token_label (`int`, *optional*, defaults to -100):
The label to use for padding tokens. Defaults to -100, which is the `ignore_index` of PyTorch's
CrossEntropyLoss.
|
265_5_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizer
|
.md
|
The label to use for padding tokens. Defaults to -100, which is the `ignore_index` of PyTorch's
CrossEntropyLoss.
only_label_first_subword (`bool`, *optional*, defaults to `True`):
Whether or not to only label the first subword, in case word labels are provided.
additional_special_tokens (`List[str]`, *optional*, defaults to `["<s>NOTUSED", "</s>NOTUSED"]`):
Additional special tokens used by the tokenizer.
sp_model_kwargs (`dict`, *optional*):
|
265_5_4
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizer
|
.md
|
Additional special tokens used by the tokenizer.
sp_model_kwargs (`dict`, *optional*):
Will be passed to the `SentencePieceProcessor.__init__()` method. The [Python wrapper for
SentencePiece](https://github.com/google/sentencepiece/tree/master/python) can be used, among other things,
to set:
- `enable_sampling`: Enable subword regularization.
- `nbest_size`: Sampling parameters for unigram. Invalid for BPE-Dropout.
- `nbest_size = {0,1}`: No sampling is performed.
|
265_5_5
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizer
|
.md
|
- `nbest_size`: Sampling parameters for unigram. Invalid for BPE-Dropout.
- `nbest_size = {0,1}`: No sampling is performed.
- `nbest_size > 1`: samples from the nbest_size results.
- `nbest_size < 0`: assuming that nbest_size is infinite and samples from the all hypothesis (lattice)
using forward-filtering-and-backward-sampling algorithm.
- `alpha`: Smoothing parameter for unigram sampling, and dropout probability of merge operations for
BPE-dropout.
legacy (`bool`, *optional*, defaults to `True`):
|
265_5_6
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizer
|
.md
|
BPE-dropout.
legacy (`bool`, *optional*, defaults to `True`):
Whether or not the `legacy` behaviour of the tokenizer should be used. Legacy is before the merge of #24622
which includes fixes to properly handle tokens that appear after special tokens. A simple example:
- `legacy=True`:
```python
>>> from transformers import T5Tokenizer
|
265_5_7
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizer
|
.md
|
>>> tokenizer = T5Tokenizer.from_pretrained("t5-base", legacy=True)
>>> tokenizer.encode("Hello <extra_id_0>.")
[8774, 32099, 3, 5, 1]
```
- `legacy=False`:
```python
>>> from transformers import T5Tokenizer
|
265_5_8
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizer
|
.md
|
>>> tokenizer = T5Tokenizer.from_pretrained("t5-base", legacy=False)
>>> tokenizer.encode("Hello <extra_id_0>.") # the extra space `[3]` is no longer here
[8774, 32099, 5, 1]
```
Checkout the pull request and the issue [here](https://github.com/huggingface/transformers/pull/24565) for
more details.
add_prefix_space (`bool`, *optional*, defaults to `True`):
Whether or not to add an initial space to the input. This allows to treat the leading word just as any
other word.
Attributes:
|
265_5_9
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizer
|
.md
|
other word.
Attributes:
sp_model (`SentencePieceProcessor`):
The *SentencePiece* processor that is used for every conversion (string, tokens and IDs).
Methods: build_inputs_with_special_tokens
- get_special_tokens_mask
- create_token_type_ids_from_sequences
- save_vocabulary
|
265_5_10
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizerfast
|
.md
|
Construct a "fast" UDOP tokenizer (backed by HuggingFace's *tokenizers* library). Adapted from
[`LayoutXLMTokenizer`] and [`T5Tokenizer`]. Based on
[BPE](https://huggingface.co/docs/tokenizers/python/latest/components.html?highlight=BPE#models).
This tokenizer inherits from [`PreTrainedTokenizerFast`] which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.
Args:
vocab_file (`str`, *optional*):
Path to the vocabulary file.
|
265_6_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizerfast
|
.md
|
Args:
vocab_file (`str`, *optional*):
Path to the vocabulary file.
tokenizer_file (`str`, *optional*):
Path to the tokenizer file.
eos_token (`str`, *optional*, defaults to `"</s>"`):
The end of sequence token.
<Tip>
When building a sequence using special tokens, this is not the token that is used for the end of sequence.
The token used is the `sep_token`.
</Tip>
sep_token (`str`, *optional*, defaults to `"</s>"`):
|
265_6_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizerfast
|
.md
|
The token used is the `sep_token`.
</Tip>
sep_token (`str`, *optional*, defaults to `"</s>"`):
The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
sequence classification or for a text and a question for question answering. It is also used as the last
token of a sequence built with special tokens.
unk_token (`str`, *optional*, defaults to `"<unk>"`):
|
265_6_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizerfast
|
.md
|
token of a sequence built with special tokens.
unk_token (`str`, *optional*, defaults to `"<unk>"`):
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
token instead.
pad_token (`str`, *optional*, defaults to `"<pad>"`):
The token used for padding, for example when batching sequences of different lengths.
sep_token_box (`List[int]`, *optional*, defaults to `[1000, 1000, 1000, 1000]`):
The bounding box to use for the special [SEP] token.
|
265_6_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizerfast
|
.md
|
The bounding box to use for the special [SEP] token.
pad_token_box (`List[int]`, *optional*, defaults to `[0, 0, 0, 0]`):
The bounding box to use for the special [PAD] token.
pad_token_label (`int`, *optional*, defaults to -100):
The label to use for padding tokens. Defaults to -100, which is the `ignore_index` of PyTorch's
CrossEntropyLoss.
only_label_first_subword (`bool`, *optional*, defaults to `True`):
Whether or not to only label the first subword, in case word labels are provided.
|
265_6_4
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udoptokenizerfast
|
.md
|
Whether or not to only label the first subword, in case word labels are provided.
additional_special_tokens (`List[str]`, *optional*, defaults to `["<s>NOTUSED", "</s>NOTUSED"]`):
Additional special tokens used by the tokenizer.
|
265_6_5
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopprocessor
|
.md
|
Constructs a UDOP processor which combines a LayoutLMv3 image processor and a UDOP tokenizer into a single processor.
[`UdopProcessor`] offers all the functionalities you need to prepare data for the model.
It first uses [`LayoutLMv3ImageProcessor`] to resize, rescale and normalize document images, and optionally applies OCR
to get words and normalized bounding boxes. These are then provided to [`UdopTokenizer`] or [`UdopTokenizerFast`],
|
265_7_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopprocessor
|
.md
|
to get words and normalized bounding boxes. These are then provided to [`UdopTokenizer`] or [`UdopTokenizerFast`],
which turns the words and bounding boxes into token-level `input_ids`, `attention_mask`, `token_type_ids`, `bbox`.
Optionally, one can provide integer `word_labels`, which are turned into token-level `labels` for token
classification tasks (such as FUNSD, CORD).
Additionally, it also supports passing `text_target` and `text_pair_target` to the tokenizer, which can be used to
|
265_7_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopprocessor
|
.md
|
Additionally, it also supports passing `text_target` and `text_pair_target` to the tokenizer, which can be used to
prepare labels for language modeling tasks.
Args:
image_processor (`LayoutLMv3ImageProcessor`):
An instance of [`LayoutLMv3ImageProcessor`]. The image processor is a required input.
tokenizer (`UdopTokenizer` or `UdopTokenizerFast`):
An instance of [`UdopTokenizer`] or [`UdopTokenizerFast`]. The tokenizer is a required input.
Methods: __call__
|
265_7_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopmodel
|
.md
|
The bare UDOP encoder-decoder 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 heads
etc.)
This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
|
265_8_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopmodel
|
.md
|
etc.)
This model is also 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 general usage
and behavior.
Args:
config ([`UdopConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
|
265_8_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopmodel
|
.md
|
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
265_8_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopforconditionalgeneration
|
.md
|
The UDOP encoder-decoder Transformer with a language modeling head on top, enabling to generate text given document
images and an optional prompt.
This class is based on [`T5ForConditionalGeneration`], extended to deal with images and layout (2D) data.
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 heads
etc.)
|
265_9_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopforconditionalgeneration
|
.md
|
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)
This model is also 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 general usage
and behavior.
Args:
config ([`UdopConfig`]): Model configuration class with all the parameters of the model.
|
265_9_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopforconditionalgeneration
|
.md
|
and behavior.
Args:
config ([`UdopConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
265_9_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopencodermodel
|
.md
|
The bare UDOP Model transformer outputting encoder's 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 heads
etc.)
This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
|
265_10_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopencodermodel
|
.md
|
etc.)
This model is also 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 general usage
and behavior.
Args:
config ([`UdopConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
|
265_10_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/udop.md
|
https://huggingface.co/docs/transformers/en/model_doc/udop/#udopencodermodel
|
.md
|
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
265_10_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/
|
.md
|
<!--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 in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
266_0_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/
|
.md
|
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->
|
266_0_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#llama3
|
.md
|
```py3
import transformers
import torch
model_id = "meta-llama/Meta-Llama-3-8B"
pipeline = transformers.pipeline("text-generation", model=model_id, model_kwargs={"torch_dtype": torch.bfloat16}, device_map="auto")
pipeline("Hey how are you doing today?")
```
|
266_1_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#overview
|
.md
|
The Llama3 model was proposed in [Introducing Meta Llama 3: The most capable openly available LLM to date](https://ai.meta.com/blog/meta-llama-3/) by the meta AI team.
The abstract from the blogpost is the following:
|
266_2_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#overview
|
.md
|
*Today, we’re excited to share the first two models of the next generation of Llama, Meta Llama 3, available for broad use. This release features pretrained and instruction-fine-tuned language models with 8B and 70B parameters that can support a broad range of use cases. This next generation of Llama demonstrates state-of-the-art performance on a wide range of industry benchmarks and offers new capabilities, including improved reasoning. We believe these are the best open source models of their class,
|
266_2_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#overview
|
.md
|
and offers new capabilities, including improved reasoning. We believe these are the best open source models of their class, period. In support of our longstanding open approach, we’re putting Llama 3 in the hands of the community. We want to kickstart the next wave of innovation in AI across the stack—from applications to developer tools to evals to inference optimizations and more. We can’t wait to see what you build and look forward to your feedback.*
|
266_2_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#overview
|
.md
|
Checkout all Llama3 model checkpoints [here](https://huggingface.co/models?search=llama3).
The original code of the authors can be found [here](https://github.com/meta-llama/llama3).
|
266_2_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#usage-tips
|
.md
|
<Tip warning={true}>
The `Llama3` models were trained using `bfloat16`, but the original inference uses `float16`. The checkpoints uploaded on the Hub use `torch_dtype = 'float16'`, which will be
used by the `AutoModel` API to cast the checkpoints from `torch.float32` to `torch.float16`.
|
266_3_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#usage-tips
|
.md
|
The `dtype` of the online weights is mostly irrelevant unless you are using `torch_dtype="auto"` when initializing a model using `model = AutoModelForCausalLM.from_pretrained("path", torch_dtype = "auto")`. The reason is that the model will first be downloaded ( using the `dtype` of the checkpoints online), then it will be casted to the default `dtype` of `torch` (becomes `torch.float32`), and finally, if there is a `torch_dtype` provided in the config, it will be used.
|
266_3_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#usage-tips
|
.md
|
Training the model in `float16` is not recommended and is known to produce `nan`; as such, the model should be trained in `bfloat16`.
</Tip>
Tips:
- Weights for the Llama3 models can be obtained by filling out [this form](https://ai.meta.com/resources/models-and-libraries/llama-downloads/)
- The architecture is exactly the same as Llama2.
|
266_3_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#usage-tips
|
.md
|
- The architecture is exactly the same as Llama2.
- The tokenizer is a BPE model based on [tiktoken](https://github.com/openai/tiktoken) (vs the one based on sentencepiece implementation for Llama2). The main difference that it ignores BPE merge rules when an input token is part of the vocab. This means that if no merge exist to produce `"hugging"`, instead of having the smallest units, like `["hug","ging"] form 2 tokens, if `"hugging"` is part of the vocab, it will be automatically returned as a token.
|
266_3_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#usage-tips
|
.md
|
- The original model uses `pad_id = -1` which means that there is no padding token. We can't have the same logic, make sure to add a padding token using `tokenizer.add_special_tokens({"pad_token":"<pad>"})` and resize the token embedding accordingly. You should also set the `model.config.pad_token_id`. The `embed_tokens` layer of the model is initialized with `self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.config.padding_idx)`, which makes sure that encoding the padding token
|
266_3_4
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#usage-tips
|
.md
|
nn.Embedding(config.vocab_size, config.hidden_size, self.config.padding_idx)`, which makes sure that encoding the padding token will output zeros, so passing it when initializing is recommended.
|
266_3_5
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#usage-tips
|
.md
|
- The original checkpoint can be converted using the [conversion script](https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/convert_llama_weights_to_hf.py). The script can be called with the following (example) command:
```bash
python src/transformers/models/llama/convert_llama_weights_to_hf.py \
--input_dir /path/to/downloaded/llama/weights --model_size 7B --output_dir /output/path --llama_version 3
```
- After conversion, the model and tokenizer can be loaded via:
|
266_3_6
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#usage-tips
|
.md
|
```
- After conversion, the model and tokenizer can be loaded via:
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
|
266_3_7
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#usage-tips
|
.md
|
tokenizer = AutoTokenizer.from_pretrained("/output/path")
model = AutoModelForCausalLM.from_pretrained("/output/path")
```
Note that executing the script requires enough CPU RAM to host the whole model in float16 precision (even if the biggest versions
come in several checkpoints they each contain a part of each weight of the model, so we need to load them all in RAM). For the 75B model, it's thus 145GB of RAM needed.
|
266_3_8
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#usage-tips
|
.md
|
- When using Flash Attention 2 via `attn_implementation="flash_attention_2"`, don't pass `torch_dtype` to the `from_pretrained` class method and use Automatic Mixed-Precision training. When using `Trainer`, it is simply specifying either `fp16` or `bf16` to `True`. Otherwise, make sure you are using `torch.autocast`. This is required because the Flash Attention only support `fp16` and `bf16` data type.
|
266_3_9
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/llama3.md
|
https://huggingface.co/docs/transformers/en/model_doc/llama3/#resources
|
.md
|
A ton of cool resources are already available on the documentation page of [Llama2](./llama2), inviting contributors to add new resources curated for Llama3 here! 🤗
|
266_4_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/vitpose.md
|
https://huggingface.co/docs/transformers/en/model_doc/vitpose/
|
.md
|
<!--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 in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
267_0_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/vitpose.md
|
https://huggingface.co/docs/transformers/en/model_doc/vitpose/
|
.md
|
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->
|
267_0_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/vitpose.md
|
https://huggingface.co/docs/transformers/en/model_doc/vitpose/#overview
|
.md
|
The ViTPose model was proposed in [ViTPose: Simple Vision Transformer Baselines for Human Pose Estimation](https://arxiv.org/abs/2204.12484) by Yufei Xu, Jing Zhang, Qiming Zhang, Dacheng Tao. ViTPose employs a standard, non-hierarchical [Vision Transformer](vit) as backbone for the task of keypoint estimation. A simple decoder head is added on top to predict the heatmaps from a given image. Despite its simplicity, the model gets state-of-the-art results on the challenging MS COCO Keypoint Detection
|
267_1_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/vitpose.md
|
https://huggingface.co/docs/transformers/en/model_doc/vitpose/#overview
|
.md
|
a given image. Despite its simplicity, the model gets state-of-the-art results on the challenging MS COCO Keypoint Detection benchmark. The model was further improved in [ViTPose++: Vision Transformer for Generic Body Pose Estimation](https://arxiv.org/abs/2212.04246) where the authors employ
|
267_1_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/vitpose.md
|
https://huggingface.co/docs/transformers/en/model_doc/vitpose/#overview
|
.md
|
a mixture-of-experts (MoE) module in the ViT backbone along with pre-training on more data, which further enhances the performance.
The abstract from the paper is the following:
|
267_1_2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.