alt.freeweights.embed / sentence-bert-swedish-cased-ONNX
From: onnx-community <huggingface.co/onnx-community>Newsgroups: alt.freeweights.embedSubject:

sentence-bert-swedish-cased-ONNX

Date: 2026-11-15Commit: f91689dSigned: 2DC28CC7B26A283B ✓

Sentence similarity model. Onnx weights, 1.66 GB in all. Published by onnx-community under Apache-2.0.

embed1.66GBsentence-bert-swedish-cased-ONNXonnxpermissive
FactsParamsnot statedSize1.66 GBFormatsonnxTasksentence similarityLicenseApache-2.0From sourcepermissive
$ fw get onnx-community/sentence-bert-swedish-cased-ONNX
# manifest sha256 b3a4936690c0… · 1.66 GB · 15 files
$ fw verify ./sentence-bert-swedish-cased-ONNX onnx-community/sentence-bert-swedish-cased-ONNX
From sourceHosted (signed)onnx-community/sentence-bert-swedish-cased-ONNXLast check: 2026-11-15 05:22 UTC

Get help: custom fine-tune or private deploy. We review your setup before we quote.

Quantized of sentence-bert-swedish-cased.

Works with

Runs with

Ranked by fit to this model (onnx), then by GitHub stars.

Convert with

Evaluate with

Scan with

Overview

Size
1.66 GB
Weights
125 MB (smallest of 8 ONNX variants)
Parameters
not stated
Formats
onnx
Task
sentence similarity
License
Apache-2.0 (permissive)
Files
15, each with a sha256
Publisher
onnx-community
Added
2026-11-15
Section
alt.freeweights.embed
Lineage

Original release from the publisher.

Base model: KBLab/sentence-bert-swedish-cased

Where these bytes come from
Publisher at the pinned commit→You

Sources are tried in order. A file counts only when its size and sha256 match the manifest. Sources are checked when you ask for them, not on a timer.

Sources
BadgeHostLast checkResult
From sourcehuggingface.co2026-11-15 05:22 UTCpassed

Model card

From the publisher at commit f91689d. Shown as plain text with links; images open at the publisher.

sentence-bert-swedish-cased (ONNX)#

This is an ONNX version of KBLab/sentence-bert-swedish-cased. It was automatically converted and uploaded using this Hugging Face Space.

Usage with Transformers.js#

See the pipeline documentation for sentence-similarity: https://huggingface.co/docs/transformers.js/api/pipelines


KBLab/sentence-bert-swedish-cased#

This is a sentence-transformers model: It maps Swedish sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search. This model is a bilingual Swedish-English model trained according to instructions in the paper Making Monolingual Sentence Embeddings Multilingual using Knowledge Distillation and the documentation accompanying its companion python package. We have used the strongest available pretrained English Bi-Encoder (all-mpnet-base-v2) as a teacher model, and the pretrained Swedish KB-BERT as the student model.

A more detailed description of the model can be found in an article we published on the KBLab blog here and for the updated model here.

Update: We have released updated versions of the model since the initial release. The original model described in the blog post is v1.0. The current version is v2.0. The newer versions are trained on longer paragraphs, and have a longer max sequence length. v2.0 is trained with a stronger teacher model and is the current default.

Model versionTeacher ModelMax Sequence Length
v1.0paraphrase-mpnet-base-v2256
v1.1paraphrase-mpnet-base-v2384
v2.0all-mpnet-base-v2384

Usage (Sentence-Transformers)#

Using this model becomes easy when you have sentence-transformers installed:

pip install -U sentence-transformers

Then you can use the model like this:

from sentence_transformers import SentenceTransformer
sentences = ["Det här är en exempelmening", "Varje exempel blir konverterad"]

model = SentenceTransformer('KBLab/sentence-bert-swedish-cased')
embeddings = model.encode(sentences)
print(embeddings)
Loading an older model version (Sentence-Transformers)#

Currently, the easiest way to load an older model version is to clone the model repository and load it from disk. For example, to clone the v1.0 model:

git clone --depth 1 --branch v1.0 https://huggingface.co/KBLab/sentence-bert-swedish-cased

Then you can load the model by pointing to the local folder where you cloned the model:

from sentence_transformers import SentenceTransformer
model = SentenceTransformer("path_to_model_folder/sentence-bert-swedish-cased")

Usage (HuggingFace Transformers)#

