Views
No views yet
npm i @huggingface/transformers1import { pipeline } from "@huggingface/transformers";
2
3// Create a text-generation pipeline
4const generator = await pipeline('text-generation', 'Xenova/llama2.c-stories42M');
5
6const text = 'Once upon a time,';
7const output = await generator(text);
8console.log(output);
9// [{ generated_text: "Once upon a time, there was a little girl named Lily. She loved to play outside in" }]
10
11const output2 = await generator(text, { max_new_tokens: 50 });
12console.log(output2);
13// [{ generated_text: "Once upon a time, there was a little girl named Lily. She loved to play outside in the sunshine. One day, she saw a big, yellow flower in the garden. It was so pretty! She picked it and smelled it. It smelled" }]