all-MiniLM-L6-v2 for Kjarni

This is the sentence-transformers team's all-MiniLM-L6-v2, unchanged, hosted so it runs locally with Kjarni: text embeddings from one native library, with no Python runtime, PyTorch, ONNX Runtime or server. It maps text to 384 dimensions and reads up to 256 tokens. The model is about 90 MB and downloads on first use.

Usage

In Kjarni the model is called minilm-l6-v2. Each example compares a question with three texts.

Command line

curl -fsSL https://kjarni.ai/install.sh | sh    # Windows: irm https://kjarni.ai/install.ps1 | iex
kjarni similarity -q -m minilm-l6-v2 "How do I reset my password?" "Forgot your password? Use the reset link on the sign-in page."
0.734807

Python

# pip install kjarni
from kjarni import Embedder

embedder = Embedder(model="minilm-l6-v2", quiet=True)
query = "How do I reset my password?"
for text in [
    "Forgot your password? Use the reset link on the sign-in page.",
    "You can change your password under Settings, then Security.",
    "What time does the shop open on Saturdays?",
]:
    print(f"{embedder.similarity(query, text):.3f}  {text}")
0.735  Forgot your password? Use the reset link on the sign-in page.
0.606  You can change your password under Settings, then Security.
0.060  What time does the shop open on Saturdays?

Rust

// cargo add kjarni anyhow tokio --features tokio/full
use kjarni::Embedder;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let embedder = Embedder::new("minilm-l6-v2").await?;
    let query = "How do I reset my password?";
    for text in [
        "Forgot your password? Use the reset link on the sign-in page.",
        "You can change your password under Settings, then Security.",
        "What time does the shop open on Saturdays?",
    ] {
        println!("{:.3}  {text}", embedder.similarity(query, text).await?);
    }
    Ok(())
}

C#

// dotnet add package Kjarni
using Kjarni;

using var embedder = new Embedder("minilm-l6-v2", quiet: true);
var query = "How do I reset my password?";
foreach (var text in new[] { "Forgot your password? Use the reset link on the sign-in page.", "You can change your password under Settings, then Security.", "What time does the shop open on Saturdays?" })
    Console.WriteLine($"{embedder.Similarity(query, text):F3}  {text}");

C++ (C++23)

#include <kjarni.hpp>
#include <cstdio>

int main() {
    kjarni::EmbedderOptions options;
    options.model = "minilm-l6-v2";

    auto embedder = kjarni::Embedder::create(options);
    if (!embedder) return 1;

    auto query = embedder->encode("How do I reset my password?");
    if (!query) return 1;
    for (const char* text : {"Forgot your password? Use the reset link on the sign-in page.",
                             "You can change your password under Settings, then Security.",
                             "What time does the shop open on Saturdays?"}) {
        auto e = embedder->encode(text);
        if (!e) return 1;
        std::printf("%.3f  %s\n", kjarni::cosine(*query, *e), text);
    }
}

Go

// go get github.com/kjarni-ai/kjarni-go
package main

import (
    "fmt"
    "log"

    kjarni "github.com/kjarni-ai/kjarni-go"
)

func main() {
    embedder, err := kjarni.NewEmbedder("minilm-l6-v2", kjarni.WithQuiet(true))
    if err != nil {
        log.Fatal(err)
    }
    defer embedder.Close()

    query := "How do I reset my password?"
    for _, text := range []string{
        "Forgot your password? Use the reset link on the sign-in page.",
        "You can change your password under Settings, then Security.",
        "What time does the shop open on Saturdays?",
    } {
        score, err := embedder.Similarity(query, text)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("%.3f  %s\n", score, text)
    }
}

Each prints the similarities above. embed (embedder.encode in Python) gives the vectors themselves, normalised, for a search index; Kjarni's Indexer and Searcher build one from a folder of documents, with keyword, meaning and hybrid search. See the Kjarni documentation for installation details.

What changed from the original

Nothing in the model. The safetensors weights, configuration and tokenizer files are byte for byte the same as in sentence-transformers/all-MiniLM-L6-v2 at revision 1110a243fdf4706b3f48f1d95db1a4f5529b4d41. This README replaces the original model card; the PyTorch, ONNX and OpenVINO copies of the weights are left out.

About the model

all-MiniLM-L6-v2 is a 22-million-parameter MiniLM model, fine-tuned by the sentence-transformers team on over a billion sentence pairs. It maps English sentences and short paragraphs to 384 dimensions, and reads up to 256 tokens; longer input is cut there.

See the original model card for training data, benchmarks and intended use.

License

The Apache License 2.0, as the original. Kjarni and this hosting are not affiliated with or endorsed by the sentence-transformers team.

Downloads last month
7
Safetensors
Model size
22.7M params
Tensor type
I64
ยท
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for kjarni-ai/all-MiniLM-L6-v2