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 `tokenizer.model` file contains no information about additional tokens or pattern strings. If these are important, convert the tokenizer to `tokenizer.json`, the appropriate format for [`PreTrainedTokenizerFast`]. Generate the `tokenizer.model` file with [tiktoken.get_encoding](https://github.com/openai/tiktoken/...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tiktoken.md
https://huggingface.co/docs/transformers/en/tiktoken/#create-tiktoken-tokenizer
#create-tiktoken-tokenizer
.md
70_4
<!--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 agreed to...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/peft.md
https://huggingface.co/docs/transformers/en/peft/
.md
71_0
[[open-in-colab]] [Parameter-Efficient Fine Tuning (PEFT)](https://huggingface.co/blog/peft) methods freeze the pretrained model parameters during fine-tuning and add a small number of trainable parameters (the adapters) on top of it. The adapters are trained to learn task-specific information. This approach has been...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/peft.md
https://huggingface.co/docs/transformers/en/peft/#load-adapters-with--peft
#load-adapters-with--peft
.md
71_1
Get started by installing 🤗 PEFT: ```bash pip install peft ``` If you want to try out the brand new features, you might be interested in installing the library from source: ```bash pip install git+https://github.com/huggingface/peft.git ```
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/peft.md
https://huggingface.co/docs/transformers/en/peft/#setup
#setup
.md
71_2
🤗 Transformers natively supports some PEFT methods, meaning you can load adapter weights stored locally or on the Hub and easily run or train them with a few lines of code. The following methods are supported: - [Low Rank Adapters](https://huggingface.co/docs/peft/conceptual_guides/lora) - [IA3](https://huggingface....
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/peft.md
https://huggingface.co/docs/transformers/en/peft/#supported-peft-models
#supported-peft-models
.md
71_3
To load and use a PEFT adapter model from 🤗 Transformers, make sure the Hub repository or local directory contains an `adapter_config.json` file and the adapter weights, as shown in the example image above. Then you can load the PEFT adapter model using the `AutoModelFor` class. For example, to load a PEFT adapter mod...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/peft.md
https://huggingface.co/docs/transformers/en/peft/#load-a-peft-adapter
#load-a-peft-adapter
.md
71_4
The `bitsandbytes` integration supports 8bit and 4bit precision data types, which are useful for loading large models because it saves memory (see the `bitsandbytes` integration [guide](./quantization#bitsandbytes-integration) to learn more). Add the `load_in_8bit` or `load_in_4bit` parameters to [`~PreTrainedModel.fro...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/peft.md
https://huggingface.co/docs/transformers/en/peft/#load-in-8bit-or-4bit
#load-in-8bit-or-4bit
.md
71_5
You can use [`~peft.PeftModel.add_adapter`] to add a new adapter to a model with an existing adapter as long as the new adapter is the same type as the current one. For example, if you have an existing LoRA adapter attached to a model: ```py from transformers import AutoModelForCausalLM, OPTForCausalLM, AutoTokenizer...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/peft.md
https://huggingface.co/docs/transformers/en/peft/#add-a-new-adapter
#add-a-new-adapter
.md
71_6
Once you've added an adapter to a model, you can enable or disable the adapter module. To enable the adapter module: ```py from transformers import AutoModelForCausalLM, OPTForCausalLM, AutoTokenizer from peft import PeftConfig model_id = "facebook/opt-350m" adapter_model_id = "ybelkada/opt-350m-lora" tokenizer = Au...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/peft.md
https://huggingface.co/docs/transformers/en/peft/#enable-and-disable-adapters
#enable-and-disable-adapters
.md
71_7
PEFT adapters are supported by the [`Trainer`] class so that you can train an adapter for your specific use case. It only requires adding a few more lines of code. For example, to train a LoRA adapter: <Tip> If you aren't familiar with fine-tuning a model with [`Trainer`], take a look at the [Fine-tune a pretrained...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/peft.md
https://huggingface.co/docs/transformers/en/peft/#train-a-peft-adapter
#train-a-peft-adapter
.md
71_8
You can also fine-tune additional trainable adapters on top of a model that has adapters attached by passing `modules_to_save` in your PEFT config. For example, if you want to also fine-tune the lm_head on top of a model with a LoRA adapter: ```py from transformers import AutoModelForCausalLM, OPTForCausalLM, AutoTok...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/peft.md
https://huggingface.co/docs/transformers/en/peft/#add-additional-trainable-layers-to-a-peft-adapter
#add-additional-trainable-layers-to-a-peft-adapter
.md
71_9
integrations.PeftAdapterMixin A class containing all functions for loading and using adapters weights that are supported in PEFT library. For more details about adapters and injecting them on a transformer-based model, check out the documentation of PEFT library: https://huggingface.co/docs/peft/index Currently sup...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/peft.md
https://huggingface.co/docs/transformers/en/peft/#api-docs
#api-docs
.md
71_10
<!--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/tasks/translation.md
https://huggingface.co/docs/transformers/en/tasks/translation/
.md
72_0
[[open-in-colab]] <Youtube id="1JvfrvZgi6c"/> Translation converts a sequence of text from one language to another. It is one of several tasks you can formulate as a sequence-to-sequence problem, a powerful framework for returning some output from an input, like translation or summarization. Translation systems are...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/translation.md
https://huggingface.co/docs/transformers/en/tasks/translation/#translation
#translation
.md
72_1
Start by loading the English-French subset of the [OPUS Books](https://huggingface.co/datasets/opus_books) dataset from the 🤗 Datasets library: ```py >>> from datasets import load_dataset >>> books = load_dataset("opus_books", "en-fr") ``` Split the dataset into a train and test set with the [`~datasets.Dataset.t...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/translation.md
https://huggingface.co/docs/transformers/en/tasks/translation/#load-opus-books-dataset
#load-opus-books-dataset
.md
72_2
<Youtube id="XAR8jnZZuUs"/> The next step is to load a T5 tokenizer to process the English-French language pairs: ```py >>> from transformers import AutoTokenizer >>> checkpoint = "google-t5/t5-small" >>> tokenizer = AutoTokenizer.from_pretrained(checkpoint) ``` The preprocessing function you want to create need...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/translation.md
https://huggingface.co/docs/transformers/en/tasks/translation/#preprocess
#preprocess
.md
72_3
Including a metric during training is often helpful for evaluating your model's performance. You can quickly load a evaluation method with the 🤗 [Evaluate](https://huggingface.co/docs/evaluate/index) library. For this task, load the [SacreBLEU](https://huggingface.co/spaces/evaluate-metric/sacrebleu) metric (see the �...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/translation.md
https://huggingface.co/docs/transformers/en/tasks/translation/#evaluate
#evaluate
.md
72_4
<frameworkcontent> <pt> <Tip> If you aren't familiar with finetuning a model with the [`Trainer`], take a look at the basic tutorial [here](../training#train-with-pytorch-trainer)! </Tip> You're ready to start training your model now! Load T5 with [`AutoModelForSeq2SeqLM`]: ```py >>> from transformers import Au...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/translation.md
https://huggingface.co/docs/transformers/en/tasks/translation/#train
#train
.md
72_5
Great, now that you've finetuned a model, you can use it for inference! Come up with some text you'd like to translate to another language. For T5, you need to prefix your input depending on the task you're working on. For translation from English to French, you should prefix your input as shown below: ```py >>> te...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/translation.md
https://huggingface.co/docs/transformers/en/tasks/translation/#inference
#inference
.md
72_6
<!--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/tasks/document_question_answering.md
https://huggingface.co/docs/transformers/en/tasks/document_question_answering/
.md
73_0
[[open-in-colab]] Document Question Answering, also referred to as Document Visual Question Answering, is a task that involves providing answers to questions posed about document images. The input to models supporting this task is typically a combination of an image and a question, and the output is an answer express...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/document_question_answering.md
https://huggingface.co/docs/transformers/en/tasks/document_question_answering/#document-question-answering
#document-question-answering
.md
73_1
In this guide we use a small sample of preprocessed DocVQA that you can find on 🤗 Hub. If you'd like to use the full DocVQA dataset, you can register and download it on [DocVQA homepage](https://rrc.cvc.uab.es/?ch=17). If you do so, to proceed with this guide check out [how to load files into a 🤗 dataset](https://hug...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/document_question_answering.md
https://huggingface.co/docs/transformers/en/tasks/document_question_answering/#load-the-data
#load-the-data
.md
73_2
The Document Question Answering task is a multimodal task, and you need to make sure that the inputs from each modality are preprocessed according to the model's expectations. Let's start by loading the [`LayoutLMv2Processor`], which internally combines an image processor that can handle image data and a tokenizer that...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/document_question_answering.md
https://huggingface.co/docs/transformers/en/tasks/document_question_answering/#preprocess-the-data
#preprocess-the-data
.md
73_3
First, let's prepare the document images for the model with the help of the `image_processor` from the processor. By default, image processor resizes the images to 224x224, makes sure they have the correct order of color channels, applies OCR with tesseract to get words and normalized bounding boxes. In this tutorial, ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/document_question_answering.md
https://huggingface.co/docs/transformers/en/tasks/document_question_answering/#preprocessing-document-images
#preprocessing-document-images
.md
73_4
Once we have applied OCR to the images, we need to encode the text part of the dataset to prepare it for the model. This involves converting the words and boxes that we got in the previous step to token-level `input_ids`, `attention_mask`, `token_type_ids` and `bbox`. For preprocessing text, we'll need the `tokenizer` ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/document_question_answering.md
https://huggingface.co/docs/transformers/en/tasks/document_question_answering/#preprocessing-text-data
#preprocessing-text-data
.md
73_5
Evaluation for document question answering requires a significant amount of postprocessing. To avoid taking up too much of your time, this guide skips the evaluation step. The [`Trainer`] still calculates the evaluation loss during training so you're not completely in the dark about your model's performance. Extractive...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/document_question_answering.md
https://huggingface.co/docs/transformers/en/tasks/document_question_answering/#evaluation
#evaluation
.md
73_6
Congratulations! You've successfully navigated the toughest part of this guide and now you are ready to train your own model. Training involves the following steps: * Load the model with [`AutoModelForDocumentQuestionAnswering`] using the same checkpoint as in the preprocessing. * Define your training hyperparameters i...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/document_question_answering.md
https://huggingface.co/docs/transformers/en/tasks/document_question_answering/#train
#train
.md
73_7
Now that you have finetuned a LayoutLMv2 model, and uploaded it to the 🤗 Hub, you can use it for inference. The simplest way to try out your finetuned model for inference is to use it in a [`Pipeline`]. Let's take an example: ```py >>> example = dataset["test"][2] >>> question = example["query"]["en"] >>> image = ex...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/document_question_answering.md
https://huggingface.co/docs/transformers/en/tasks/document_question_answering/#inference
#inference
.md
73_8
<!--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/tasks/idefics.md
https://huggingface.co/docs/transformers/en/tasks/idefics/
.md
74_0
[[open-in-colab]] While individual tasks can be tackled by fine-tuning specialized models, an alternative approach that has recently emerged and gained popularity is to use large models for a diverse set of tasks without fine-tuning. For instance, large language models can handle such NLP tasks as summarization, tran...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/idefics.md
https://huggingface.co/docs/transformers/en/tasks/idefics/#image-tasks-with-idefics
#image-tasks-with-idefics
.md
74_1
Let's start by loading the model's 9 billion parameters checkpoint: ```py >>> checkpoint = "HuggingFaceM4/idefics-9b" ``` Just like for other Transformers models, you need to load a processor and the model itself from the checkpoint. The IDEFICS processor wraps a [`LlamaTokenizer`] and IDEFICS image processor into ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/idefics.md
https://huggingface.co/docs/transformers/en/tasks/idefics/#loading-the-model
#loading-the-model
.md
74_2
If high-memory GPU availability is an issue, you can load the quantized version of the model. To load the model and the processor in 4bit precision, pass a `BitsAndBytesConfig` to the `from_pretrained` method and the model will be compressed on the fly while loading. ```py >>> import torch >>> from transformers impor...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/idefics.md
https://huggingface.co/docs/transformers/en/tasks/idefics/#quantized-model
#quantized-model
.md
74_3
Image captioning is the task of predicting a caption for a given image. A common application is to aid visually impaired people navigate through different situations, for instance, explore image content online. To illustrate the task, get an image to be captioned, e.g.: <div class="flex justify-center"> <img src="h...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/idefics.md
https://huggingface.co/docs/transformers/en/tasks/idefics/#image-captioning
#image-captioning
.md
74_4
You can extend image captioning by providing a text prompt, which the model will continue given the image. Let's take another image to illustrate: <div class="flex justify-center"> <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/idefics-prompted-im-captioning...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/idefics.md
https://huggingface.co/docs/transformers/en/tasks/idefics/#prompted-image-captioning
#prompted-image-captioning
.md
74_5
While IDEFICS demonstrates great zero-shot results, your task may require a certain format of the caption, or come with other restrictions or requirements that increase task's complexity. Few-shot prompting can be used to enable in-context learning. By providing examples in the prompt, you can steer the model to genera...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/idefics.md
https://huggingface.co/docs/transformers/en/tasks/idefics/#few-shot-prompting
#few-shot-prompting
.md
74_6
Visual Question Answering (VQA) is the task of answering open-ended questions based on an image. Similar to image captioning it can be used in accessibility applications, but also in education (reasoning about visual materials), customer service (questions about products based on images), and image retrieval. Let's g...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/idefics.md
https://huggingface.co/docs/transformers/en/tasks/idefics/#visual-question-answering
#visual-question-answering
.md
74_7
IDEFICS is capable of classifying images into different categories without being explicitly trained on data containing labeled examples from those specific categories. Given a list of categories and using its image and text understanding capabilities, the model can infer which category the image likely belongs to. Sa...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/idefics.md
https://huggingface.co/docs/transformers/en/tasks/idefics/#image-classification
#image-classification
.md
74_8
For more creative applications, you can use image-guided text generation to generate text based on an image. This can be useful to create descriptions of products, ads, descriptions of a scene, etc. Let's prompt IDEFICS to write a story based on a simple image of a red door: <div class="flex justify-center"> <img s...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/idefics.md
https://huggingface.co/docs/transformers/en/tasks/idefics/#image-guided-text-generation
#image-guided-text-generation
.md
74_9
All of the earlier sections illustrated IDEFICS for a single example. In a very similar fashion, you can run inference for a batch of examples by passing a list of prompts: ```py >>> prompts = [ ... [ "https://images.unsplash.com/photo-1543349689-9a4d426bee8e?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/idefics.md
https://huggingface.co/docs/transformers/en/tasks/idefics/#running-inference-in-batch-mode
#running-inference-in-batch-mode
.md
74_10
For conversational use cases, you can find fine-tuned instructed versions of the model on the 🤗 Hub: `HuggingFaceM4/idefics-80b-instruct` and `HuggingFaceM4/idefics-9b-instruct`. These checkpoints are the result of fine-tuning the respective base models on a mixture of supervised and instruction fine-tuning datasets...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/idefics.md
https://huggingface.co/docs/transformers/en/tasks/idefics/#idefics-instruct-for-conversational-use
#idefics-instruct-for-conversational-use
.md
74_11
<!--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/tasks/summarization.md
https://huggingface.co/docs/transformers/en/tasks/summarization/
.md
75_0
[[open-in-colab]] <Youtube id="yHnr5Dk2zCI"/> Summarization creates a shorter version of a document or an article that captures all the important information. Along with translation, it is another example of a task that can be formulated as a sequence-to-sequence task. Summarization can be: - Extractive: extract ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/summarization.md
https://huggingface.co/docs/transformers/en/tasks/summarization/#summarization
#summarization
.md
75_1
Start by loading the smaller California state bill subset of the BillSum dataset from the 🤗 Datasets library: ```py >>> from datasets import load_dataset >>> billsum = load_dataset("billsum", split="ca_test") ``` Split the dataset into a train and test set with the [`~datasets.Dataset.train_test_split`] method: ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/summarization.md
https://huggingface.co/docs/transformers/en/tasks/summarization/#load-billsum-dataset
#load-billsum-dataset
.md
75_2
The next step is to load a T5 tokenizer to process `text` and `summary`: ```py >>> from transformers import AutoTokenizer >>> checkpoint = "google-t5/t5-small" >>> tokenizer = AutoTokenizer.from_pretrained(checkpoint) ``` The preprocessing function you want to create needs to: 1. Prefix the input with a prompt s...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/summarization.md
https://huggingface.co/docs/transformers/en/tasks/summarization/#preprocess
#preprocess
.md
75_3
Including a metric during training is often helpful for evaluating your model's performance. You can quickly load a evaluation method with the 🤗 [Evaluate](https://huggingface.co/docs/evaluate/index) library. For this task, load the [ROUGE](https://huggingface.co/spaces/evaluate-metric/rouge) metric (see the 🤗 Evalua...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/summarization.md
https://huggingface.co/docs/transformers/en/tasks/summarization/#evaluate
#evaluate
.md
75_4
<frameworkcontent> <pt> <Tip> If you aren't familiar with finetuning a model with the [`Trainer`], take a look at the basic tutorial [here](../training#train-with-pytorch-trainer)! </Tip> You're ready to start training your model now! Load T5 with [`AutoModelForSeq2SeqLM`]: ```py >>> from transformers import Au...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/summarization.md
https://huggingface.co/docs/transformers/en/tasks/summarization/#train
#train
.md
75_5
Great, now that you've finetuned a model, you can use it for inference! Come up with some text you'd like to summarize. For T5, you need to prefix your input depending on the task you're working on. For summarization you should prefix your input as shown below: ```py >>> text = "summarize: The Inflation Reduction A...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/summarization.md
https://huggingface.co/docs/transformers/en/tasks/summarization/#inference
#inference
.md
75_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/tasks/mask_generation.md
https://huggingface.co/docs/transformers/en/tasks/mask_generation/
.md
76_0
Mask generation is the task of generating semantically meaningful masks for an image. This task is very similar to [image segmentation](semantic_segmentation), but many differences exist. Image segmentation models are trained on labeled datasets and are limited to the classes they have seen during training; they return...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/mask_generation.md
https://huggingface.co/docs/transformers/en/tasks/mask_generation/#mask-generation
#mask-generation
.md
76_1
The easiest way to infer mask generation models is to use the `mask-generation` pipeline. ```python >>> from transformers import pipeline >>> checkpoint = "facebook/sam-vit-base" >>> mask_generator = pipeline(model=checkpoint, task="mask-generation") ``` Let's see the image. ```python from PIL import Image impor...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/mask_generation.md
https://huggingface.co/docs/transformers/en/tasks/mask_generation/#mask-generation-pipeline
#mask-generation-pipeline
.md
76_2
You can also use the model without the pipeline. To do so, initialize the model and the processor. ```python from transformers import SamModel, SamProcessor import torch from accelerate.test_utils.testing import get_backend # automatically detects the underlying device type (CUDA, CPU, XPU, MPS, etc.) device, _, _ = ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/mask_generation.md
https://huggingface.co/docs/transformers/en/tasks/mask_generation/#point-prompting
#point-prompting
.md
76_3
You can also do box prompting in a similar fashion to point prompting. You can simply pass the input box in the format of a list `[x_min, y_min, x_max, y_max]` format along with the image to the `processor`. Take the processor output and directly pass it to the model, then post-process the output again. ```python # b...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/mask_generation.md
https://huggingface.co/docs/transformers/en/tasks/mask_generation/#box-prompting
#box-prompting
.md
76_4
<!--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/tasks/zero_shot_object_detection.md
https://huggingface.co/docs/transformers/en/tasks/zero_shot_object_detection/
.md
77_0
[[open-in-colab]] Traditionally, models used for [object detection](object_detection) require labeled image datasets for training, and are limited to detecting the set of classes from the training data. Zero-shot object detection is supported by the [OWL-ViT](../model_doc/owlvit) model which uses a different approa...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/zero_shot_object_detection.md
https://huggingface.co/docs/transformers/en/tasks/zero_shot_object_detection/#zero-shot-object-detection
#zero-shot-object-detection
.md
77_1
The simplest way to try out inference with OWL-ViT is to use it in a [`pipeline`]. Instantiate a pipeline for zero-shot object detection from a [checkpoint on the Hugging Face Hub](https://huggingface.co/models?other=owlvit): ```python >>> from transformers import pipeline >>> checkpoint = "google/owlv2-base-patch16...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/zero_shot_object_detection.md
https://huggingface.co/docs/transformers/en/tasks/zero_shot_object_detection/#zero-shot-object-detection-pipeline
#zero-shot-object-detection-pipeline
.md
77_2
Now that you've seen how to use the zero-shot object detection pipeline, let's replicate the same result manually. Start by loading the model and associated processor from a [checkpoint on the Hugging Face Hub](https://huggingface.co/models?other=owlvit). Here we'll use the same checkpoint as before: ```py >>> from...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/zero_shot_object_detection.md
https://huggingface.co/docs/transformers/en/tasks/zero_shot_object_detection/#text-prompted-zero-shot-object-detection-by-hand
#text-prompted-zero-shot-object-detection-by-hand
.md
77_3
You can pass multiple sets of images and text queries to search for different (or same) objects in several images. Let's use both an astronaut image and the beach image together. For batch processing, you should pass text queries as a nested list to the processor and images as lists of PIL images, PyTorch tensors, or N...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/zero_shot_object_detection.md
https://huggingface.co/docs/transformers/en/tasks/zero_shot_object_detection/#batch-processing
#batch-processing
.md
77_4
In addition to zero-shot object detection with text queries, OWL-ViT offers image-guided object detection. This means you can use an image query to find similar objects in the target image. Unlike text queries, only a single example image is allowed. Let's take an image with two cats on a couch as a target image, and...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/zero_shot_object_detection.md
https://huggingface.co/docs/transformers/en/tasks/zero_shot_object_detection/#image-guided-object-detection
#image-guided-object-detection
.md
77_5
<!--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/tasks/semantic_segmentation.md
https://huggingface.co/docs/transformers/en/tasks/semantic_segmentation/
.md
78_0
[[open-in-colab]] <Youtube id="dKE8SIt9C-w"/> Image segmentation models separate areas corresponding to different areas of interest in an image. These models work by assigning a label to each pixel. There are several types of segmentation: semantic segmentation, instance segmentation, and panoptic segmentation. I...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/semantic_segmentation.md
https://huggingface.co/docs/transformers/en/tasks/semantic_segmentation/#image-segmentation
#image-segmentation
.md
78_1
Semantic segmentation assigns a label or class to every single pixel in an image. Let's take a look at a semantic segmentation model output. It will assign the same class to every instance of an object it comes across in an image, for example, all cats will be labeled as "cat" instead of "cat-1", "cat-2". We can use tr...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/semantic_segmentation.md
https://huggingface.co/docs/transformers/en/tasks/semantic_segmentation/#types-of-segmentation
#types-of-segmentation
.md
78_2
We will now: 1. Finetune [SegFormer](https://huggingface.co/docs/transformers/main/en/model_doc/segformer#segformer) on the [SceneParse150](https://huggingface.co/datasets/scene_parse_150) dataset. 2. Use your fine-tuned model for inference. <Tip> To see all architectures and checkpoints compatible with this task...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/semantic_segmentation.md
https://huggingface.co/docs/transformers/en/tasks/semantic_segmentation/#fine-tuning-a-model-for-segmentation
#fine-tuning-a-model-for-segmentation
.md
78_3
Start by loading a smaller subset of the SceneParse150 dataset from the 🤗 Datasets library. This'll give you a chance to experiment and make sure everything works before spending more time training on the full dataset. ```py >>> from datasets import load_dataset >>> ds = load_dataset("scene_parse_150", split="train...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/semantic_segmentation.md
https://huggingface.co/docs/transformers/en/tasks/semantic_segmentation/#load-sceneparse150-dataset
#load-sceneparse150-dataset
.md
78_4
You could also create and use your own dataset if you prefer to train with the [run_semantic_segmentation.py](https://github.com/huggingface/transformers/blob/main/examples/pytorch/semantic-segmentation/run_semantic_segmentation.py) script instead of a notebook instance. The script requires: 1. a [`~datasets.DatasetD...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/semantic_segmentation.md
https://huggingface.co/docs/transformers/en/tasks/semantic_segmentation/#custom-dataset
#custom-dataset
.md
78_5
The next step is to load a SegFormer image processor to prepare the images and annotations for the model. Some datasets, like this one, use the zero-index as the background class. However, the background class isn't actually included in the 150 classes, so you'll need to set `do_reduce_labels=True` to subtract one from...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/semantic_segmentation.md
https://huggingface.co/docs/transformers/en/tasks/semantic_segmentation/#preprocess
#preprocess
.md
78_6
Including a metric during training is often helpful for evaluating your model's performance. You can quickly load an evaluation method with the 🤗 [Evaluate](https://huggingface.co/docs/evaluate/index) library. For this task, load the [mean Intersection over Union](https://huggingface.co/spaces/evaluate-metric/accuracy...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/semantic_segmentation.md
https://huggingface.co/docs/transformers/en/tasks/semantic_segmentation/#evaluate
#evaluate
.md
78_7
<frameworkcontent> <pt> <Tip> If you aren't familiar with finetuning a model with the [`Trainer`], take a look at the basic tutorial [here](../training#finetune-with-trainer)! </Tip> You're ready to start training your model now! Load SegFormer with [`AutoModelForSemanticSegmentation`], and pass the model the map...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/semantic_segmentation.md
https://huggingface.co/docs/transformers/en/tasks/semantic_segmentation/#train
#train
.md
78_8
Great, now that you've finetuned a model, you can use it for inference! Reload the dataset and load an image for inference. ```py >>> from datasets import load_dataset >>> ds = load_dataset("scene_parse_150", split="train[:50]") >>> ds = ds.train_test_split(test_size=0.2) >>> test_ds = ds["test"] >>> image = ds["t...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/semantic_segmentation.md
https://huggingface.co/docs/transformers/en/tasks/semantic_segmentation/#inference
#inference
.md
78_9
<!--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/tasks/image_captioning.md
https://huggingface.co/docs/transformers/en/tasks/image_captioning/
.md
79_0
[[open-in-colab]] Image captioning is the task of predicting a caption for a given image. Common real world applications of it include aiding visually impaired people that can help them navigate through different situations. Therefore, image captioning helps to improve content accessibility for people by describing i...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/image_captioning.md
https://huggingface.co/docs/transformers/en/tasks/image_captioning/#image-captioning
#image-captioning
.md
79_1
Use the 🤗 Dataset library to load a dataset that consists of {image-caption} pairs. To create your own image captioning dataset in PyTorch, you can follow [this notebook](https://github.com/NielsRogge/Transformers-Tutorials/blob/master/GIT/Fine_tune_GIT_on_an_image_captioning_dataset.ipynb). ```python from datasets ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/image_captioning.md
https://huggingface.co/docs/transformers/en/tasks/image_captioning/#load-the-pokémon-blip-captions-dataset
#load-the-pokémon-blip-captions-dataset
.md
79_2
Since the dataset has two modalities (image and text), the pre-processing pipeline will preprocess images and the captions. To do so, load the processor class associated with the model you are about to fine-tune. ```python from transformers import AutoProcessor checkpoint = "microsoft/git-base" processor = AutoPro...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/image_captioning.md
https://huggingface.co/docs/transformers/en/tasks/image_captioning/#preprocess-the-dataset
#preprocess-the-dataset
.md
79_3
Load the ["microsoft/git-base"](https://huggingface.co/microsoft/git-base) into a [`AutoModelForCausalLM`](https://huggingface.co/docs/transformers/model_doc/auto#transformers.AutoModelForCausalLM) object. ```python from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained(checkpoint...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/image_captioning.md
https://huggingface.co/docs/transformers/en/tasks/image_captioning/#load-a-base-model
#load-a-base-model
.md
79_4
Image captioning models are typically evaluated with the [Rouge Score](https://huggingface.co/spaces/evaluate-metric/rouge) or [Word Error Rate](https://huggingface.co/spaces/evaluate-metric/wer). For this guide, you will use the Word Error Rate (WER). We use the 🤗 Evaluate library to do so. For potential limitation...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/image_captioning.md
https://huggingface.co/docs/transformers/en/tasks/image_captioning/#evaluate
#evaluate
.md
79_5
Now, you are ready to start fine-tuning the model. You will use the 🤗 [`Trainer`] for this. First, define the training arguments using [`TrainingArguments`]. ```python from transformers import TrainingArguments, Trainer model_name = checkpoint.split("/")[1] training_args = TrainingArguments( output_dir=f"{model_...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/image_captioning.md
https://huggingface.co/docs/transformers/en/tasks/image_captioning/#train
#train
.md
79_6
Take a sample image from `test_ds` to test the model. ```python from PIL import Image import requests url = "https://huggingface.co/datasets/sayakpaul/sample-datasets/resolve/main/pokemon.png" image = Image.open(requests.get(url, stream=True).raw) image ``` <div class="flex justify-center"> <img src="https://huggi...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/image_captioning.md
https://huggingface.co/docs/transformers/en/tasks/image_captioning/#inference
#inference
.md
79_7
<!--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/tasks/image_text_to_text.md
https://huggingface.co/docs/transformers/en/tasks/image_text_to_text/
.md
80_0
[[open-in-colab]] Image-text-to-text models, also known as vision language models (VLMs), are language models that take an image input. These models can tackle various tasks, from visual question answering to image segmentation. This task shares many similarities with image-to-text, butwith some overlapping use cases...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/image_text_to_text.md
https://huggingface.co/docs/transformers/en/tasks/image_text_to_text/#image-text-to-text
#image-text-to-text
.md
80_1
The fastest way to get started is to use the [`Pipeline`] API. Specify the `"image-text-to-text"` task and the model you want to use. ```python from transformers import pipeline pipe = pipeline("image-text-to-text", model="llava-hf/llava-interleave-qwen-0.5b-hf") ``` The example below uses chat templates to format ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/image_text_to_text.md
https://huggingface.co/docs/transformers/en/tasks/image_text_to_text/#pipeline
#pipeline
.md
80_2
We can use [text streaming](./generation_strategies#streaming) for a better generation experience. Transformers supports streaming with the [`TextStreamer`] or [`TextIteratorStreamer`] classes. We will use the [`TextIteratorStreamer`] with IDEFICS-8B. Assume we have an application that keeps chat history and takes in...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/image_text_to_text.md
https://huggingface.co/docs/transformers/en/tasks/image_text_to_text/#streaming
#streaming
.md
80_3
VLMs are often large and need to be optimized to fit on smaller hardware. Transformers supports many model quantization libraries, and here we will only show int8 quantization with [Quanto](./quantization/quanto#quanto). int8 quantization offers memory improvements up to 75 percent (if all weights are quantized). Howev...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/image_text_to_text.md
https://huggingface.co/docs/transformers/en/tasks/image_text_to_text/#fit-models-in-smaller-hardware
#fit-models-in-smaller-hardware
.md
80_4
Here are some more resources for the image-text-to-text task. - [Image-text-to-texttask page](https://huggingface.co/tasks/image-text-to-text) covers model types, use cases, datasets, and more. - [Vision Language Models Explained](https://huggingface.co/blog/vlms) is a blog post that covers everything about vision la...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/image_text_to_text.md
https://huggingface.co/docs/transformers/en/tasks/image_text_to_text/#further-reading
#further-reading
.md
80_5
<!--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/tasks/object_detection.md
https://huggingface.co/docs/transformers/en/tasks/object_detection/
.md
81_0
[[open-in-colab]] Object detection is the computer vision task of detecting instances (such as humans, buildings, or cars) in an image. Object detection models receive an image as input and output coordinates of the bounding boxes and associated labels of the detected objects. An image can contain multiple objects, e...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/object_detection.md
https://huggingface.co/docs/transformers/en/tasks/object_detection/#object-detection
#object-detection
.md
81_1
The [CPPE-5 dataset](https://huggingface.co/datasets/cppe-5) contains images with annotations identifying medical personal protective equipment (PPE) in the context of the COVID-19 pandemic. Start by loading the dataset and creating a `validation` split from `train`: ```py >>> from datasets import load_dataset >>>...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/object_detection.md
https://huggingface.co/docs/transformers/en/tasks/object_detection/#load-the-cppe-5-dataset
#load-the-cppe-5-dataset
.md
81_2
To finetune a model, you must preprocess the data you plan to use to match precisely the approach used for the pre-trained model. [`AutoImageProcessor`] takes care of processing image data to create `pixel_values`, `pixel_mask`, and `labels` that a DETR model can train with. The image processor has some attributes that...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/object_detection.md
https://huggingface.co/docs/transformers/en/tasks/object_detection/#preprocess-the-data
#preprocess-the-data
.md
81_3
Object detection models are commonly evaluated with a set of <a href="https://cocodataset.org/#detection-eval">COCO-style metrics</a>. We are going to use `torchmetrics` to compute `mAP` (mean average precision) and `mAR` (mean average recall) metrics and will wrap it to `compute_metrics` function in order to use in [`...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/object_detection.md
https://huggingface.co/docs/transformers/en/tasks/object_detection/#preparing-function-to-compute-map
#preparing-function-to-compute-map
.md
81_4
You have done most of the heavy lifting in the previous sections, so now you are ready to train your model! The images in this dataset are still quite large, even after resizing. This means that finetuning this model will require at least one GPU. Training involves the following steps: 1. Load the model with [`AutoMo...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/object_detection.md
https://huggingface.co/docs/transformers/en/tasks/object_detection/#training-the-detection-model
#training-the-detection-model
.md
81_5
```py >>> from pprint import pprint >>> metrics = trainer.evaluate(eval_dataset=cppe5["test"], metric_key_prefix="test") >>> pprint(metrics) {'epoch': 30.0, 'test_loss': 1.0877351760864258, 'test_map': 0.4116, 'test_map_50': 0.741, 'test_map_75': 0.3663, 'test_map_Coverall': 0.5937, 'test_map_Face_Shield': 0.5863, 'te...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/object_detection.md
https://huggingface.co/docs/transformers/en/tasks/object_detection/#evaluate
#evaluate
.md
81_6
Now that you have finetuned a model, evaluated it, and uploaded it to the Hugging Face Hub, you can use it for inference. ```py >>> import torch >>> import requests >>> from PIL import Image, ImageDraw >>> from transformers import AutoImageProcessor, AutoModelForObjectDetection >>> url = "https://images.pexels.com/...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/object_detection.md
https://huggingface.co/docs/transformers/en/tasks/object_detection/#inference
#inference
.md
81_7
<!--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/tasks/token_classification.md
https://huggingface.co/docs/transformers/en/tasks/token_classification/
.md
82_0
[[open-in-colab]] <Youtube id="wVHdVlPScxA"/> Token classification assigns a label to individual tokens in a sentence. One of the most common token classification tasks is Named Entity Recognition (NER). NER attempts to find a label for each entity in a sentence, such as a person, location, or organization. This ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/token_classification.md
https://huggingface.co/docs/transformers/en/tasks/token_classification/#token-classification
#token-classification
.md
82_1
Start by loading the WNUT 17 dataset from the 🤗 Datasets library: ```py >>> from datasets import load_dataset >>> wnut = load_dataset("wnut_17") ``` Then take a look at an example: ```py >>> wnut["train"][0] {'id': '0', 'ner_tags': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/token_classification.md
https://huggingface.co/docs/transformers/en/tasks/token_classification/#load-wnut-17-dataset
#load-wnut-17-dataset
.md
82_2
<Youtube id="iY2AZYdZAr0"/> The next step is to load a DistilBERT tokenizer to preprocess the `tokens` field: ```py >>> from transformers import AutoTokenizer >>> tokenizer = AutoTokenizer.from_pretrained("distilbert/distilbert-base-uncased") ``` As you saw in the example `tokens` field above, it looks like the ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/token_classification.md
https://huggingface.co/docs/transformers/en/tasks/token_classification/#preprocess
#preprocess
.md
82_3
Including a metric during training is often helpful for evaluating your model's performance. You can quickly load a evaluation method with the 🤗 [Evaluate](https://huggingface.co/docs/evaluate/index) library. For this task, load the [seqeval](https://huggingface.co/spaces/evaluate-metric/seqeval) framework (see the 🤗...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/token_classification.md
https://huggingface.co/docs/transformers/en/tasks/token_classification/#evaluate
#evaluate
.md
82_4
Before you start training your model, create a map of the expected ids to their labels with `id2label` and `label2id`: ```py >>> id2label = { ... 0: "O", ... 1: "B-corporation", ... 2: "I-corporation", ... 3: "B-creative-work", ... 4: "I-creative-work", ... 5: "B-group", ... 6: "I-group", ...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/token_classification.md
https://huggingface.co/docs/transformers/en/tasks/token_classification/#train
#train
.md
82_5
Great, now that you've finetuned a model, you can use it for inference! Grab some text you'd like to run inference on: ```py >>> text = "The Golden State Warriors are an American professional basketball team based in San Francisco." ``` The simplest way to try out your finetuned model for inference is to use it i...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/token_classification.md
https://huggingface.co/docs/transformers/en/tasks/token_classification/#inference
#inference
.md
82_6
<!--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/tasks/sequence_classification.md
https://huggingface.co/docs/transformers/en/tasks/sequence_classification/
.md
83_0
[[open-in-colab]] <Youtube id="leNG9fN9FQU"/> Text classification is a common NLP task that assigns a label or class to text. Some of the largest companies run text classification in production for a wide range of practical applications. One of the most popular forms of text classification is sentiment analysis, wh...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/sequence_classification.md
https://huggingface.co/docs/transformers/en/tasks/sequence_classification/#text-classification
#text-classification
.md
83_1
Start by loading the IMDb dataset from the 🤗 Datasets library: ```py >>> from datasets import load_dataset >>> imdb = load_dataset("imdb") ``` Then take a look at an example: ```py >>> imdb["test"][0] { "label": 0, "text": "I love sci-fi and am willing to put up with a lot. Sci-fi movies/TV are usually underfun...
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/tasks/sequence_classification.md
https://huggingface.co/docs/transformers/en/tasks/sequence_classification/#load-imdb-dataset
#load-imdb-dataset
.md
83_2