初始化项目,由ModelHub XC社区提供模型
Model: Xenova/llama2.c-stories42M Source: Original Platform
This commit is contained in:
30
README.md
Normal file
30
README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
library_name: transformers.js
|
||||
tags:
|
||||
- transformers
|
||||
---
|
||||
|
||||
## 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/@huggingface/transformers) using:
|
||||
```bash
|
||||
npm i @huggingface/transformers
|
||||
```
|
||||
|
||||
You can then use the model to generate text like this:
|
||||
|
||||
```js
|
||||
import { pipeline } from "@huggingface/transformers";
|
||||
|
||||
// Create a text-generation pipeline
|
||||
const generator = await pipeline('text-generation', 'Xenova/llama2.c-stories42M');
|
||||
|
||||
const text = 'Once upon a time,';
|
||||
const output = await generator(text);
|
||||
console.log(output);
|
||||
// [{ generated_text: "Once upon a time, there was a little girl named Lily. She loved to play outside in" }]
|
||||
|
||||
const output2 = await generator(text, { max_new_tokens: 50 });
|
||||
console.log(output2);
|
||||
// [{ 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" }]
|
||||
```
|
||||
Reference in New Issue
Block a user