Create README.md

#1
by nico-martin HF Staff - opened
Files changed (1) hide show
  1. README.md +50 -0
README.md ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model:
4
+ - swiss-ai/Apertus-8B-Instruct-2509
5
+ pipeline_tag: text-generation
6
+ library_name: transformers.js
7
+ ---
8
+
9
+ This is an ONNX version of [swiss-ai/Apertus-8B-Instruct-2509](https://huggingface.co/swiss-ai/Apertus-8B-Instruct-2509).
10
+
11
+ ### use with Transformers.js
12
+
13
+ > [!IMPORTANT]
14
+ > Note: This model requires Transformers.js v4.0.0 and above!
15
+
16
+ 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:
17
+ ```bash
18
+ npm i @huggingface/transformers
19
+ ```
20
+
21
+ **Example**: Basic example
22
+
23
+ ```js
24
+ import { pipeline, TextStreamer } from "@huggingface/transformers";
25
+
26
+ // Create a text generation pipeline
27
+ const generator = await pipeline(
28
+ "text-generation",
29
+ "swiss-ai/Apertus-8B-Instruct-2509",
30
+ {
31
+ device: "webgpu",
32
+ dtype: "q4f16",
33
+ },
34
+ );
35
+
36
+ // Define the list of messages
37
+ const messages = [
38
+ { role: "system", content: "You are a helpful assistant." },
39
+ { role: "user", content: "What is the capital of France?" },
40
+ ];
41
+
42
+ // Generate a response
43
+ const output = await generator(messages, {
44
+ max_new_tokens: 512,
45
+ do_sample: false,
46
+ streamer: new TextStreamer(generator.tokenizer, { skip_prompt: true, skip_special_tokens: true }),
47
+ });
48
+ console.log(output[0].generated_text.at(-1).content);
49
+ // The capital of France is Paris.
50
+ ```