Update README.md
Browse files
README.md
CHANGED
@@ -28,12 +28,12 @@ You can then use the model to compute embeddings, as follows:
|
|
28 |
import { pipeline, cos_sim } from '@xenova/transformers';
|
29 |
|
30 |
// Create a feature extraction pipeline
|
31 |
-
const extractor = await pipeline('feature-extraction', 'Xenova/jina-embeddings-v2-base-
|
32 |
quantized: false, // Comment out this line to use the quantized version
|
33 |
});
|
34 |
|
35 |
// Compute sentence embeddings
|
36 |
-
const texts = ['How is the weather today?', '
|
37 |
const output = await extractor(texts, { pooling: 'mean', normalize: true });
|
38 |
// Tensor {
|
39 |
// dims: [2, 768],
|
@@ -45,7 +45,7 @@ const output = await extractor(texts, { pooling: 'mean', normalize: true });
|
|
45 |
// Compute cosine similarity between the two embeddings
|
46 |
const score = cos_sim(output[0].data, output[1].data);
|
47 |
console.log(score);
|
48 |
-
// 0.
|
49 |
```
|
50 |
|
51 |
---
|
|
|
28 |
import { pipeline, cos_sim } from '@xenova/transformers';
|
29 |
|
30 |
// Create a feature extraction pipeline
|
31 |
+
const extractor = await pipeline('feature-extraction', 'Xenova/jina-embeddings-v2-base-zh', {
|
32 |
quantized: false, // Comment out this line to use the quantized version
|
33 |
});
|
34 |
|
35 |
// Compute sentence embeddings
|
36 |
+
const texts = ['How is the weather today?', '今天天气怎么样?'];
|
37 |
const output = await extractor(texts, { pooling: 'mean', normalize: true });
|
38 |
// Tensor {
|
39 |
// dims: [2, 768],
|
|
|
45 |
// Compute cosine similarity between the two embeddings
|
46 |
const score = cos_sim(output[0].data, output[1].data);
|
47 |
console.log(score);
|
48 |
+
// 0.7860610759096025
|
49 |
```
|
50 |
|
51 |
---
|