Without sentence-transformers, you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.

from transformers import AutoTokenizer, AutoModel
import torch


#Mean Pooling - Take attention mask into account for correct averaging
def mean_pooling(model_output, attention_mask):
    token_embeddings = model_output[0] #First element of model_output contains all token embeddings
    input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
    return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)


# Sentences we want sentence embeddings for
sentences = ['Det här är en exempelmening', 'Varje exempel blir konverterad']

# Load model from HuggingFace Hub
# To load an older version, e.g. v1.0, add the argument revision="v1.0" 
tokenizer = AutoTokenizer.from_pretrained('KBLab/sentence-bert-swedish-cased')
model = AutoModel.from_pretrained('KBLab/sentence-bert-swedish-cased')

# Tokenize sentences
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')

# Compute token embeddings
with torch.no_grad():
    model_output = model(**encoded_input)

# Perform pooling. In this case, max pooling.
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])

print("Sentence embeddings:")
print(sentence_embeddings)
Loading an older model (Hugginfface Transformers)#

To load an older model specify the version tag with the revision arg. For example, to load the v1.0 model, use the following code:

AutoTokenizer.from_pretrained('KBLab/sentence-bert-swedish-cased', revision="v1.0")
AutoModel.from_pretrained('KBLab/sentence-bert-swedish-cased', revision="v1.0")

Evaluation Results#

The model was evaluated on SweParaphrase v1.0 and SweParaphrase v2.0. This test set is part of SuperLim -- a Swedish evaluation suite for natural langage understanding tasks. We calculated Pearson and Spearman correlation between predicted model similarity scores and the human similarity score labels. Results from SweParaphrase v1.0 are displayed below.

Model versionPearsonSpearman
v1.00.91830.9114
v1.10.91830.9114
v2.00.92830.9130

The following code snippet can be used to reproduce the above results:

from sentence_transformers import SentenceTransformer
import pandas as pd

df = pd.read_csv(
    "sweparaphrase-dev-165.csv",
    sep="\t",
    header=None,
    names=[
        "original_id",
        "source",
        "type",
        "sentence_swe1",
        "sentence_swe2",
        "score",
        "sentence1",
        "sentence2",
    ],
)

model = SentenceTransformer("KBLab/sentence-bert-swedish-cased")

sentences1 = df["sentence_swe1"].tolist()
sentences2 = df["sentence_swe2"].tolist()

# Compute embedding for both lists
embeddings1 = model.encode(sentences1, convert_to_tensor=True)
embeddings2 = model.encode(sentences2, convert_to_tensor=True)

# Compute cosine similarity after normalizing
embeddings1 /= embeddings1.norm(dim=-1, keepdim=True)
embeddings2 /= embeddings2.norm(dim=-1, keepdim=True)

cosine_scores = embeddings1 @ embeddings2.t()
sentence_pair_scores = cosine_scores.diag()

df["model_score"] = sentence_pair_scores.cpu().tolist()
print(df[["score", "model_score"]].corr(method="spearman"))
print(df[["score", "model_score"]].corr(method="pearson"))
Sweparaphrase v2.0#

In general, v1.1 correlates the most with human assessment of text similarity on SweParaphrase v2.0. Below, we present zero-shot evaluation results on all data splits. They display the model's performance out of the box, without any fine-tuning.

Model versionData splitPearsonSpearman
v1.0train0.83550.8256
v1.1train0.83830.8302
v2.0train0.82090.8059
v1.0dev0.86820.8774
v1.1dev0.87390.8833
v2.0dev0.86380.8668
v1.0test0.83560.8476
v1.1test0.83930.8550
v2.0test0.82320.8213
SweFAQ v2.0#

When it comes to retrieval tasks, v2.0 performs the best by quite a substantial margin. It is better at matching the correct answer to a question compared to v1.1 and v1.0.

Model versionData splitAccuracy
v1.0train0.5262
v1.1train0.6236
v2.0train0.7106
v1.0dev0.4636
v1.1dev0.5818
v2.0dev0.6727
v1.0test0.4495
v1.1test0.5229
v2.0test0.5871

Examples how to evaluate the models on some of the test sets of the SuperLim suites can be found on the following links: evaluate_faq.py (Swedish FAQ), evaluate_swesat.py (SweSAT synonyms), evaluate_supersim.py (SuperSim).

Training#

An article with more details on data and v1.0 of the model can be found on the KBLab blog.

