vector listlengths 1.02k 1.02k | text stringlengths 2 11.8k |
|---|---|
[
0.033877775,
-0.020037286,
-0.038788445,
0.01234975,
-0.022244165,
0.030048622,
-0.024860267,
0.024348738,
0.008856744,
0.04176992,
-0.022580313,
-0.0037889618,
0.014578551,
0.00066361635,
-0.029990163,
0.01473201,
-0.0108443955,
-0.049077466,
-0.02151341,
0.011772454,
-0.011... | Use case 4: web page question answering (inference), parse_html=True
For question answering tasks on web pages, you can provide a question to the processor. By default, the
processor will use the feature extractor to get all nodes and xpaths, and create [CLS] question tokens [SEP] word tokens [SEP].
thon |
[
0.03477079,
-0.011196533,
-0.016409323,
-0.0044276877,
0.00073382206,
-0.030668458,
0.006892623,
0.00034613415,
-0.01782392,
0.038024362,
-0.02655198,
0.018220006,
0.028787045,
-0.0052764458,
-0.030894794,
0.028603146,
-0.008862449,
-0.07197469,
-0.04037259,
-0.004866213,
-0.... | from transformers import MarkupLMProcessor
processor = MarkupLMProcessor.from_pretrained("microsoft/markuplm-base")
html_string = """
<!DOCTYPE html>
Hello world
Welcome
My name is Niels.
"""
question = "What's his name?"
encoding = processor(html_string, questions=question, return_tensors="pt"... |
[
0.027666863,
-0.016063256,
-0.0055674594,
-0.0028511924,
0.0046016756,
-0.012264033,
0.004608777,
-0.01393285,
-0.0023097144,
0.039938,
-0.033461567,
0.015765,
0.035989646,
-0.00504551,
-0.019045824,
0.029825674,
-0.009608128,
-0.06669589,
-0.045278214,
-0.0075203306,
-0.0282... |
from transformers import MarkupLMProcessor
processor = MarkupLMProcessor.from_pretrained("microsoft/markuplm-base")
processor.parse_html = False
nodes = ["hello", "world", "how", "are"]
xpaths = ["/html/body/div/li[1]/div/span", "/html/body/div/li[1]/div/span", "html/body", "html/body/div"]
question = "What's his nam... |
[
0.01688647,
-0.009197212,
-0.021891313,
0.0069742813,
-0.013792568,
-0.010464672,
0.0059440634,
0.008722726,
0.001244711,
0.05480628,
-0.01627549,
0.016327487,
0.026623165,
-0.019213397,
-0.00830024,
-0.0033636445,
-0.022203304,
-0.037256833,
-0.033902936,
-0.02365926,
-0.029... | Resources
Demo notebooks
Text classification task guide
Token classification task guide
Question answering task guide |
[
0.029964205,
-0.009850949,
-0.02619703,
0.006866797,
-0.009887033,
0.021332897,
-0.02345464,
0.0074766176,
0.0013748028,
0.06362341,
-0.006736894,
-0.022891728,
0.028246604,
-0.002166848,
0.001074403,
-0.006040472,
-0.01086852,
-0.032013778,
-0.023440206,
0.016930642,
-0.0028... | Use case 5: web page question answering (inference), parse_html=False
For question answering tasks (such as WebSRC), you can provide a question to the processor. If you have extracted
all nodes and xpaths yourself, you can provide them directly to the processor. Make sure to set parse_html to False.
thon |
[
0.021195486,
-0.009655086,
0.015810918,
-0.008890963,
-0.025694527,
-0.0460759,
0.05167471,
0.015111067,
0.0024655464,
0.030879136,
0.011647519,
-0.0058558956,
0.050646354,
-0.031250488,
-0.032935843,
0.014125562,
-0.0042776605,
-0.017053511,
-0.044933286,
-0.020995528,
-0.02... | BEiT pre-training. Taken from the original paper.
Resources
A list of official Hugging Face and community (indicated by ๐) resources to help you get started with BEiT.
[BeitForImageClassification] is supported by this example script and notebook.
See also: Image classification task guide |
[
-0.005003102,
-0.026865782,
-0.01756879,
-0.007969854,
0.006891993,
-0.024773257,
-0.0001591996,
0.01724578,
-0.010603066,
0.02822803,
-0.03300292,
-0.0036970293,
0.033789374,
-0.040277608,
-0.022175154,
0.007710044,
-0.0065970733,
-0.03665431,
-0.066455245,
-0.014036774,
0.0... |
Semantic segmentation
- Semantic segmentation task guide
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.
BEiT specific outputs
[[autodoc]] ... |
[
0.0029762234,
-0.009172163,
-0.023809787,
0.012535523,
-0.005290285,
0.016032016,
-0.0093052965,
0.001884883,
0.010412402,
0.035287254,
0.0055039986,
0.039547507,
0.0259259,
-0.03419416,
-0.02256254,
0.04400396,
-0.012647635,
-0.060876817,
-0.03388585,
0.008422414,
-0.0325685... |
MarkupLMConfig
[[autodoc]] MarkupLMConfig
- all
MarkupLMFeatureExtractor
[[autodoc]] MarkupLMFeatureExtractor
- call
MarkupLMTokenizer
[[autodoc]] MarkupLMTokenizer
- build_inputs_with_special_tokens
- get_special_tokens_mask
- create_token_type_ids_from_sequences
- save_vocabulary
MarkupLMTok... |
[
0.0072503774,
-0.028712073,
-0.0038856813,
-0.040550016,
-0.011078171,
-0.02604926,
0.014464576,
-0.0001415524,
-0.019421171,
0.03531122,
0.010412469,
-0.027814822,
0.06558625,
-0.028639715,
-0.0016307923,
0.012793082,
-0.022547083,
-0.026628133,
-0.06697554,
-0.0037481992,
0... |
BEiT
Overview
The BEiT model was proposed in BEiT: BERT Pre-Training of Image Transformers by
Hangbo Bao, Li Dong and Furu Wei. Inspired by BERT, BEiT is the first paper that makes self-supervised pre-training of
Vision Transformers (ViTs) outperform supervised pre-training. Rather than pre-training the model to predi... |
[
0.019414833,
-0.026514286,
0.0030788446,
-0.05667972,
-0.0048428415,
0.005302857,
-0.0087076975,
0.015024762,
-0.037496705,
0.0417274,
0.029252646,
-0.037091024,
0.044596158,
-0.02361655,
0.0077152224,
0.02635491,
-0.014756721,
-0.015300047,
-0.06676384,
-0.007773177,
0.00417... |
BEiT models are regular Vision Transformers, but pre-trained in a self-supervised way rather than supervised. They
outperform both the original model (ViT) as well as Data-efficient Image Transformers (DeiT) when fine-tuned on ImageNet-1K and CIFAR-100. You can check out demo notebooks regarding inference as well a... |
[
0.016296197,
-0.012481877,
-0.0028013724,
-0.0068754214,
0.030455185,
-0.0300693,
0.006882842,
-0.009825211,
-0.017824892,
0.083291665,
0.0298912,
-0.033215743,
0.03093012,
-0.037490156,
-0.0134985335,
-0.038499393,
-0.013283329,
-0.010990285,
-0.041942667,
-0.018166251,
0.01... |
RoCBert
Overview
The RoCBert model was proposed in RoCBert: Robust Chinese Bert with Multimodal Contrastive Pretraining by HuiSu, WeiweiShi, XiaoyuShen, XiaoZhou, TuoJi, JiaruiFang, JieZhou.
It's a pretrained Chinese language model that is robust under various forms of adversarial attacks.
The abstract from the paper... |
[
-0.00520346,
-0.036057,
-0.0041710823,
-0.008487668,
0.018042358,
-0.019968538,
0.01726634,
0.03209378,
-0.0045521613,
0.039604496,
0.014189995,
0.01705848,
0.057702284,
-0.014314712,
-0.030929755,
0.038274184,
-0.017820638,
-0.029654872,
-0.028629424,
0.006204658,
0.03317465... | BeitModel
[[autodoc]] BeitModel
- forward
BeitForMaskedImageModeling
[[autodoc]] BeitForMaskedImageModeling
- forward
BeitForImageClassification
[[autodoc]] BeitForImageClassification
- forward
BeitForSemanticSegmentation
[[autodoc]] BeitForSemanticSegmentation
- forward
FlaxBeitModel
[[autodoc]] FlaxB... |
[
0.010273644,
0.007717556,
-0.010710221,
0.0073373113,
-0.008083717,
0.014956285,
-0.009372324,
0.007999218,
-0.020814868,
0.07802054,
0.037207633,
0.004231981,
0.02415257,
-0.03684147,
-0.03329252,
0.0012683619,
-0.028673254,
-0.035545822,
-0.06033213,
-0.025659464,
-0.010886... |
RoCBertConfig
[[autodoc]] RoCBertConfig
- all
RoCBertTokenizer
[[autodoc]] RoCBertTokenizer
- build_inputs_with_special_tokens
- get_special_tokens_mask
- create_token_type_ids_from_sequences
- save_vocabulary
RoCBertModel
[[autodoc]] RoCBertModel
- forward
RoCBertForPreTraining
[[autodoc]] Ro... |
[
0.020806994,
-0.006721601,
-0.020831458,
-0.015779555,
-0.012489089,
0.0072903987,
-0.01102734,
-0.02957749,
-0.019755023,
0.03564467,
-0.0059020426,
0.013149628,
0.019669399,
-0.034030017,
-0.020880386,
-0.010599212,
-0.05323459,
-0.03427466,
-0.056708537,
-0.038849507,
-0.0... | Text classification task guide
Token classification task guide
Question answering task guide
Causal language modeling task guide
Masked language modeling task guide
Multiple choice task guide |
[
0.016819837,
0.0025434962,
-0.034446105,
0.02828267,
0.009158747,
-0.026554605,
-0.014638154,
-0.033812482,
0.0022932868,
0.041041553,
0.012024456,
0.030730763,
0.028729089,
-0.0343597,
-0.02272406,
0.004381366,
-0.009252351,
-0.054232452,
-0.042596813,
0.0034129291,
0.024826... |
SeamlessM4T-v2
Overview
The SeamlessM4T-v2 model was proposed in Seamless: Multilingual Expressive and Streaming Speech Translation by the Seamless Communication team from Meta AI.
SeamlessM4T-v2 is a collection of models designed to provide high quality translation, allowing people from different linguistic communiti... |
[
0.0005769587,
0.0027068786,
-0.03527769,
0.003012138,
0.029128367,
-0.007513795,
0.010658335,
-0.0066237613,
-0.0030360438,
0.056903295,
0.01587349,
-0.026774561,
0.010959916,
-0.034571547,
0.031452753,
0.0031316674,
-0.010959916,
-0.055726394,
-0.0014251568,
-0.028716452,
0.... |
SwiftFormer
Overview
The SwiftFormer model was proposed in SwiftFormer: Efficient Additive Attention for Transformer-based Real-time Mobile Vision Applications by Abdelrahman Shaker, Muhammad Maaz, Hanoona Rasheed, Salman Khan, Ming-Hsuan Yang, Fahad Shahbaz Khan.
The SwiftFormer paper introduces a novel efficient add... |
[
-0.005355935,
0.02707776,
-0.030949675,
-0.00096717733,
-0.00020974207,
0.009199003,
0.0013958765,
-0.016551794,
0.020833978,
0.03341129,
-0.007275866,
0.022346845,
-0.008551546,
-0.045155242,
-0.027847014,
0.023103278,
-0.03833452,
-0.02226992,
-0.021244247,
-0.013070917,
-0... | Speech-to-speech translation (S2ST)
Speech-to-text translation (S2TT)
Text-to-speech translation (T2ST)
Text-to-text translation (T2TT)
Automatic speech recognition (ASR) |
[
0.0048064813,
0.0039329077,
-0.0056544687,
0.017895462,
-0.015863216,
-0.018056286,
0.0033499163,
-0.019035859,
0.013830969,
0.028553788,
-0.008063192,
-0.00038036078,
0.04067416,
-0.040878847,
-0.008976972,
0.013129186,
-0.022705598,
-0.067780524,
-0.04304268,
-0.014328065,
... | from transformers import AutoProcessor, SeamlessM4Tv2Model
processor = AutoProcessor.from_pretrained("facebook/seamless-m4t-v2-large")
model = SeamlessM4Tv2Model.from_pretrained("facebook/seamless-m4t-v2-large")
You can seamlessly use this model on text or on audio, to generated either translated text or translated au... |
[
0.024717407,
0.025060086,
-0.038767148,
0.024136348,
-0.00083527406,
-0.042044923,
-0.008254035,
-0.03608533,
0.026326498,
0.02792069,
-0.0074681137,
0.0107347155,
0.011829791,
-0.07765348,
-0.006723165,
-0.0026669174,
-0.018787613,
-0.039988864,
-0.030066142,
-0.008164641,
0... |
[SeamlessM4Tv2Model] can perform all the above tasks, but each task also has its own dedicated sub-model.
The abstract from the paper is the following:
Recent advancements in automatic speech translation have dramatically expanded language coverage, improved multimodal capabilities, and enabled a wide range of tasks ... |
[
0.0048708846,
0.0074046017,
-0.0138729075,
-0.0021066663,
0.01288658,
-0.027860172,
-0.034307037,
-0.04056807,
-0.0036844327,
0.05060288,
-0.0052997223,
0.003863115,
0.019140467,
-0.050574288,
0.002651648,
-0.00037277633,
-0.024357995,
-0.04133998,
-0.060266025,
-0.024143577,
... | let's load an audio sample from an Arabic speech corpus
from datasets import load_dataset
dataset = load_dataset("arabic_speech_corpus", split="test", streaming=True)
audio_sample = next(iter(dataset))["audio"]
now, process it
audio_inputs = processor(audios=audio_sample["array"], return_tensors="pt")
now, process some... |
[
-0.0013961463,
0.00056543923,
-0.04982939,
0.023172304,
-0.006701502,
-0.04935284,
-0.0069993464,
-0.010893663,
-0.003185075,
0.030529063,
0.012561593,
0.008168386,
0.025927367,
-0.06439399,
-0.026001828,
-0.024036054,
-0.029724883,
-0.048995424,
-0.02735702,
0.0016362834,
-0... | Speech
[SeamlessM4Tv2Model] can seamlessly generate text or speech with few or no changes. Let's target Russian voice translation:
thon
audio_array_from_text = model.generate(text_inputs, tgt_lang="rus")[0].cpu().numpy().squeeze()
audio_array_from_audio = model.generate(audio_inputs, tgt_lang="rus")[0].cpu().numpy().s... |
[
-0.00037151543,
-0.008968137,
-0.04618305,
0.023677025,
0.010703214,
-0.04981029,
0.0030363856,
0.0005051717,
-0.0027543462,
0.038814325,
-0.010474727,
0.031217113,
0.036643695,
-0.06414788,
-0.020735247,
-0.03630096,
-0.006922459,
-0.04835368,
-0.044783562,
-0.00064039,
-0.0... | With basically the same code, I've translated English text and Arabic speech to Russian speech samples.
Text
Similarly, you can generate translated text from audio files or from text with the same model. You only have to pass generate_speech=False to [SeamlessM4Tv2Model.generate].
This time, let's translate to French.
... |
[
-0.017071186,
-0.005290215,
-0.023668814,
0.020248877,
0.010416558,
-0.057910934,
-0.0030868493,
0.008029727,
-0.024253054,
0.04457318,
0.0016538602,
0.017569926,
0.032460902,
-0.057882432,
-0.017014187,
-0.023797061,
-0.011178919,
-0.056656957,
-0.054149,
-0.014021741,
-0.01... | from audio
output_tokens = model.generate(**audio_inputs, tgt_lang="fra", generate_speech=False)
translated_text_from_audio = processor.decode(output_tokens[0].tolist()[0], skip_special_tokens=True)
from text
output_tokens = model.generate(**text_inputs, tgt_lang="fra", generate_speech=False)
translated_text_from_text ... |
[
0.0008675892,
0.015537278,
-0.030257573,
-0.0013449228,
-0.0069844807,
-0.04551766,
-0.022175271,
-0.01870309,
0.01825083,
0.0145452265,
0.010693733,
-0.021679245,
0.042833284,
-0.06810142,
0.0076811053,
0.0031566934,
-0.0019913977,
-0.039156858,
-0.055321462,
-0.0056277043,
... | Tips
1. Use dedicated models
[SeamlessM4Tv2Model] is transformers top level model to generate speech and text, but you can also use dedicated models that perform the task without additional components, thus reducing the memory footprint.
For example, you can replace the audio-to-audio generation snippet with the model ... |
[
0.0045711556,
0.005700869,
-0.014107471,
0.014588646,
-0.013096308,
-0.052189976,
0.0033106883,
-0.02541158,
0.020167477,
0.025955517,
-0.0018514749,
-0.024909485,
0.050153702,
-0.04800585,
-0.006018165,
0.010739252,
-0.015788095,
-0.041060206,
-0.02383556,
-0.011855018,
-0.0... | from transformers import SeamlessM4Tv2ForSpeechToSpeech
model = SeamlessM4Tv2ForSpeechToSpeech.from_pretrained("facebook/seamless-m4t-v2-large")
Or you can replace the text-to-text generation snippet with the model dedicated to the T2TT task, you only have to remove generate_speech=False.
thon
from transformers impor... |
[
0.0049390043,
0.001419736,
-0.022657454,
0.00012062744,
0.0029233075,
-0.030997265,
-0.024013404,
-0.018123047,
-0.019464416,
0.050971985,
-0.027148122,
0.023998823,
0.017146181,
-0.042690493,
-0.00020138745,
0.004002234,
-0.017802287,
-0.04872665,
-0.07295875,
-0.008893853,
... | Input text or speech is processed through its specific encoder.
A decoder creates text tokens in the desired language.
If speech generation is required, the second seq2seq model, generates unit tokens in an non auto-regressive way.
These unit tokens are then passed through the final vocoder to produce the actual speech... |
[
0.007815934,
-0.009191424,
-0.030232117,
0.017093325,
-0.008123986,
-0.030547334,
-0.020875921,
-0.011354954,
0.022466332,
0.033556215,
0.025704464,
0.012372243,
0.03679435,
-0.058085784,
-0.01322476,
0.0229105,
-0.009807528,
-0.0529277,
-0.04957494,
-0.0093203755,
0.04080619... |
This model was contributed by ylacombe. The original code can be found here.
SeamlessM4Tv2Model
[[autodoc]] SeamlessM4Tv2Model
- generate
SeamlessM4Tv2ForTextToSpeech
[[autodoc]] SeamlessM4Tv2ForTextToSpeech
- generate
SeamlessM4Tv2ForSpeechToSpeech
[[autodoc]] SeamlessM4Tv2ForSpeechToSpeech
- generate
Se... |
[
0.030231733,
-0.013269003,
0.012160885,
-0.008538191,
-0.010860977,
-0.027802397,
0.036084868,
0.015826197,
-0.009546863,
0.031908117,
-0.0150022125,
0.00047503455,
0.05063247,
-0.043756455,
-0.036056455,
0.011287176,
0.011201937,
-0.039664943,
-0.04048893,
-0.012857011,
-0.0... | Resources
A list of official Hugging Face and community (indicated by ๐) resources to help you get started with ViT MSN.
[ViTMSNForImageClassification] is supported by this example script and notebook.
See also: Image classification task guide |
[
0.0012615743,
0.0018572651,
-0.04030967,
0.025967564,
0.0068864888,
-0.03508884,
-0.030763444,
-0.03848845,
0.0080664875,
0.014122045,
0.0053953645,
0.004439224,
0.040582854,
-0.058612935,
-0.020837793,
-0.01327973,
-0.00074508775,
-0.05251185,
-0.045135904,
0.007459414,
-0.0... |
Feel free to try out [SeamlessM4Tv2ForSpeechToText] and [SeamlessM4Tv2ForTextToSpeech] as well.
2. Change the speaker identity
You have the possibility to change the speaker used for speech synthesis with the speaker_id argument. Some speaker_id works better than other for some languages!
3. Change the generation str... |
[
0.031420536,
-0.017429022,
-0.05846606,
-0.023892106,
0.033551224,
-0.017088111,
0.008103714,
-0.0035546967,
0.00849434,
0.055539917,
-0.0009348391,
-0.02684666,
0.031704627,
-0.012563953,
-0.0101775825,
0.01010656,
-0.0055220313,
-0.0010742215,
-0.05298309,
-0.029602349,
-0.... |
OneFormer
Overview
The OneFormer model was proposed in OneFormer: One Transformer to Rule Universal Image Segmentation by Jitesh Jain, Jiachen Li, MangTik Chiu, Ali Hassani, Nikita Orlov, Humphrey Shi. OneFormer is a universal image segmentation framework that can be trained on a single panoptic dataset to perform sem... |
[
0.015154494,
0.01224556,
-0.023467736,
-0.023916343,
-0.001359839,
-0.015154494,
-0.0471037,
-0.008635678,
-0.019416258,
0.023005111,
0.04174846,
0.00531669,
0.035580117,
-0.035299737,
-0.008761849,
0.028612694,
-0.002483108,
-0.021505082,
-0.05004768,
-0.03541189,
-0.0008253... |
MSN (masked siamese networks) is a method for self-supervised pre-training of Vision Transformers (ViTs). The pre-training
objective is to match the prototypes assigned to the unmasked views of the images to that of the masked views of the same images.
The authors have only released pre-trained weights of the backbon... |
[
0.010980382,
-0.0032344619,
-0.02701874,
-0.026475793,
0.01665989,
-0.024632633,
-0.0344914,
-0.018417323,
-0.008987196,
0.045864705,
0.032776833,
0.001634198,
0.021803595,
-0.030347861,
-0.016116943,
0.012544925,
0.009594439,
-0.015531132,
-0.050151125,
-0.03723471,
0.007715... |
ViTMSN
Overview
The ViTMSN model was proposed in Masked Siamese Networks for Label-Efficient Learning by Mahmoud Assran, Mathilde Caron, Ishan Misra, Piotr Bojanowski, Florian Bordes,
Pascal Vincent, Armand Joulin, Michael Rabbat, Nicolas Ballas. The paper presents a joint-embedding architecture to match the prototype... |
[
0.054294154,
-0.012984927,
-0.03307575,
-0.016452774,
0.012325398,
-0.034380626,
0.0013155128,
-0.014069959,
0.00836113,
0.06269074,
0.018509371,
-0.010956697,
0.02517558,
-0.052875813,
-0.0017383562,
0.013779199,
0.008190929,
-0.0023544487,
-0.03134537,
-0.0098858485,
-0.009... |
The abstract from the paper is the following:
Universal Image Segmentation is not a new concept. Past attempts to unify image segmentation in the last decades include scene parsing, panoptic segmentation, and, more recently, new panoptic architectures. However, such panoptic architectures do not truly unify image seg... |
[
0.0232055,
-0.0031911149,
-0.0098458445,
0.005417724,
-0.02724997,
-0.0322697,
0.020021556,
0.0112872245,
0.030577334,
0.08094675,
0.02025103,
0.007579794,
0.032929435,
-0.041649427,
-0.0054141385,
0.015087878,
-0.0034205883,
-0.031323124,
-0.07870939,
0.014155642,
0.05036942... | This model was contributed by Jitesh Jain. The original code can be found here.
Usage tips |
[
0.032793548,
-0.022597685,
-0.009866311,
-0.007398052,
-0.022664942,
-0.007835209,
-0.0075594643,
0.03300876,
0.014258064,
0.06827729,
0.0072164633,
0.0069608944,
0.042962506,
-0.032605235,
-0.013309768,
0.017755324,
0.03190578,
-0.035591356,
-0.053830918,
-0.0375014,
-0.0019... | 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.
ViTMSNConfig
[[autodoc]] ViTMSNConfig
ViTMSNModel
[[autodoc]] ViTMSNModel
- forward
ViTMS... |
[
0.021274807,
-0.01203152,
-0.027925907,
-0.008960106,
-0.01082619,
-0.019866167,
0.04789373,
0.011574076,
0.020054953,
0.02576212,
-0.006749124,
0.011900822,
0.022480136,
-0.045395933,
0.0062154382,
0.04040035,
0.017005323,
-0.031832337,
-0.02605256,
-0.012213046,
-0.01793473... | Resources
A list of official Hugging Face and community (indicated by ๐) resources to help you get started with OneFormer.
Demo notebooks regarding inference + fine-tuning on custom data can be found here. |
[
0.03433683,
0.0010962919,
-0.07236643,
-0.018702107,
-0.003720692,
-0.024449728,
-0.004783481,
-0.0036183216,
0.043062497,
0.05128189,
-0.007608899,
-0.006722931,
0.026504578,
-0.017257756,
-0.017019514,
0.04419415,
-0.0015420676,
-0.026489688,
-0.050180018,
-0.02374989,
-0.0... |
OneFormer requires two inputs during inference: image and task token.
During training, OneFormer only uses panoptic annotations.
If you want to train the model in a distributed environment across multiple nodes, then one should update the
get_num_masks function inside in the OneFormerLoss class of modeling_oneform... |
[
0.019800471,
-0.013158977,
-0.030148527,
0.00470554,
-0.012945402,
-0.014137289,
-0.019097742,
-0.012848949,
0.019469775,
0.06343867,
-0.0036514439,
0.002134028,
0.026207723,
-0.03764432,
-0.004447183,
0.040841058,
0.01754071,
-0.039766293,
-0.060076587,
-0.04321105,
-0.00371... |
If you're interested in submitting a resource to be included here, please feel free to open a Pull Request and we will review it.
The resource should ideally demonstrate something new instead of duplicating an existing resource.
OneFormer specific outputs
[[autodoc]] models.oneformer.modeling_oneformer.OneFormerModel... |
[
0.024081491,
0.02515178,
-0.011896112,
0.018064734,
-0.006620602,
-0.0104497755,
-0.05611783,
-0.03181939,
-0.0111801755,
0.033410355,
0.0345385,
-0.044604994,
0.036216248,
-0.08654873,
0.03326572,
0.024544317,
-0.016141107,
-0.0012366171,
-0.044142168,
-0.020783845,
-0.00155... |
SEW
Overview
SEW (Squeezed and Efficient Wav2Vec) was proposed in Performance-Efficiency Trade-offs in Unsupervised Pre-training
for Speech Recognition by Felix Wu, Kwangyoun Kim, Jing Pan, Kyu Han, Kilian Q.
Weinberger, Yoav Artzi.
The abstract from the paper is the following:
This paper is a study of performance-eff... |
[
0.0038413713,
0.010452517,
-0.018840164,
-0.0018601636,
-0.0086439755,
-0.0100680245,
-0.06505054,
-0.021232566,
-0.0012335822,
0.023753133,
0.045512598,
-0.015066436,
0.040158175,
-0.07809483,
0.022158198,
0.019666113,
-0.028295849,
-0.019965163,
-0.043917663,
-0.023197753,
... | SEW is a speech model that accepts a float array corresponding to the raw waveform of the speech signal.
SEWForCTC is fine-tuned using connectionist temporal classification (CTC) so the model output has to be decoded using
[Wav2Vec2CTCTokenizer].
Resources
Audio classification task guide
Automatic speech recognitio... |
[
-0.0015834875,
0.007319992,
-0.031909414,
0.025390578,
-0.016995529,
-0.0012248489,
-0.024801694,
-0.004895972,
0.013852519,
0.044152766,
0.021377936,
-0.009593366,
0.027335273,
-0.05560181,
0.022870695,
0.028074805,
-0.011613383,
-0.021829873,
-0.052041102,
-0.04018121,
-0.0... | Resources
Audio classification task guide
Automatic speech recognition task guide
SEWConfig
[[autodoc]] SEWConfig
SEWModel
[[autodoc]] SEWModel
- forward
SEWForCTC
[[autodoc]] SEWForCTC
- forward
SEWForSequenceClassification
[[autodoc]] SEWForSequenceClassification
- forward |
[
0.010894081,
-0.010303042,
-0.00164451,
-0.0049034306,
-0.010390603,
-0.039782,
-0.006450346,
-0.0230578,
0.013856569,
0.05049366,
-0.0062825205,
-0.014425718,
0.022474058,
-0.03219336,
0.0119448155,
-0.0012997375,
0.007975372,
-0.036717355,
-0.04629072,
0.010492758,
-0.00028... |
AltCLIP
Overview
The AltCLIP model was proposed in AltCLIP: Altering the Language Encoder in CLIP for Extended Language Capabilities by Zhongzhi Chen, Guang Liu, Bo-Wen Zhang, Fulong Ye, Qinghong Yang, Ledell Wu. AltCLIP
(Altering the Language Encoder in CLIP) is a neural network trained on a variety of image-text and... |
[
-0.019808797,
-0.005590483,
0.011276342,
0.009684301,
-0.010535345,
-0.015421516,
-0.030813685,
-0.009522896,
0.04516406,
0.04014583,
0.020263666,
0.00096384477,
0.004277233,
-0.03603734,
-0.019383276,
0.07072475,
0.020630496,
-0.06256645,
-0.027248101,
0.016624717,
0.0077401... | This model is based on CLIPModel, use it like you would use the original CLIP. |
[
-0.008948653,
-0.03193732,
-0.0063759997,
-0.004578851,
-0.026555989,
0.013385891,
-0.009137472,
0.034742624,
0.0048755663,
0.06284962,
-0.000046730496,
-0.007896664,
0.02412832,
-0.020365436,
0.0141209345,
0.03641502,
0.0123608755,
-0.034823544,
-0.068406284,
-0.005442022,
-... | AltCLIPConfig
[[autodoc]] AltCLIPConfig
- from_text_vision_configs
AltCLIPTextConfig
[[autodoc]] AltCLIPTextConfig
AltCLIPVisionConfig
[[autodoc]] AltCLIPVisionConfig
AltCLIPProcessor
[[autodoc]] AltCLIPProcessor
AltCLIPModel
[[autodoc]] AltCLIPModel
- forward
- get_text_features
- get_image_features
Al... |
[
0.040467415,
0.016161153,
0.032035507,
-0.028149374,
0.00022260573,
-0.042102173,
-0.0140388375,
-0.010841022,
0.015917374,
0.05434851,
0.021868464,
-0.012963339,
0.006829414,
-0.03177739,
0.004244633,
0.013149759,
0.027016517,
-0.028493533,
-0.04324937,
-0.028378814,
0.00753... |
from PIL import Image
import requests
from transformers import AltCLIPModel, AltCLIPProcessor
model = AltCLIPModel.from_pretrained("BAAI/AltCLIP")
processor = AltCLIPProcessor.from_pretrained("BAAI/AltCLIP")
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=Tru... |
[
0.027071835,
-0.01651721,
0.006778556,
-0.028795617,
-0.020558205,
0.0010482211,
-0.043631434,
-0.025701288,
-0.026280591,
0.06912078,
0.019696314,
-0.023850344,
0.017449748,
-0.023454722,
0.000554577,
-0.0058318893,
-0.03696238,
-0.043857504,
-0.10031839,
0.007594526,
0.0225... |
Encoder Decoder Models
Overview
The [EncoderDecoderModel] can be used to initialize a sequence-to-sequence model with any
pretrained autoencoding model as the encoder and any pretrained autoregressive model as the decoder.
The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for se... |
[
0.01520414,
-0.0109082535,
-0.0011438964,
-0.04618616,
-0.014479792,
0.010628554,
-0.02036781,
-0.030379593,
-0.029217767,
0.050833464,
0.016695866,
-0.010614211,
0.023064394,
-0.02699452,
0.017140517,
-0.00093232933,
-0.05702987,
-0.040391374,
-0.10786333,
0.0010434916,
0.00... |
Initialising EncoderDecoderModel from a pretrained encoder and a pretrained decoder.
[EncoderDecoderModel] can be initialized from a pretrained encoder checkpoint and a pretrained decoder checkpoint. Note that any pretrained auto-encoding model, e.g. BERT, can serve as the encoder and both pretrained auto-encoding mo... |
[
0.018132193,
-0.017477456,
-0.024452405,
-0.03174804,
-0.0043994286,
-0.0028945366,
-0.0077833473,
0.021633029,
-0.025187314,
0.06568744,
0.038028166,
-0.028354099,
0.03826868,
-0.046499655,
0.03385923,
0.0022514919,
-0.02747221,
-0.047648784,
-0.06996328,
0.023289913,
0.0041... | from transformers import BertConfig, EncoderDecoderConfig, EncoderDecoderModel
config_encoder = BertConfig()
config_decoder = BertConfig()
config = EncoderDecoderConfig.from_encoder_decoder_configs(config_encoder, config_decoder)
model = EncoderDecoderModel(config=config) |
[
0.013597869,
-0.019720003,
-0.026288755,
-0.022399724,
-0.00568582,
-0.0077574505,
-0.012189298,
0.011014343,
-0.035124965,
0.058816455,
0.026013913,
-0.0203384,
0.019486386,
-0.03737868,
0.009722579,
0.013962037,
-0.032651376,
-0.06827106,
-0.061729793,
0.018510692,
-0.00247... | from transformers import EncoderDecoderModel, BertTokenizer
tokenizer = BertTokenizer.from_pretrained("google-bert/bert-base-uncased")
model = EncoderDecoderModel.from_encoder_decoder_pretrained("google-bert/bert-base-uncased", "google-bert/bert-base-uncased") |
[
0.029955532,
0.008409739,
-0.02294372,
0.045443654,
0.0064903656,
-0.0016392333,
-0.020783963,
0.0024241793,
0.0038498407,
0.055236522,
0.025399333,
-0.015887527,
-0.0016882346,
-0.027130097,
-0.019822426,
-0.025576849,
-0.027440747,
-0.040739525,
-0.03656794,
0.015887527,
-0... |
from transformers import AutoTokenizer, EncoderDecoderModel
load a fine-tuned seq2seq model and corresponding tokenizer
model = EncoderDecoderModel.from_pretrained("patrickvonplaten/bert2bert_cnn_daily_mail")
tokenizer = AutoTokenizer.from_pretrained("patrickvonplaten/bert2bert_cnn_daily_mail")
let's perform inferenc... |
[
0.013824389,
-0.018501371,
-0.022411149,
-0.010416242,
-0.035202768,
-0.0054404945,
-0.0208915,
-0.01587518,
-0.001072423,
0.05155007,
0.035055228,
-0.02115707,
0.032753624,
-0.018929234,
-0.006749902,
-0.0014680114,
-0.003382328,
-0.014119467,
-0.07282517,
0.0112424595,
0.01... | Loading an existing EncoderDecoderModel checkpoint and perform inference.
To load fine-tuned checkpoints of the EncoderDecoderModel class, [EncoderDecoderModel] provides the from_pretrained() method just like any other model architecture in Transformers.
To perform inference, one uses the [generate] method, which allow... |
[
0.023917053,
-0.050132442,
-0.010328145,
0.021661812,
-0.021446344,
0.0021241647,
-0.020268446,
-0.012856314,
-0.006866277,
0.047144607,
0.019866237,
-0.02062756,
0.045507044,
-0.03953137,
0.000091967086,
0.02759439,
-0.01315797,
0.005221531,
-0.07475336,
-0.011082286,
0.0109... | Loading a PyTorch checkpoint into TFEncoderDecoderModel.
[TFEncoderDecoderModel.from_pretrained] currently doesn't support initializing the model from a
pytorch checkpoint. Passing from_pt=True to this method will throw an exception. If there are only pytorch
checkpoints for a particular encoder-decoder model, a workar... |
[
0.036706664,
0.012520705,
-0.012605544,
-0.04165556,
-0.02837838,
-0.014945664,
0.022114493,
-0.01137539,
-0.008900942,
0.043210927,
0.013948815,
0.012237911,
-0.00591393,
-0.028661175,
-0.0011638742,
0.005100897,
-0.008794894,
-0.023853676,
-0.08817518,
-0.034783665,
0.02450... | Training
Once the model is created, it can be fine-tuned similar to BART, T5 or any other encoder-decoder model.
As you can see, only 2 inputs are required for the model in order to compute a loss: input_ids (which are the
input_ids of the encoded input sequence) and labels (which are the input_ids of the encoded
targe... |
[
0.039817233,
-0.03558199,
-0.004227785,
0.015091776,
0.0097753545,
0.010707406,
-0.022041151,
-0.0029862926,
0.0032920055,
0.025873747,
0.022488534,
-0.03567147,
0.07259562,
-0.031883612,
0.0050890003,
-0.0065951953,
0.00061095966,
-0.008418288,
-0.058428437,
-0.025933398,
0.... |
a workaround to load from pytorch checkpoint
from transformers import EncoderDecoderModel, TFEncoderDecoderModel
_model = EncoderDecoderModel.from_pretrained("patrickvonplaten/bert2bert-cnn_dailymail-fp16")
_model.encoder.save_pretrained("./encoder")
_model.decoder.save_pretrained("./decoder")
model = TFEncoderDecode... |
[
0.017507529,
-0.0066568134,
0.0024738899,
0.020640146,
0.019981418,
0.02646623,
-0.03688877,
0.035981193,
0.007355797,
-0.00027721474,
0.019835034,
-0.00015724846,
-0.009632069,
-0.05211271,
0.00072871795,
0.02317259,
-0.051439345,
-0.033785433,
-0.03068209,
-0.00060154684,
-... |
from transformers import BertTokenizer, EncoderDecoderModel
tokenizer = BertTokenizer.from_pretrained("google-bert/bert-base-uncased")
model = EncoderDecoderModel.from_encoder_decoder_pretrained("google-bert/bert-base-uncased", "google-bert/bert-base-uncased")
model.config.decoder_start_token_id = tokenizer.cls_token... |
[
-0.0088731935,
-0.021819098,
-0.0034953943,
0.019607797,
-0.04159484,
-0.018950006,
-0.021917067,
0.0069977865,
-0.020223603,
0.04327431,
0.039607473,
-0.0010916546,
0.02127327,
-0.026605584,
-0.008341362,
-0.0018264223,
-0.00044567153,
-0.025373973,
-0.058557477,
0.017144576,
... | TFEncoderDecoderModel
[[autodoc]] TFEncoderDecoderModel
- call
- from_encoder_decoder_pretrained
FlaxEncoderDecoderModel
[[autodoc]] FlaxEncoderDecoderModel
- call
- from_encoder_decoder_pretrained |
[
0.04420606,
0.005605369,
-0.0068719145,
0.05016968,
-0.029021988,
-0.030541841,
-0.04562459,
0.002093419,
0.00766441,
0.055872753,
0.019208068,
0.016776301,
0.016935524,
-0.042903326,
-0.010863342,
0.019671261,
0.0016845056,
-0.012209499,
-0.026706018,
0.014851151,
0.01891857... |
Usage of SigLIP is similar to CLIP. The main difference is the training loss, which does not require a global view of all the pairwise similarities of images and texts within a batch. One needs to apply the sigmoid activation function to the logits, rather than the softmax.
Training is not yet supported. If you want ... |
[
0.019890638,
-0.02359431,
-0.020008683,
0.0033329362,
-0.020613667,
-0.004769769,
-0.020436598,
0.00830744,
-0.015021268,
0.05028731,
0.00024600464,
0.029570356,
0.025866684,
-0.011826667,
-0.018311782,
-0.002012304,
-0.0012330204,
-0.021808876,
-0.101932146,
0.002386729,
0.0... | Detailed colab for training.
This model was contributed by thomwolf. This model's TensorFlow and Flax versions
were contributed by ydshieh.
EncoderDecoderConfig
[[autodoc]] EncoderDecoderConfig
EncoderDecoderModel
[[autodoc]] EncoderDecoderModel
- forward
- from_encoder_decoder_pretrained
TFEncoderDecoderMode... |
[
0.03152871,
-0.014088089,
0.0017256233,
0.025717653,
-0.06913668,
-0.04476004,
-0.025896456,
0.022603523,
0.017626874,
0.06174621,
0.0069471938,
-0.020025797,
0.02537495,
-0.017746076,
-0.011972268,
0.025687853,
0.00907419,
-0.030634703,
-0.037309967,
-0.005807332,
0.02589645... | SigLIP evaluation results compared to CLIP. Taken from the original paper.
This model was contributed by nielsr.
The original code can be found here.
Usage example
There are 2 main ways to use SigLIP: either using the pipeline API, which abstracts away all the complexity for you, or by using the SiglipModel class yours... |
[
0.025147907,
0.008228219,
0.0028291396,
-0.02704503,
-0.008537052,
-0.053001788,
-0.02128013,
0.0060516745,
-0.006264917,
0.056796033,
0.020397747,
-0.01904476,
0.031089284,
-0.02676561,
-0.010184167,
0.021853678,
-0.009412082,
-0.027339157,
-0.042619083,
-0.022427227,
0.0190... |
from transformers import pipeline
from PIL import Image
import requests
load pipe
image_classifier = pipeline(task="zero-shot-image-classification", model="google/siglip-base-patch16-224")
load image
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
... |
[
0.052718427,
0.0054133185,
-0.023187172,
0.02344034,
-0.0166346,
-0.059330568,
-0.021414999,
-0.016738845,
-0.031065151,
0.05099093,
0.009739506,
-0.023529693,
0.020298084,
-0.029158948,
-0.0037640063,
0.025555033,
0.002751336,
-0.007855642,
-0.029516362,
-0.011005344,
0.0212... |
SigLIP
Overview
The SigLIP model was proposed in Sigmoid Loss for Language Image Pre-Training by Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer. SigLIP proposes to replace the loss function used in CLIP by a simple pairwise sigmoid loss. This results in better performance in terms of zero-shot classifi... |
[
0.05619724,
-0.009470941,
0.013615413,
0.0011913487,
-0.028861683,
-0.024582552,
-0.019061578,
-0.0056855567,
0.012448377,
0.06691003,
0.02238314,
0.0040995856,
0.010106825,
-0.041803807,
-0.02718594,
0.03058231,
-0.001644884,
-0.022861924,
-0.030612236,
-0.014438322,
0.01874... |
from PIL import Image
import requests
from transformers import AutoProcessor, AutoModel
import torch
model = AutoModel.from_pretrained("google/siglip-base-patch16-224")
processor = AutoProcessor.from_pretrained("google/siglip-base-patch16-224")
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Im... |
[
0.015180052,
-0.024938656,
-0.019907555,
-0.042243917,
-0.0113850385,
0.006111778,
0.0019228066,
0.011594668,
0.0373863,
0.023290537,
0.022986935,
-0.0126861865,
0.004062471,
-0.0498484,
-0.0047925594,
0.044557065,
-0.03177691,
-0.0373863,
-0.07240162,
0.0025553086,
-0.017637... | Using the model yourself
If you want to do the pre- and postprocessing yourself, here's how to do that:
thon |
[
0.027113186,
-0.0122654885,
-0.008771521,
0.0136231445,
-0.041821122,
-0.016385043,
-0.032370776,
0.014242076,
-0.0039431914,
0.04429685,
-0.003212786,
-0.0070944172,
0.039052572,
-0.02800498,
-0.009789763,
0.022587666,
0.009650005,
-0.04094264,
-0.050898783,
-0.035724983,
0.... |
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.
SiglipConfig
[[autodoc]] SiglipConfig
- from_text_vision_configs
SiglipTextConfig
[[aut... |
[
0.04217623,
-0.002925745,
-0.010942215,
0.022396347,
-0.0045823636,
-0.051987965,
0.019282188,
0.027970549,
-0.011226613,
0.034525923,
-0.016608845,
0.016964344,
0.038649693,
-0.049599018,
-0.0018085939,
0.019879423,
0.015172636,
-0.01315341,
-0.028496685,
-0.022879822,
-0.01... | Resources
A list of official Hugging Face and community (indicated by ๐) resources to help you get started with SigLIP.
Zero-shot image classification task guide
Demo notebooks for SigLIP can be found here. ๐ |
[
0.028849749,
0.031684697,
-0.020761814,
0.01288233,
-0.012792001,
-0.032462917,
0.011200817,
-0.005148763,
-0.011013211,
0.043913875,
0.018468842,
-0.0054579666,
0.010179403,
-0.052919,
0.009755551,
0.009373389,
-0.04021733,
-0.038966615,
-0.035492416,
0.01635653,
-0.00098406... | from transformers import PLBartForConditionalGeneration, PLBartTokenizer
tokenizer = PLBartTokenizer.from_pretrained("uclanlp/plbart-base", src_lang="en_XX", tgt_lang="python")
example_python_phrase = "def maximum(a,b,c):NEW_LINE_INDENTreturn max([a,b,c])"
expected_translation_english = "Returns the maximum value of a ... |
[
-0.0060795527,
-0.018298702,
-0.009419554,
0.028956683,
0.011528634,
-0.04278204,
0.011130835,
-0.012804588,
-0.026765043,
0.016482342,
-0.027380504,
0.028971694,
0.015326477,
-0.006608699,
-0.017232904,
-0.024978705,
-0.015941938,
-0.022171604,
-0.0500775,
0.03083309,
-0.016... | Generation
While generating the target text set the decoder_start_token_id to the target language id. The following
example shows how to translate Python to English using the uclanlp/plbart-python-en_XX model.
thon |
[
0.029435847,
-0.01741215,
-0.009229155,
-0.018845249,
0.019131867,
-0.03499627,
0.005123328,
-0.04895465,
-0.015835742,
0.060878035,
0.005954525,
-0.010905881,
-0.0030722055,
-0.048868667,
-0.016509296,
-0.026254369,
-0.035397537,
-0.007573927,
-0.06987789,
0.0016292541,
0.00... |
PLBart
Overview
The PLBART model was proposed in Unified Pre-training for Program Understanding and Generation by Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray, Kai-Wei Chang.
This is a BART-like model which can be used to perform code-summarization, code-generation, and code-translation tasks. The pre-trained m... |
[
0.040285084,
0.02767656,
-0.023718728,
0.022036647,
-0.009922853,
-0.029485855,
0.010869905,
0.0014612178,
-0.020736217,
0.039097734,
0.012905362,
-0.0008034931,
0.020849299,
-0.053854797,
0.0077955173,
0.005894344,
-0.0385606,
-0.04803113,
-0.040624328,
0.011166743,
-0.00613... |
from transformers import PLBartForConditionalGeneration, PLBartTokenizer
tokenizer = PLBartTokenizer.from_pretrained("uclanlp/plbart-python-en_XX", src_lang="python", tgt_lang="en_XX")
example_python_phrase = "def maximum(a,b,c):NEW_LINE_INDENTreturn max([a,b,c])"
inputs = tokenizer(example_python_phrase, return_tens... |
[
0.008179089,
-0.01042257,
-0.020947699,
-0.010871266,
0.012480162,
0.010762297,
-0.015935121,
-0.03953654,
-0.012967317,
0.046100322,
-0.01510183,
-0.013499343,
0.009781575,
-0.04584392,
-0.0001245933,
-0.014858251,
-0.024178311,
-0.023780894,
-0.06599679,
-0.018819597,
-0.00... | Resources
Text classification task guide
Causal language modeling task guide
Translation task guide
Summarization task guide |
[
0.020988088,
0.01947008,
-0.00479822,
0.0023166097,
-0.016500069,
-0.0046695196,
-0.0061908257,
0.00068516535,
-0.0139788585,
0.055809833,
0.04142177,
-0.015048062,
-0.004042517,
-0.049130604,
-0.009365439,
0.010474244,
-0.027852116,
-0.025713706,
-0.052061018,
0.003154813,
0... | PLBartConfig
[[autodoc]] PLBartConfig
PLBartTokenizer
[[autodoc]] PLBartTokenizer
- build_inputs_with_special_tokens
PLBartModel
[[autodoc]] PLBartModel
- forward
PLBartForConditionalGeneration
[[autodoc]] PLBartForConditionalGeneration
- forward
PLBartForSequenceClassification
[[autodoc]] PLBartForSequence... |
[
0.022623897,
0.008070202,
-0.009755607,
0.044701174,
-0.028879631,
-0.0033081754,
0.020209668,
-0.008237224,
-0.010431287,
0.040388968,
-0.003955386,
-0.0002270456,
-0.022092463,
-0.003771282,
-0.010226305,
-0.045247793,
-0.03376882,
-0.021986175,
-0.014234834,
0.028818896,
0... | T5 |
[
0.01854029,
-0.013310621,
-0.023269245,
0.014019963,
-0.004245629,
-0.010160301,
-0.0032998377,
-0.026009258,
-0.027608758,
0.03813764,
0.009158875,
0.010925279,
-0.0008080082,
-0.037136212,
-0.022392998,
-0.026064893,
-0.031489283,
-0.022351272,
-0.070656165,
-0.007927956,
0... |
T5 is an encoder-decoder model pre-trained on a multi-task mixture of unsupervised and supervised tasks and for which
each task is converted into a text-to-text format. T5 works well on a variety of tasks out-of-the-box by prepending a
different prefix to the input corresponding to each task, e.g., for translation: t... |
[
0.044336013,
-0.006856869,
-0.0017993394,
0.027036276,
-0.014546849,
-0.020342406,
0.015227827,
-0.0330057,
-0.023848718,
0.05094295,
0.005900602,
-0.012170671,
0.016184093,
-0.021631919,
-0.008150003,
-0.015619027,
-0.00008099065,
0.022211473,
-0.06925691,
-0.00045458903,
0.... |
Overview
The T5 model was presented in Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer by Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang,
Michael Matena, Yanqi Zhou, Wei Li, Peter J. Liu.
The abstract from the paper is the following:
Transfer learning, where a... |
[
0.017580988,
-0.016759314,
0.014400543,
0.008379657,
-0.028503582,
-0.010610926,
-0.029523592,
0.007395065,
-0.009045496,
0.023998544,
0.049442098,
0.025882727,
0.014166791,
-0.046552073,
-0.052813794,
-0.013210532,
-0.013132615,
-0.026392732,
-0.080240704,
-0.014173874,
0.02... | Self-supervised training uses corrupted tokens, by randomly removing 15% of the tokens and replacing them with individual sentinel tokens (if several consecutive tokens are marked for removal, the whole group is replaced with a single sentinel token). The input of the encoder is the corrupted sentence, the input of the... |
[
0.06702205,
0.016798256,
-0.00069725583,
-0.0007978815,
-0.054341428,
0.020944389,
0.019890046,
0.006482787,
-0.0149887735,
0.032570664,
0.026358586,
0.035106786,
-0.03151632,
-0.017425163,
-0.033710495,
-0.004025027,
-0.0149887735,
-0.019177651,
-0.033966955,
-0.0002860708,
... | T5 uses relative scalar embeddings. Encoder input padding can be done on the left and on the right.
See the training, inference and resources sections below for all details regarding usage.
T5 comes in different sizes:
google-t5/t5-small
google-t5/t5-base
google-t5/t5-large
google-t5/t5-3b
google-t5/t5-11b.
Bas... |
[
0.04795909,
-0.015071599,
-0.012730878,
0.01567329,
-0.0088565815,
-0.01778654,
-0.003136859,
-0.017434333,
-0.025359029,
0.055061966,
0.014873481,
0.034046844,
-0.013750816,
-0.03310762,
-0.042118292,
-0.0070698564,
-0.022614736,
-0.032960866,
-0.01699407,
-0.025667211,
0.02... | mT5: mT5 is a multilingual T5 model. It is pre-trained on the mC4 corpus, which includes 101 languages. Refer to
the documentation of mT5 which can be found here.
byT5: byT5 is a T5 model pre-trained on byte sequences rather than SentencePiece subword token sequences. Refer
to the documentation of byT5 which can b... |
[
0.02419808,
0.010474665,
-0.00023150066,
-0.0047165127,
-0.050581414,
-0.010263423,
-0.015675576,
0.008078166,
-0.020206343,
0.067597285,
0.025902579,
0.01583583,
-0.0057581523,
-0.01654968,
-0.04198607,
0.010365402,
-0.018225044,
-0.011756683,
-0.012332134,
-0.019273967,
0.0... | UL2: UL2 is a T5 like model pretrained on various denoising objectives
Flan-T5: Flan is a pretraining methods that is based on prompting. The Flan-T5 are T5 models trained on the Flan collection of
datasets which include: taskmaster2, djaym7/wiki_dialog, deepmind/code_contests, lambada, gsm8k, aqua_rat, esnli, qu... |
[
0.05520825,
-0.015011747,
-0.0021971075,
0.01625058,
-0.0048387377,
-0.0049043233,
0.0047440035,
-0.0077317785,
-0.0033594249,
0.062495507,
0.031480946,
0.01880112,
-0.013299242,
-0.019078035,
-0.0417414,
-0.0034614466,
-0.010151147,
-0.01935495,
0.022284428,
-0.020360593,
0.... | FLan-UL2 : the UL2 model finetuned using the "Flan" prompt tuning and dataset collection.
UMT5: UmT5 is a multilingual T5 model trained on an improved and refreshed mC4 multilingual corpus, 29 trillion characters across 107 language, using a new sampling method, UniMax. Refer to
the documentation of mT5 which can be... |
[
0.066378035,
-0.008364987,
-0.023733532,
0.017976254,
-0.02511528,
0.0067292424,
0.019805036,
0.002392657,
-0.0069493735,
0.021186784,
0.0418588,
0.04990544,
-0.011717754,
-0.010390194,
-0.033812158,
0.009218418,
-0.03156343,
0.0019049818,
-0.048903,
-0.015768168,
-0.00985510... | T5 comes in different sizes:
google-t5/t5-small
google-t5/t5-base
google-t5/t5-large
google-t5/t5-3b
google-t5/t5-11b.
Based on the original T5 model, Google has released some follow-up works:
T5v1.1: T5v1.1 is an improved version of T5 with some architectural tweaks, and is pre-trained on C4 only without
mixi... |
[
0.026096642,
0.021543864,
-0.026825681,
0.026215669,
-0.020814825,
-0.014774211,
0.028551571,
0.0075768046,
-0.0066506267,
0.04264138,
0.011724147,
0.017898666,
0.0039204475,
-0.021171905,
-0.00952215,
0.01587521,
-0.0204875,
-0.044635076,
-0.07082099,
-0.002475387,
-0.000884... | from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google-t5/t5-small")
model = T5ForConditionalGeneration.from_pretrained("google-t5/t5-small")
input_ids = tokenizer("The walks in park", return_tensors="pt").input_ids
labels = tokenizer(" cute dog the ", return... |
[
0.051499404,
-0.0018875378,
-0.003082182,
0.017830918,
-0.019223532,
-0.044154048,
0.017721692,
0.019332755,
-0.020397697,
0.01646561,
0.021053044,
0.025585866,
0.007946091,
-0.028507624,
-0.029217582,
-0.009625419,
0.010000878,
-0.048878014,
-0.024985129,
0.0049458267,
0.010... | If you're interested in pre-training T5 on a new corpus, check out the run_t5_mlm_flax.py script in the Examples
directory.
Supervised training |
[
0.03225228,
0.023581665,
-0.009878198,
0.017521238,
-0.019216357,
-0.019051345,
-0.0198314,
-0.007590536,
-0.039182767,
0.037772667,
-0.0034952469,
0.019066347,
0.010748259,
-0.03240229,
-0.0077555478,
-0.029972116,
-0.024556734,
-0.01684619,
-0.059554204,
-0.0076805423,
0.01... |
Training
T5 is an encoder-decoder model and converts all NLP problems into a text-to-text format. It is trained using teacher
forcing. This means that for training, we always need an input sequence and a corresponding target sequence. The input
sequence is fed to the model using input_ids. The target sequence is shif... |
[
0.006864921,
0.040836874,
-0.0049517946,
-0.047231596,
-0.0044815945,
-0.013917922,
-0.07151743,
-0.023627553,
-0.045139205,
0.05172201,
0.023427717,
0.025813984,
0.035382554,
-0.045139205,
-0.020148072,
0.012460302,
-0.031221284,
-0.046761397,
-0.047795836,
-0.043446485,
-0.... | Unsupervised denoising training |
[
-0.013109629,
0.024101919,
0.03187008,
-0.035692286,
-0.012779654,
-0.019413525,
-0.061155353,
0.0010002365,
-0.046938933,
0.041136872,
-0.01105416,
0.06000044,
0.01644375,
-0.029807735,
-0.02054094,
-0.01671873,
-0.036214747,
-0.010710436,
-0.10416208,
-0.011088532,
0.032640... | Supervised training
In this setup, the input sequence and output sequence are a standard sequence-to-sequence input-output mapping.
Suppose that we want to fine-tune the model for translation for example, and we have a training example: the input
sequence "The house is wonderful." and output sequence "Das Haus ist wun... |
[
0.009282886,
0.008919828,
-0.01146835,
0.027635094,
-0.012023615,
-0.015817923,
-0.0029240379,
-0.0054458645,
-0.010236802,
0.043994043,
0.017982032,
0.04333912,
-0.013062957,
0.0062396084,
-0.05589664,
0.0074747163,
-0.03633424,
-0.04687003,
-0.04163061,
0.01782542,
-0.01062... |
In this setup, spans of the input sequence are masked by so-called sentinel tokens (a.k.a unique mask tokens) and
the output sequence is formed as a concatenation of the same sentinel tokens and the real masked tokens. Each
sentinel token represents a unique mask token for this sentence and should start with <extra_i... |
[
0.057126958,
0.026929285,
-0.02512748,
0.012850073,
-0.041818608,
-0.0028231752,
0.008694751,
-0.015517861,
-0.011474278,
0.029778648,
0.0132830655,
-0.0055834968,
0.011048269,
-0.033047035,
-0.005049241,
-0.038689896,
-0.004277538,
-0.022697141,
-0.06263014,
0.015853079,
0.0... | Additional training tips:
T5 models need a slightly higher learning rate than the default one set in the Trainer when using the AdamW
optimizer. Typically, 1e-4 and 3e-4 work well for most problems (classification, summarization, translation, question
answering, question generation). Note that T5 was pre-trained using... |
[
0.018717604,
0.02166986,
-0.025536267,
0.024232479,
-0.022494094,
-0.020860612,
0.021534987,
0.012423454,
-0.029028023,
0.021295208,
0.012168691,
0.0133675765,
0.008422173,
-0.036116436,
0.009725961,
0.0040237606,
-0.02068078,
-0.047505848,
-0.06593872,
-0.009860836,
0.009995... |
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google-t5/t5-small")
model = T5ForConditionalGeneration.from_pretrained("google-t5/t5-small")
input_ids = tokenizer("translate English to German: The house is wonderful.", return_tensors="pt").input_ids
labels = ... |
[
0.02260807,
0.021987218,
-0.017959258,
0.011856744,
-0.024425196,
-0.030285425,
0.01155389,
0.02907401,
-0.038492776,
-0.0014726288,
-0.008903915,
0.014741431,
0.016157275,
-0.052787498,
0.029028581,
-0.021078657,
-0.023289492,
-0.0436413,
-0.06693079,
0.023198636,
0.01194002... | from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google-t5/t5-small")
model = T5ForConditionalGeneration.from_pretrained("google-t5/t5-small")
input_ids = tokenizer("translate English to German: The house is wonderful.", return_tensors="pt").input_ids
outputs = m... |
[
0.02316965,
-0.0011720556,
0.0038848417,
0.007520232,
-0.009288403,
-0.0066324775,
-0.0004901907,
-0.0024816764,
-0.034923222,
0.05934013,
0.025488082,
0.019912107,
-0.002089157,
-0.03495257,
-0.021306101,
-0.014387487,
-0.007168065,
-0.027630432,
-0.06362483,
0.0071130386,
0... |
As you can see, only 2 inputs are required for the model in order to compute a loss: input_ids (which are the
input_ids of the encoded input sequence) and labels (which are the input_ids of the encoded
target sequence). The model will automatically create the decoder_input_ids based on the labels, by
shifting them on... |
[
0.027996294,
0.011167582,
-0.024918247,
0.040091928,
-0.02197941,
-0.00039683972,
0.015142746,
-0.019829419,
-0.009682696,
0.036194105,
0.017988779,
0.011275855,
0.012033766,
-0.028228307,
-0.0138357375,
0.0120415,
-0.02154632,
-0.026480472,
-0.06601557,
0.0011987364,
0.01210... |
from transformers import T5Tokenizer, T5ForConditionalGeneration
import torch
tokenizer = T5Tokenizer.from_pretrained("google-t5/t5-small")
model = T5ForConditionalGeneration.from_pretrained("google-t5/t5-small")
the following 2 hyperparameters are task-specific
max_source_length = 512
max_target_length = 128
Suppose... |
[
0.022100113,
0.025211366,
-0.025152938,
0.03491029,
-0.025211366,
-0.030411392,
0.0056418832,
0.00024854412,
-0.009720837,
0.02950577,
-0.009005102,
0.009457914,
0.028600147,
-0.056090176,
-0.007160992,
-0.008004536,
-0.03070353,
-0.05702501,
-0.050218236,
0.007431218,
-0.006... |
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google-t5/t5-small")
model = T5ForConditionalGeneration.from_pretrained("google-t5/t5-small")
task_prefix = "translate English to German: "
use different length sentences to test batching
sentences = ["The house ... |
[
0.03154134,
0.0008727633,
-0.0039570048,
0.011304704,
-0.0504088,
-0.029906927,
0.0059570125,
-0.008781396,
-0.011483916,
0.04997869,
0.010831583,
0.017605804,
0.017448097,
-0.02775638,
-0.046595164,
-0.011469578,
0.012595031,
-0.01819362,
-0.06153429,
0.002930119,
0.00573478... |
According to this forum post, task prefixes matter when
(1) doing multi-task training (2) your task is similar or related to one of the supervised tasks used in T5's
pre-training mixture (see Appendix D of the paper for the task prefixes
used).
If training on TPU, it is recommended to pad all examples of the dataset ... |
[
0.016557315,
0.002141217,
-0.011362582,
0.018431997,
-0.033286355,
-0.0020052667,
-0.012228371,
0.0008997763,
-0.018975798,
0.0452786,
0.039411273,
0.0018013414,
-0.021179624,
-0.02799145,
-0.008743751,
-0.015526954,
-0.026989711,
-0.049171075,
-0.021651873,
0.0017968693,
0.0... | Because T5 has been trained with the span-mask denoising objective,
it can be used to predict the sentinel (masked-out) tokens during inference.
The predicted tokens will then be placed between the sentinel tokens.
thon |
[
0.022783112,
0.008548855,
-0.00090866163,
0.0063839746,
-0.035468064,
-0.047696523,
0.0080854455,
0.012062461,
-0.011578303,
0.062414937,
0.018384187,
-0.019891994,
0.016101725,
-0.019988827,
-0.04974382,
-0.04255061,
0.016350722,
-0.031871457,
-0.014981245,
0.02054215,
0.006... | Note that T5 uses the pad_token_id as the decoder_start_token_id, so when doing generation without using
[~generation.GenerationMixin.generate], make sure you start it with the pad_token_id.
The example above only shows a single example. You can also do batched inference, like so:
thon |
[
0.02536165,
-0.011352083,
0.0058890735,
0.0013332559,
-0.015569395,
-0.016768152,
0.017721381,
-0.006701484,
-0.02768695,
0.054593984,
-0.0088606905,
0.011222097,
0.008477955,
-0.023527408,
0.0068928516,
-0.049134586,
-0.02140431,
-0.0434441,
-0.049625643,
0.015352753,
0.0016... | A notebook for how to finetune T5 for classification and multiple choice.
A notebook for how to finetune T5 for sentiment span extraction. ๐
A notebook for how to finetune T5 for named entity recognition. ๐
A notebook for Finetuning CodeT5 for generating docstrings from Ruby code. |
[
0.034631588,
0.020764278,
-0.028585734,
0.023332298,
0.0062292833,
0.0016756332,
0.048396178,
-0.011783544,
-0.04725157,
0.050450593,
0.022363788,
-0.00961907,
0.002138794,
-0.06268904,
-0.022261066,
-0.0018893292,
0.022745322,
-0.021453975,
-0.015921725,
0.015364098,
0.02005... |
Performance
If you'd like a faster training and inference performance, install NVIDIA APEX for NVIDIA GPUs, or ROCm APEX for AMD GPUs and then the model will automatically use apex.normalization.FusedRMSNorm instead of T5LayerNorm. The former uses an optimized fused kernel which is several times faster than the latte... |
[
0.023892235,
0.040225837,
-0.027686032,
0.020503882,
-0.012836646,
-0.027526751,
0.004778447,
0.008688086,
0.011714435,
0.03446274,
-0.0027638972,
0.01219228,
0.037156045,
-0.04384587,
-0.00920937,
0.013082809,
-0.025209928,
-0.04981169,
-0.06000571,
0.017419612,
-0.015783355... | from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google-t5/t5-small")
model = T5ForConditionalGeneration.from_pretrained("google-t5/t5-small")
input_ids = tokenizer("The walks in park", return_tensors="pt").input_ids
sequence_ids = model.generate(input_ids)
seq... |
[
0.06384319,
-0.026581822,
-0.019866876,
0.013634705,
-0.03540342,
-0.010752691,
0.0053434293,
-0.022909814,
0.0155658005,
0.07420088,
-0.0008658842,
0.0047728783,
-0.00089834345,
-0.0125374915,
0.002933217,
-0.022339264,
-0.02842514,
-0.061326914,
-0.07548828,
0.02362666,
-0.... |
A notebook to Finetune T5-base-dutch to perform Dutch abstractive summarization on a TPU.
A notebook for how to finetune T5 for summarization in PyTorch and track experiments with WandB. ๐
A blog post on Distributed Training: Train BART/T5 for Summarization using ๐ค Transformers and Amazon SageMaker.
[T5ForCondition... |
[
0.04855964,
0.010028297,
-0.020026747,
0.037337497,
-0.0450378,
-0.019967055,
-0.004036688,
-0.0013421428,
-0.024055975,
0.043993182,
0.019608902,
0.02301136,
0.029756583,
-0.023429206,
-0.001728277,
0.009468682,
-0.011445988,
-0.037576266,
-0.041665185,
0.011095296,
0.009214... | [FlaxT5ForConditionalGeneration] is supported by this example script for training T5 with a span-masked language model objective. The script also shows how to train a T5 tokenizer. [FlaxT5ForConditionalGeneration] is also supported by this notebook.
[T5ForConditionalGeneration] is supported by this example script and ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.