nico-martin HF Staff commited on
Commit
263e471
·
verified ·
1 Parent(s): 33df311

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +47 -0
README.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ 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:
14
+ ```bash
15
+ npm i @huggingface/transformers
16
+ ```
17
+
18
+ **Example**: Basic example
19
+
20
+ ```js
21
+ import { pipeline, TextStreamer } from "@huggingface/transformers";
22
+
23
+ // Create a text generation pipeline
24
+ const generator = await pipeline(
25
+ "text-generation",
26
+ "swiss-ai/Apertus-8B-Instruct-2509",
27
+ {
28
+ device: "webgpu",
29
+ dtype: "q4f16",
30
+ },
31
+ );
32
+
33
+ // Define the list of messages
34
+ const messages = [
35
+ { role: "system", content: "You are a helpful assistant." },
36
+ { role: "user", content: "What is the capital of France?" },
37
+ ];
38
+
39
+ // Generate a response
40
+ const output = await generator(messages, {
41
+ max_new_tokens: 512,
42
+ do_sample: false,
43
+ streamer: new TextStreamer(generator.tokenizer, { skip_prompt: true, skip_special_tokens: true }),
44
+ });
45
+ console.log(output[0].generated_text.at(-1).content);
46
+ // The capital of France is Paris.
47
+ ```