Around 14.6 million sentences from English-Swedish parallel corpuses were used to train the model. Data was sourced from the Open Parallel Corpus (OPUS) and downloaded via the python package opustools. Datasets used were: JW300, Europarl, DGT-TM, EMEA, ELITR-ECA, TED2020, Tatoeba and OpenSubtitles.

The model was trained with the parameters:

DataLoader:

torch.utils.data.dataloader.DataLoader of length 180513 with parameters:

{'batch_size': 64, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}

Loss:

sentence_transformers.losses.MSELoss.MSELoss

Parameters of the fit()-Method:

{
    "epochs": 2,
    "evaluation_steps": 1000,
    "evaluator": "sentence_transformers.evaluation.SequentialEvaluator.SequentialEvaluator",
    "max_grad_norm": 1,
    "optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
    "optimizer_params": {
        "eps": 1e-06,
        "lr": 8e-06
    },
    "scheduler": "WarmupLinear",
    "steps_per_epoch": null,
    "warmup_steps": 5000,
    "weight_decay": 0.01
}

Full Model Architecture#

SentenceTransformer(
  (0): Transformer({'max_seq_length': 384, 'do_lower_case': False}) with Transformer model: BertModel 
  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
)

Citing & Authors#

This model was trained by KBLab, a data lab at the National Library of Sweden.

You can cite the article on our blog: https://kb-labb.github.io/posts/2021-08-23-a-swedish-sentence-transformer/ .

