|
|
--- |
|
|
library_name: transformers.js |
|
|
base_model: NbAiLab/nb-sbert-base |
|
|
tags: |
|
|
- onnx |
|
|
- transformers.js |
|
|
- feature-extraction |
|
|
- sentence-similarity |
|
|
language: |
|
|
- no |
|
|
pipeline_tag: feature-extraction |
|
|
license: apache-2.0 |
|
|
--- |
|
|
|
|
|
# ONNX version of NbAiLab/nb-sbert-base |
|
|
|
|
|
This repository contains **ONNX-converted weights** for [NbAiLab/nb-sbert-base](https://huggingface.co/NbAiLab/nb-sbert-base), compatible with [Transformers.js](https://huggingface.co/docs/transformers.js). |
|
|
|
|
|
It includes both: |
|
|
1. **Quantized (int8):** Faster, smaller (default). |
|
|
2. **Full Precision (float32):** Higher theoretical accuracy, larger file size. |
|
|
|
|
|
## Usage (Node.js) |
|
|
|
|
|
First, install the library: |
|
|
|
|
|
```bash |
|
|
npm install @huggingface/transformers |
|
|
``` |
|
|
|
|
|
## Option 1: Use Quantized Model (Recommended) |
|
|
This is the default behavior. It loads model_quantized.onnx (approx. 4x smaller). |
|
|
|
|
|
```javascript |
|
|
import { pipeline } from '@huggingface/transformers'; |
|
|
|
|
|
const embedder = await pipeline( |
|
|
'feature-extraction', |
|
|
'lebchen/nb-sbert-base-onnx', |
|
|
{ device: 'auto' } // Defaults to { quantized: true } |
|
|
); |
|
|
|
|
|
const output = await embedder("Dette er en test.", { pooling: 'mean', normalize: true }); |
|
|
``` |
|
|
|
|
|
## Option 2: Use Full Precision Model |
|
|
|
|
|
``` |
|
|
import { pipeline } from '@huggingface/transformers'; |
|
|
|
|
|
const embedder = await pipeline( |
|
|
'feature-extraction', |
|
|
'lebchen/nb-sbert-base-onnx', |
|
|
{ |
|
|
device: 'auto', |
|
|
quantized: false // Forces loading of model.onnx |
|
|
} |
|
|
); |
|
|
``` |
|
|
|
|
|
## Credits & License |
|
|
|
|
|
The original model was developed by the National Library of Norway (AI Lab). Original repository: https://huggingface.co/NbAiLab/nb-sbert-base |
|
|
|
|
|
This distribution is licensed under Apache 2.0. |
|
|
|