Upload ONNX weights + Transformers.js sample code
#4
by
Xenova
HF Staff
- opened
- README.md +29 -0
- onnx/model.onnx +3 -0
- onnx/model_bnb4.onnx +3 -0
- onnx/model_fp16.onnx +3 -0
- onnx/model_int8.onnx +3 -0
- onnx/model_q4.onnx +3 -0
- onnx/model_q4f16.onnx +3 -0
- onnx/model_quantized.onnx +3 -0
- onnx/model_uint8.onnx +3 -0
README.md
CHANGED
|
@@ -9173,6 +9173,35 @@ for query, query_scores in zip(queries, scores):
|
|
| 9173 |
print(score, document)
|
| 9174 |
```
|
| 9175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9176 |
|
| 9177 |
## Contact
|
| 9178 |
|
|
|
|
| 9173 |
print(score, document)
|
| 9174 |
```
|
| 9175 |
|
| 9176 |
+
### Using Huggingface Transformers.js
|
| 9177 |
+
|
| 9178 |
+
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:
|
| 9179 |
+
```bash
|
| 9180 |
+
npm i @huggingface/transformers
|
| 9181 |
+
```
|
| 9182 |
+
|
| 9183 |
+
You can then use the model for retrieval, as follows:
|
| 9184 |
+
|
| 9185 |
+
```js
|
| 9186 |
+
import { pipeline, dot } from '@huggingface/transformers';
|
| 9187 |
+
|
| 9188 |
+
// Create feature extraction pipeline
|
| 9189 |
+
const extractor = await pipeline('feature-extraction', 'Snowflake/snowflake-arctic-embed-m-v2.0');
|
| 9190 |
+
|
| 9191 |
+
// Generate sentence embeddings
|
| 9192 |
+
const sentences = [
|
| 9193 |
+
'query: what is snowflake?',
|
| 9194 |
+
'The Data Cloud!',
|
| 9195 |
+
'Mexico City of Course!',
|
| 9196 |
+
]
|
| 9197 |
+
const output = await extractor(sentences, { normalize: true, pooling: 'cls' });
|
| 9198 |
+
|
| 9199 |
+
// Compute similarity scores
|
| 9200 |
+
const [source_embeddings, ...document_embeddings ] = output.tolist();
|
| 9201 |
+
const similarities = document_embeddings.map(x => dot(source_embeddings, x));
|
| 9202 |
+
console.log(similarities); // [0.32719788157046004, 0.06960141111667434]
|
| 9203 |
+
```
|
| 9204 |
+
|
| 9205 |
|
| 9206 |
## Contact
|
| 9207 |
|
onnx/model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c0c53d7f49a2db60761b92b7bbf5be87a7b3cf5d92dbbd7f1b5028bd5a40aa39
|
| 3 |
+
size 1226099913
|
onnx/model_bnb4.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:042dc3b22eb47b760eb9e95aff681baf2901c919e6bea2280678d7863ee2f10d
|
| 3 |
+
size 836823604
|
onnx/model_fp16.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f27ab40ab6e230265ba49a202a37f1ad031556256cbbc105d0ca9c0bdc7ec42e
|
| 3 |
+
size 613266244
|
onnx/model_int8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:03d923bb1850ebdccb068e2f3abd8aa43fe81c50d07d037ef103fe3d0fb78e3b
|
| 3 |
+
size 310916060
|
onnx/model_q4.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f8ee62d8f4d2f00fc456b1bc5efff8fb2084642844d8835d1ecffce420ae3c51
|
| 3 |
+
size 843901108
|
onnx/model_q4f16.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3cabedcefa1a1c1a8f8c6bb46bad75219f23ef73892580bcf59e96b03b941e5c
|
| 3 |
+
size 450481991
|
onnx/model_quantized.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:03d923bb1850ebdccb068e2f3abd8aa43fe81c50d07d037ef103fe3d0fb78e3b
|
| 3 |
+
size 310916060
|
onnx/model_uint8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:22299d6d7d9ce6969a3b6bea9e0c828b92b7f4124c3ecb401ad6291f7171f406
|
| 3 |
+
size 310916060
|