flan-alpaca-base / README.md
whitphx's picture
Add/update the quantized ONNX model files and README.md for Transformers.js v3
c341b23 verified
|
raw
history blame
1.55 kB
metadata
base_model: declare-lab/flan-alpaca-base
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 JavaScript library from NPM using:

npm i @huggingface/transformers

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

import { pipeline } from "@huggingface/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,
    dtype: "fp32"  // Options: "fp32", "fp16", "q8", "q4"
});
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 and structuring your repo like this one (with ONNX weights located in a subfolder named onnx).