Views
No views yet
| Property | Value |
|---|---|
| Original Model | sentence-transformers/msmarco-MiniLM-L-6-v3 |
| Format | LiteRT (.tflite) |
| File Size | 86.0 MB |
| Task | Document Retrieval / Semantic Search |
| Max Sequence Length | 512 |
| Output Dimension | 384 |
| Pooling Mode | Mean Pooling |
| Metric | Value |
|---|---|
| Inference Latency | 46.3 ms |
| Throughput | 21.6 tokens/sec |
| Cosine Similarity vs Original | 1.0000 ✅ |
1import numpy as np
2from ai_edge_litert.interpreter import Interpreter
3from transformers import AutoTokenizer
4
5# Load model and tokenizer
6interpreter = Interpreter(model_path="sentence-transformers_msmarco-MiniLM-L-6-v3.tflite")
7interpreter.allocate_tensors()
8input_details = interpreter.get_input_details()
9output_details = interpreter.get_output_details()
10
11tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/msmarco-MiniLM-L-6-v3")
12
13def get_embedding(text: str) -> np.ndarray:
14 """Get sentence embedding for input text."""
15 encoded = tokenizer(
16 text,
17 padding="max_length",
18 max_length=512,
19 truncation=True,
20 return_tensors="np"
21 )
22
23 interpreter.set_tensor(input_details[0]["index"], encoded["input_ids"].astype(np.int64))
24 interpreter.set_tensor(input_details[1]["index"], encoded["attention_mask"].astype(np.int64))
25 interpreter.invoke()
26
27 return interpreter.get_tensor(output_details[0]["index"])[0]
28
29# Example
30embedding = get_embedding("Hello, world!")
31print(f"Embedding shape: {embedding.shape}") # (384,)sentence-transformers_msmarco-MiniLM-L-6-v3.tflite - The LiteRT model file1@inproceedings{reimers-2019-sentence-bert,
2 title={Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks},
3 author={Reimers, Nils and Gurevych, Iryna},
4 booktitle={EMNLP 2019},
5 year={2019}
6}