pipeline()
One function that loads a model for a task (embeddings, classification, and more) and gives you a callable.
Last updated
Analogy
A factory function: pass the task name and model id, get back a ready-to-use function.
Code example
import { pipeline } from "@huggingface/transformers"; const classify = await pipeline( "zero-shot-classification", "Xenova/mobilebert-uncased-mnli",);In an agent
Each pipeline is a cheap, fast helper your agent's tools can call.
Questions people ask
What does the pipeline function do in Transformers.js?
pipeline takes a task name, such as feature-extraction or zero-shot-classification, and a model id, then loads the model and returns a ready-to-call function. You call that function with your text and get the result. It hides tokenising, running the model and formatting the output.
How do I use a Transformers.js pipeline as an agent tool?
Load the pipeline once when your server starts, not on every request, because loading downloads and prepares the model. Then wrap the returned function in a tool, for example classifyPr or embedText. The agent calls it like any other tool, with no network call and no per-call cost.