Sentence Similarity
sentence-transformers
Safetensors
Norwegian
Norwegian Nynorsk
Norwegian Bokmål
feature-extraction
dense
custom_code
Eval Results (legacy)
Instructions to use Fremtind/norsbert4-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Fremtind/norsbert4-large with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Fremtind/norsbert4-large", trust_remote_code=True) sentences = [ "En gruppe barn leker og har det gøy.", "Barn leker på gresset omgitt av sterke farger.", "Barna er sammen.", "Barna leser bøker." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
File size: 1,009 Bytes
854dbf1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | from __future__ import annotations
import json
from pathlib import Path
import copy
from transformers.configuration_utils import PretrainedConfig
class GptBertConfig(PretrainedConfig):
def __init__(
self,
config_file: Path | str | None = None,
**kwargs
):
super().__init__(**kwargs)
self.model = "norbert4"
if config_file is not None:
if type(config_file) is str:
config_file = Path(config_file)
assert type(config_file) is not Path, "The config_file should either be a Path or str"
with config_file.open("r") as file:
config = json.load(file)
for attr, value in config.items():
if isinstance(value, str):
value = value.lower()
setattr(self, attr, value)
for attr, value in kwargs.items():
if isinstance(value, str):
value = value.lower()
setattr(self, attr, value)
|