Xenova HF staff commited on
Commit
9eeeeb0
1 Parent(s): 806b343

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -0
README.md CHANGED
@@ -5,4 +5,27 @@ pipeline_tag: feature-extraction
5
 
6
  https://huggingface.co/jinaai/jina-embeddings-v2-base-en with ONNX weights to be compatible with Transformers.js.
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  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`).
 
5
 
6
  https://huggingface.co/jinaai/jina-embeddings-v2-base-en with ONNX weights to be compatible with Transformers.js.
7
 
8
+
9
+ ## Usage with 🤗 Transformers.js
10
+
11
+ ```js
12
+ // npm i @xenova/transformers
13
+ import { pipeline, cos_sim } from '@xenova/transformers';
14
+
15
+ // Create feature extraction pipeline
16
+ const extractor = await pipeline('feature-extraction', 'Xenova/jina-embeddings-v2-base-en',
17
+ { quantized: false } // Comment out this line to use the quantized version
18
+ );
19
+
20
+ // Generate embeddings
21
+ const output = await extractor(
22
+ ['How is the weather today?', 'What is the current weather like today?'],
23
+ { pooling: 'mean' }
24
+ );
25
+
26
+ // Compute cosine similarity
27
+ console.log(cos_sim(output[0].data, output[1].data)); // 0.9341313949712492 (unquantized) vs. 0.9022937687830741 (quantized)
28
+ ```
29
+
30
+
31
  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`).