Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: transformers.js
|
3 |
+
other: transformers
|
4 |
+
---
|
5 |
+
|
6 |
+
The language model used by https://huggingface.co/vikhyatk/moondream2 (2024-08-26).
|
7 |
+
|
8 |
+
## Usage (Transformers.js)
|
9 |
+
|
10 |
+
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:
|
11 |
+
```bash
|
12 |
+
npm i @huggingface/transformers
|
13 |
+
```
|
14 |
+
|
15 |
+
**Example:** Text generation with `onnx-community/moondream2.text_model-ONNX`.
|
16 |
+
|
17 |
+
```js
|
18 |
+
import { pipeline } from "@huggingface/transformers";
|
19 |
+
|
20 |
+
// Create a text generation pipeline
|
21 |
+
const generator = await pipeline(
|
22 |
+
"text-generation",
|
23 |
+
"onnx-community/moondream2.text_model-ONNX",
|
24 |
+
{ dtype: "q4" },
|
25 |
+
);
|
26 |
+
|
27 |
+
// Generate a response
|
28 |
+
const text = "Once upon a time";
|
29 |
+
const output = await generator(text, { max_new_tokens: 128 });
|
30 |
+
console.log(output[0].generated_text);
|
31 |
+
```
|
32 |
+
|
33 |
+
<details>
|
34 |
+
|
35 |
+
<summary>Example output</summary>
|
36 |
+
|
37 |
+
```
|
38 |
+
Once upon a time, there was a young girl named Lily who loved to read books. She would spend hours lost in the pages of her favorite stories, imagining herself as the main characters. One day, while reading a book about a magical forest, Lily had an idea. She wanted to create her own magical forest, filled with all the wonders and adventures she had read about in her books.
|
39 |
+
|
40 |
+
Lily knew that she needed to gather the right materials to create her magical forest. She decided to use her imagination and creativity to make the forest come to life. She gathered her friends and family to help her, and together they began to build the forest
|
41 |
+
```
|
42 |
+
</details>
|
43 |
+
|
44 |
+
|
45 |
+
---
|
46 |
+
|
47 |
+
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`).
|