# pipeline()

One function that loads a model for a task (embeddings, classification, and more) and gives you a callable.

AI developers · Part 07: Hugging Face · Card 3 of 12 · Last updated 2026-10-13

## Analogy

A factory function: pass the task name and model id, get back a ready-to-use function.

## Code example

`pipeline.ts`

```typescript
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.

## Related concepts

- [Transformers.js](https://studyvisually.com/learn/tech/ai-developers/hugging-face/transformers-js)
- [The Hugging Face Hub](https://studyvisually.com/learn/tech/ai-developers/hugging-face/hugging-face-hub)
- [Local embeddings](https://studyvisually.com/learn/tech/ai-developers/hugging-face/local-embeddings)
- [Zero-shot classification](https://studyvisually.com/learn/tech/ai-developers/hugging-face/zero-shot-classification)

Web page: https://studyvisually.com/learn/tech/ai-developers/hugging-face/pipeline
Study this card in the app: https://studyvisually.com/app/learn?category=ai-developers&card=pipeline
