CoolFace
Modelpublic

Bombek1/multi-qa-MiniLM-L6-cos-v1-litert

sourceHugging Faceapache-2.0updated 9mo agoView on Hugging Face
0likes20downloads
Model Card

multi-qa-MiniLM-L6-cos-v1 - LiteRT

This is a LiteRT (formerly TensorFlow Lite) conversion of sentence-transformers/multi-qa-MiniLM-L6-cos-v1 for efficient on-device inference.

Model Details

PropertyValue
Original Modelsentence-transformers/multi-qa-MiniLM-L6-cos-v1
FormatLiteRT (.tflite)
File Size86.0 MB
TaskQuestion Answering / Semantic Search
Max Sequence Length512
Output Dimension384
Pooling ModeMean Pooling

Performance

Benchmarked on AMD CPU (WSL2):

MetricValue
Inference Latency46.4 ms
Throughput21.6 tokens/sec
Cosine Similarity vs Original1.0000 ✅

Quick Start

python
import numpy as np
from ai_edge_litert.interpreter import Interpreter
from transformers import AutoTokenizer

# Load model and tokenizer
interpreter = Interpreter(model_path="sentence-transformers_multi-qa-MiniLM-L6-cos-v1.tflite")
interpreter.allocate_tensors()
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()

tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/multi-qa-MiniLM-L6-cos-v1")

def get_embedding(text: str) -> np.ndarray:
    """Get sentence embedding for input text."""
    encoded = tokenizer(
        text,
        padding="max_length",
        max_length=512,
        truncation=True,
        return_tensors="np"
    )

    interpreter.set_tensor(input_details[0]["index"], encoded["input_ids"].astype(np.int64))
    interpreter.set_tensor(input_details[1]["index"], encoded["attention_mask"].astype(np.int64))
    interpreter.invoke()

    return interpreter.get_tensor(output_details[0]["index"])[0]

# Example
embedding = get_embedding("Hello, world!")
print(f"Embedding shape: {embedding.shape}")  # (384,)

Files

  • —sentence-transformers_multi-qa-MiniLM-L6-cos-v1.tflite - The LiteRT model file

Conversion Details

  • —Conversion Tool: ai-edge-torch
  • —Conversion Date: 2026-01-12
  • —Source Framework: PyTorch → LiteRT
  • —Validation: Cosine similarity 1.0000 vs original

Intended Use

  • —Mobile Applications: On-device semantic search, RAG systems
  • —Edge Devices: IoT, embedded systems, Raspberry Pi
  • —Offline Processing: Privacy-preserving inference
  • —Low-latency Applications: Real-time processing

Limitations

  • —Fixed sequence length (512 tokens)
  • —CPU inference (GPU delegate requires setup)
  • —Tokenizer loaded separately from original model
  • —Float32 precision

License

This model inherits the license from the original:

  • —License: Apache 2.0 (source)

Citation

bibtex
@inproceedings{reimers-2019-sentence-bert,
    title={Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks},
    author={Reimers, Nils and Gurevych, Iryna},
    booktitle={EMNLP 2019},
    year={2019}
}

Acknowledgments


Converted by [Bombek1](https://huggingface.co/Bombek1)