Transformers.js
Last updated
Last updated
State-of-the-art Machine Learning for the web. Run 🌍 Transformers directly in your browser, with no need for a server!
Transformers.js is designed to be functionally equivalent to BOINC AI’s python library, meaning you can run the same pretrained models using a very similar API. These models support common tasks in different modalities, such as:
📝 Natural Language Processing: text classification, named entity recognition, question answering, language modeling, summarization, translation, multiple choice, and text generation.
🖼️ Computer Vision: image classification, object detection, and segmentation.
🗣️ Audio: automatic speech recognition and audio classification.
🐙 Multimodal: zero-shot image classification.
Transformers.js uses to run models in the browser. The best part about it, is that you can easily your pretrained PyTorch, TensorFlow, or JAX models to ONNX using 🌍.
For more information, check out the full .
It’s super simple to translate from existing code! Just like the python library, we support the pipeline
API. Pipelines group together a pretrained model with preprocessing of inputs and postprocessing of outputs, making it the easiest way to run models with the library.
Copied
Copied
You can also use a different model by specifying the model id or path as the second argument to the pipeline
function. For example:
Copied
The documentation is organized into 4 sections:
GET STARTED provides a quick tour of the library and installation instructions to get up and running.
TUTORIALS are a great place to start if you’re a beginner! We also include sample applications for you to play around with!
DEVELOPER GUIDES show you how to use the library to achieve a specific goal.
API REFERENCE describes all classes and functions, as well as their available parameters and types.
Natural Language Processing
conversational
Generating conversational text that is relevant, coherent and knowledgable given a prompt.
❌
fill-mask
Masking some of the words in a sentence and predicting which words should replace those masks.
question-answering
Retrieve the answer to a question from a given text.
sentence-similarity
Determining how similar two texts are.
summarization
Producing a shorter version of a document while preserving its important information.
table-question-answering
Answering a question about information from a given table.
❌
text-classification
or sentiment-analysis
Assigning a label or class to a given text.
text-generation
Producing new text by predicting the next word in a sequence.
text2text-generation
Converting one text sequence into another text sequence.
token-classification
or ner
Assigning a label to each token in a text.
translation
Converting text from one language to another.
zero-shot-classification
Classifying text into classes that are unseen during training.
Vision
depth-estimation
Predicting the depth of objects present in an image.
❌
image-classification
Assigning a label or class to an entire image.
image-segmentation
Divides an image into segments where each pixel is mapped to an object. This task has multiple variants such as instance segmentation, panoptic segmentation and semantic segmentation.
image-to-image
Transforming a source image to match the characteristics of a target image or a target image domain.
❌
mask-generation
Generate masks for the objects in an image.
❌
object-detection
Identify objects of certain defined classes within an image.
n/a
Assigning a label or class to an entire video.
❌
n/a
Generating images with no condition in any context (like a prompt text or another image).
❌
Audio
audio-classification
Assigning a label or class to a given audio.
n/a
Generating audio from an input audio source.
❌
automatic-speech-recognition
Transcribing a given audio into text.
text-to-speech
or text-to-audio
Generating natural-sounding speech given text input.
Tabular
n/a
Classifying a target category (a group) based on set of attributes.
❌
n/a
Predicting a numerical value given a set of attributes.
❌
Multimodal
document-question-answering
Answering questions on document images.
feature-extraction
Transforming raw data into numerical features that can be processed while preserving the information in the original dataset.
image-to-text
Output text from a given image.
text-to-image
Generates images from input text.
❌
visual-question-answering
Answering open-ended questions based on an image.
❌
zero-shot-image-classification
Classifying images into classes that are unseen during training.
Reinforcement Learning
n/a
Learning from actions by interacting with an environment through trial and error and receiving rewards (negative or positive) as feedback.
❌
Here is the list of all tasks and architectures currently supported by Transformers.js. If you don’t see your task/model listed here or it is not yet supported, feel free to open up a feature request .
To find compatible models on the Hub, select the “transformers.js” library tag in the filter menu (or visit ). You can refine your search by selecting the task you’re interested in (e.g., ).
✅
✅
✅
✅
✅
✅
✅
✅
✅
✅
✅
✅
✅
✅
✅
✅
✅
✅
✅
✅
(from Google Research and the Toyota Technological Institute at Chicago) released with the paper , by Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut.
(from Facebook) released with the paper by Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Ves Stoyanov and Luke Zettlemoyer.
(from Microsoft) released with the paper by Hangbo Bao, Li Dong, Furu Wei.
(from Google) released with the paper by Jacob Devlin, Ming-Wei Chang, Kenton Lee and Kristina Toutanova.
(from Facebook) released with the paper by Stephen Roller, Emily Dinan, Naman Goyal, Da Ju, Mary Williamson, Yinhan Liu, Jing Xu, Myle Ott, Kurt Shuster, Eric M. Smith, Y-Lan Boureau, Jason Weston.
(from Facebook) released with the paper by Stephen Roller, Emily Dinan, Naman Goyal, Da Ju, Mary Williamson, Yinhan Liu, Jing Xu, Myle Ott, Kurt Shuster, Eric M. Smith, Y-Lan Boureau, Jason Weston.
(from BigScience workshop) released by the .
(from Inria/Facebook/Sorbonne) released with the paper by Louis Martin, Benjamin Muller, Pedro Javier Ortiz Suárez*, Yoann Dupont, Laurent Romary, Éric Villemonte de la Clergerie, Djamé Seddah and Benoît Sagot.
(from OpenAI) released with the paper by Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, Ilya Sutskever.
(from Salesforce) released with the paper by Erik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu, Huan Wang, Yingbo Zhou, Silvio Savarese, Caiming Xiong.
(from MetaAI) released with the paper by Baptiste Rozière, Jonas Gehring, Fabian Gloeckle, Sten Sootla, Itai Gat, Xiaoqing Ellen Tan, Yossi Adi, Jingyu Liu, Tal Remez, Jérémy Rapin, Artyom Kozhevnikov, Ivan Evtimov, Joanna Bitton, Manish Bhatt, Cristian Canton Ferrer, Aaron Grattafiori, Wenhan Xiong, Alexandre Défossez, Jade Copet, Faisal Azhar, Hugo Touvron, Louis Martin, Nicolas Usunier, Thomas Scialom, Gabriel Synnaeve.
(from Microsoft) released with the paper by Pengcheng He, Xiaodong Liu, Jianfeng Gao, Weizhu Chen.
(from Microsoft) released with the paper by Pengcheng He, Xiaodong Liu, Jianfeng Gao, Weizhu Chen.
(from Facebook) released with the paper by Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, Hervé Jégou.
(from Facebook) released with the paper by Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, Sergey Zagoruyko.
(from BOINC AI), released together with the paper by Victor Sanh, Lysandre Debut and Thomas Wolf. The same method has been applied to compress GPT2 into , RoBERTa into , Multilingual BERT into and a German version of DistilBERT.
(from NAVER), released together with the paper by Geewook Kim, Teakgyu Hong, Moonbin Yim, Jeongyeon Nam, Jinyoung Park, Jinyeong Yim, Wonseok Hwang, Sangdoo Yun, Dongyoon Han, Seunghyun Park.
(from Google AI) released in the repository by Hyung Won Chung, Le Hou, Shayne Longpre, Barret Zoph, Yi Tay, William Fedus, Eric Li, Xuezhi Wang, Mostafa Dehghani, Siddhartha Brahma, Albert Webson, Shixiang Shane Gu, Zhuyun Dai, Mirac Suzgun, Xinyun Chen, Aakanksha Chowdhery, Sharan Narang, Gaurav Mishra, Adams Yu, Vincent Zhao, Yanping Huang, Andrew Dai, Hongkun Yu, Slav Petrov, Ed H. Chi, Jeff Dean, Jacob Devlin, Adam Roberts, Denny Zhou, Quoc V. Le, and Jason Wei
(from EleutherAI) released in the repository by Sid Black, Stella Biderman, Leo Gao, Phil Wang and Connor Leahy.
(from EleutherAI) released with the paper by Sid Black, Stella Biderman, Eric Hallahan, Quentin Anthony, Leo Gao, Laurence Golding, Horace He, Connor Leahy, Kyle McDonell, Jason Phang, Michael Pieler, USVSN Sai Prashanth, Shivanshu Purohit, Laria Reynolds, Jonathan Tow, Ben Wang, Samuel Weinbach
(from OpenAI) released with the paper by Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodeiand Ilya Sutskever.
(from EleutherAI) released in the repository by Ben Wang and Aran Komatsuzaki.
(from BigCode) released with the paper by Loubna Ben Allal, Raymond Li, Denis Kocetkov, Chenghao Mou, Christopher Akiki, Carlos Munoz Ferrandis, Niklas Muennighoff, Mayank Mishra, Alex Gu, Manan Dey, Logesh Kumar Umapathi, Carolyn Jane Anderson, Yangtian Zi, Joel Lamy Poirier, Hailey Schoelkopf, Sergey Troshin, Dmitry Abulkhanov, Manuel Romero, Michael Lappert, Francesco De Toni, Bernardo García del Río, Qian Liu, Shamik Bose, Urvashi Bhattacharyya, Terry Yue Zhuo, Ian Yu, Paulo Villegas, Marco Zocca, Sourab Mangrulkar, David Lansky, Huu Nguyen, Danish Contractor, Luis Villa, Jia Li, Dzmitry Bahdanau, Yacine Jernite, Sean Hughes, Daniel Fried, Arjun Guha, Harm de Vries, Leandro von Werra.
(from Allegro.pl, AGH University of Science and Technology) released with the paper by Piotr Rybak, Robert Mroczkowski, Janusz Tracz, Ireneusz Gawlik.
(from Google AI) released with the paper by Mandy Guo, Joshua Ainslie, David Uthus, Santiago Ontanon, Jianmo Ni, Yun-Hsuan Sung, Yinfei Yang.
(from The FAIR team of Meta AI) released with the paper by Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, Guillaume Lample.
(from The FAIR team of Meta AI) released with the paper by Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushka rMishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaoqing EllenTan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurelien Rodriguez, Robert Stojnic, Sergey Edunov, Thomas Scialom.
(from Facebook) released with the paper by Angela Fan, Shruti Bhosale, Holger Schwenk, Zhiyi Ma, Ahmed El-Kishky, Siddharth Goyal, Mandeep Baines, Onur Celebi, Guillaume Wenzek, Vishrav Chaudhary, Naman Goyal, Tom Birch, Vitaliy Liptchinsky, Sergey Edunov, Edouard Grave, Michael Auli, Armand Joulin.
Machine translation models trained using data by Jörg Tiedemann. The is being developed by the Microsoft Translator Team.
(from Facebook) released with the paper by Yinhan Liu, Jiatao Gu, Naman Goyal, Xian Li, Sergey Edunov, Marjan Ghazvininejad, Mike Lewis, Luke Zettlemoyer.
(from Facebook) released with the paper by Yuqing Tang, Chau Tran, Xian Li, Peng-Jen Chen, Naman Goyal, Vishrav Chaudhary, Jiatao Gu, Angela Fan.
(from Facebook) released with the paper by Vineel Pratap, Andros Tjandra, Bowen Shi, Paden Tomasello, Arun Babu, Sayani Kundu, Ali Elkahky, Zhaoheng Ni, Apoorv Vyas, Maryam Fazel-Zarandi, Alexei Baevski, Yossi Adi, Xiaohui Zhang, Wei-Ning Hsu, Alexis Conneau, Michael Auli.
(from CMU/Google Brain) released with the paper by Zhiqing Sun, Hongkun Yu, Xiaodan Song, Renjie Liu, Yiming Yang, and Denny Zhou.
(from Apple) released with the paper by Sachin Mehta and Mohammad Rastegari.
(from Microsoft Research) released with the paper by Kaitao Song, Xu Tan, Tao Qin, Jianfeng Lu, Tie-Yan Liu.
(from MosaiML) released with the repository by the MosaicML NLP Team.
(from Google AI) released with the paper by Linting Xue, Noah Constant, Adam Roberts, Mihir Kale, Rami Al-Rfou, Aditya Siddhant, Aditya Barua, Colin Raffel.
(from Meta) released with the paper by the NLLB team.
(from Meta AI) released with the paper by Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen et al.
(from Microsoft Research) released with the paper by Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun.
(from Facebook), released together with the paper by Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, Veselin Stoyanov.
(from Microsoft Research) released with the paper by Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu, Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei.
(from Berkeley) released with the paper by Forrest N. Iandola, Albert E. Shaw, Ravi Krishna, and Kurt W. Keutzer.
(from Microsoft) released with the paper by Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, Baining Guo.
(from Google AI) released with the paper by Colin Raffel and Noam Shazeer and Adam Roberts and Katherine Lee and Sharan Narang and Michael Matena and Yanqi Zhou and Wei Li and Peter J. Liu.
(from Google AI) released in the repository by Colin Raffel and Noam Shazeer and Adam Roberts and Katherine Lee and Sharan Narang and Michael Matena and Yanqi Zhou and Wei Li and Peter J. Liu.
(from Google AI) released with the paper by Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, Neil Houlsby.
(from Facebook AI) released with the paper by Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael Auli.
(from Microsoft Research) released with the paper by Sanyuan Chen, Chengyi Wang, Zhengyang Chen, Yu Wu, Shujie Liu, Zhuo Chen, Jinyu Li, Naoyuki Kanda, Takuya Yoshioka, Xiong Xiao, Jian Wu, Long Zhou, Shuo Ren, Yanmin Qian, Yao Qian, Jian Wu, Michael Zeng, Furu Wei.
(from OpenAI) released with the paper by Alec Radford, Jong Wook Kim, Tao Xu, Greg Brockman, Christine McLeavey, Ilya Sutskever.
(from Facebook) released together with the paper by Guillaume Lample and Alexis Conneau.
(from Facebook AI), released together with the paper by Alexis Conneau, Kartikay Khandelwal, Naman Goyal, Vishrav Chaudhary, Guillaume Wenzek, Francisco Guzmán, Edouard Grave, Myle Ott, Luke Zettlemoyer and Veselin Stoyanov.
(from Huazhong University of Science & Technology) released with the paper by Yuxin Fang, Bencheng Liao, Xinggang Wang, Jiemin Fang, Jiyang Qi, Rui Wu, Jianwei Niu, Wenyu Liu.