Skip to main content

What is Transformers.js?

TheCodingTrainOctober 25, 202529:17general_education

Summary

This video introduces the Transformers.js library, demonstrating how to implement machine learning models like sentiment analysis and language detection directly in the browser using JavaScript and p5.js. It's highly useful for students and educators who want to learn practical AI/ML development and understand how AI models can be integrated into web applications.

Description

Welcome to a new series all about working with machine learning models in JavaScript in the browser using the Transformers.js library! In this introduction, I cover what Transformers.js is, how to load it into a p5.js sketch, explain the pipeline API, and demonstrate sentiment analysis and language detection examples. Code: https://thecodingtrain.com/tracks/transformers-js/transformers-js/introduction ๐Ÿš€ Watch this video ad-free on Nebula https://nebula.tv/videos/codingtrain-machine-learning-in-the-browser p5.js Web Editor Sketches: ๐Ÿ•น๏ธ Sentiment Analysis: https://editor.p5js.org/codingtrain/sketches/JaXqVSHxM ๐Ÿ•น๏ธ Language Detection: https://editor.p5js.org/codingtrain/sketches/VmS9V6-0o References: ๐Ÿ’ป Transformers.js Documentation: https://huggingface.co/docs/transformers.js ๐Ÿค— Hugging Face: https://huggingface.co/ ๐Ÿค— Hugging Face Models: https://huggingface.co/models?library=transformers.js ๐Ÿค— Xenova on Hugging Face: https://huggingface.co/Xenova ๐Ÿค— Whisper Web: https://huggingface.co/spaces/Xenova/whisper-web ๐Ÿ’ป p5.js 2.0 reference: https://beta.p5js.org/ ๐Ÿ““ ES6 Modules: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules ๐Ÿ““ Quantization: https://huggingface.co/docs/optimum/concept_guides/quantization Videos: ๐Ÿš‚ https://www.youtube.com/playlist?list=PLRqwX-V7Uu6YPSwT06y_AEYTqIwbeam3y ๐Ÿš‚ https://youtu.be/0Ad5Frf8NBM Timestamps: 0:00 Welcome! 1:53 Why JavaScript and not Python? 3:01 What is Hugging Face? 4:03 Transformers.js Documentation 4:18 Pipeline API 5:41 import syntax and ES6 modules 8:34 Object Destructuring 11:33 Creating a Pipeline 13:18 Sentiment Analysis Example 19:04 Tasks and Models on Hugging Face 20:20 Language Detection Example 22:27 Device: WebGPU, CPU and more 24:25 Data Types and Quantization 27:54 See you next time! Editing by Mathieu Blanchette Animations by Jason Heglund Music from Epidemic Sound ๐Ÿš‚ Website: https://thecodingtrain.com/ ๐Ÿ‘พ Share Your Creation! https://thecodingtrain.com/guides/passenger-showcase-guide