@misc{rekathati2021introducing,  
  author = {Rekathati, Faton},  
  title = {The KBLab Blog: Introducing a Swedish Sentence Transformer},  
  url = {https://kb-labb.github.io/posts/2021-08-23-a-swedish-sentence-transformer/},  
  year = {2021}  
}

Acknowledgements#

We gratefully acknowledge the HPC RIVR consortium (www.hpc-rivr.si) and EuroHPC JU (eurohpc-ju.europa.eu/) for funding this research by providing computing resources of the HPC system Vega at the Institute of Information Science (www.izum.si).

Files

15 files · 1.66 GBWeights 125 MB (smallest of 8 ONNX variants). Sizes and sha256 from the signed manifest.
Hide all 15 files with their sha256
FileSizesha256
.gitattributes1.52 KB11ad7efa24975ee4b0c3c3a38ed18737f0658a5f75a0a96787b576a78a023361
README.md13.4 KB5715492aa6ad5a157012f51e58e65dbf49c53d2a20264c3474b441db07ee42bf
config.json635 B8ca4f8b5347c88e3171d8dc41aedb00402f3c48bc2e6462e04541bd74fec6ec5
onnx/model.onnx497 MB4c8fc532961089fa299590b1ce7d5c468129513bcd3be599eaa0e88f17fd61d0
onnx/model_bnb4.onnx205 MBaf900e4f04bccc884f5df3664445cabe37323530518dc14adc47466056d3785a
onnx/model_fp16.onnx248 MB4d902e9dd9db897d25481977728d1ed942ae68826095aaafb9f2e0725528cfe0
onnx/model_int8.onnx125 MB8a839f67332edd4acc5eb551b898eb144bb085dd39fb0f97694e4adf070a43de
onnx/model_q4.onnx210 MBb599714f485f1a570763a473c2ea5bbb8e5784561364fdcdac0ffde2fea2d1e2
onnx/model_q4f16.onnx126 MB5e47c10f049f9956bddf279dbf9f6cf5640dfcf7beb0e7a530e7fd35ee33c82a
onnx/model_quantized.onnx125 MB8a839f67332edd4acc5eb551b898eb144bb085dd39fb0f97694e4adf070a43de
onnx/model_uint8.onnx125 MBac873e83b9c7e0b7091bc2dcc67af333c29532a027b43fd7a5373ecfcc690350
special_tokens_map.json695 B5d5b662e421ea9fac075174bb0688ee0d9431699900b90662acd44b2a350503a
tokenizer.json1.20 MB0001cd9fd9ef17918f38ad084d7abd372ff0fa587d8b12298bf659154ad6f045
tokenizer_config.json1.49 KB7bc31ee8321cf2e6020a80ea4fe9c4a17e48e850842e822ad6710cf3a3d50a83
vocab.txt399 KBcf103a3207ce9ce64c4d9e306c2cb433e5987b6050a9d869914e1a8e2c781ad6
VersionsEach time the pinned upstream commit or file list changed in this repo. Newest first.
Upstream commitDateContents
f91689df40 pinned now2026-11-15 05:22 UTC15 files · 1.66 GB

Use it

$ fw get onnx-community/sentence-bert-swedish-cased-ONNX
# manifest sha256 b3a4936690c0… · 1.66 GB · 15 files
$ fw verify ./sentence-bert-swedish-cased-ONNX onnx-community/sentence-bert-swedish-cased-ONNX
fw.pyChecks the signature and every sha256, tries each source in order, resumes.
$ python3 fw.py get https://freeweights.allternit.com/manifests/onnx-community/sentence-bert-swedish-cased-ONNX.json --dir ./sentence-bert-swedish-cased-ONNX $ python3 fw.py verify ./sentence-bert-swedish-cased-ONNX ./onnx-community__sentence-bert-swedish-cased-ONNX.json
hfThe Hugging Face CLI with one setting. Same repo id.
$ HF_ENDPOINT=https://freeweights.allternit.com hf download onnx-community/sentence-bert-swedish-cased-ONNX --revision f91689df4028b1ae13e0aa7c58d4298cd7fc4fbb --local-dir ./sentence-bert-swedish-cased-ONNX

License

Name
Apache License 2.0
Id
Apache-2.0
Class
Permissive
Redistribution
yes
Listing
Hosted (signed)
Decided
License as declared by the publisher. No person read it. 2026-11-15
Text in
README.md
Text sha256
5715492aa6ad5a157012f51e58e65dbf49c53d2a20264c3474b441db07ee42bf
Terms gate
No extra terms beyond the license.

Read the license text

Licenses are checked against the license table. A custom license passes only after a person reads it.

Provenance

From: onnx-community <huggingface.co/onnx-community>Newsgroups: alt.freeweights.embedSubject: sentence-bert-swedish-cased-ONNXDate: 2026-11-15Commit: f91689dSigned: 2DC28CC7B26A283B ✓
Upstream
onnx-community/sentence-bert-swedish-cased-ONNX
Pinned commit
f91689df4028b1ae13e0aa7c58d4298cd7fc4fbb
Manifest
sentence-bert-swedish-cased-ONNX.json · .minisig
Manifest sha256
b3a4936690c0b9b233f3fe94b3301428fb591a2ffc80b9ba943812ec08f5ef7a
Signature
minisign, Ed25519, key 2DC28CC7B26A283B
Created
2026-11-15 05:22 UTC
Generator
freeweights-manifest/0.1.0
Takedowns
None.

How to verify

$ curl -O https://freeweights.allternit.com/manifests/onnx-community/sentence-bert-swedish-cased-ONNX.json $ curl -O https://freeweights.allternit.com/manifests/onnx-community/sentence-bert-swedish-cased-ONNX.json.minisig $ minisign -Vm sentence-bert-swedish-cased-ONNX.json -P RWQ7KGqyx4zCLXtUFOqvfv8L3g+8fpKJ1FsuxPyOYMF+4KufbUxKq1Oq $ shasum -a 256 <file> # compare with the Files tab

A manifest whose signature fails must be rejected. A file whose size or sha256 does not match must be discarded. Verify a download

Model tree

Parent

KBLab/sentence-bert-swedish-cased · this model is a quantization of it

No model in the catalog names this one as its parent.

Get it
Download
$ HF_ENDPOINT=https://freeweights.allternit.com hf download onnx-community/sentence-bert-swedish-cased-ONNX
Open in Freeweights Studio

Pull, verify and run it in the Allternit app on Desktop, web or phone.

Signed manifest
minisign, key 2DC28CC7B26A283B. sentence-bert-swedish-cased-ONNX.json. Provenance. Takedown history: none.
From: sentence-transformers <huggingface.co/sentence-transformers>Subject: all-MiniLM-L6-v1
From: unsloth <huggingface.co/unsloth>Subject: all-MiniLM-L6-v2
From: mlx-community <huggingface.co/mlx-community>Subject: all-MiniLM-L6-v2-4bit
From: sentence-transformers <huggingface.co/sentence-transformers>Subject: all-mpnet-base-v1
From: sentence-transformers <huggingface.co/sentence-transformers>Subject: allenai-specter
From: sentence-transformers <huggingface.co/sentence-transformers>Subject: bert-base-nli-max-tokens