Views
No views yet
npm i @huggingface/transformers1import { pipeline } from "@huggingface/transformers";
2
3// Create a text2text-generation pipeline
4const generator = await pipeline('text2text-generation', 'Xenova/flan-alpaca-base');
5
6// Generate text
7const output = await generator('What is Python?', {
8 max_length: 128,
9 do_sample: true,
10 top_k: 10,
11 dtype: "fp32" // Options: "fp32", "fp16", "q8", "q4"
12});
13console.log(output);
14// [{ 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.' }]onnx).