transformers.js onnx t5 text2text-generation region:us
---
library_name: transformers.js
---

https://huggingface.co/declare-lab/flan-alpaca-base with ONNX weights to be compatible with Transformers.js.


## Usage (Transformers.js)

If you haven't already, you can install the [Transformers.js](https://huggingface.co/docs/transformers.js) JavaScript library from [NPM](https://www.npmjs.com/package/@xenova/transformers) using:
```bash
npm i @xenova/transformers
```

You can then use the model to generate text like this:

```js
import { pipeline } from "@xenova/transformers";

// Create a text2text-generation pipeline
const generator = await pipeline('text2text-generation', 'Xenova/flan-alpaca-base');

// Generate text
const output = await generator('What is Python?', { max_length: 128, do_sample: true, top_k: 10, });
console.log(output);
// [{ generated_text: 'Python is a programming language used in many applications, such as machine learning, database management, and graphical application development. It is a multi-functional language which works across various data sets and platforms.' }]
```


---


Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [🤗 Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).