Views
No views yet
| Property | Value |
|---|---|
| Original Model | intfloat/multilingual-e5-small |
| Format | LiteRT (.tflite) |
| File Size | 449.0 MB |
| Task | Multilingual Sentence Embeddings (100 languages) |
| Max Sequence Length | 512 |
| Output Dimension | 384 |
| Pooling Mode | Mean Pooling |
| Metric | Value |
|---|---|
| Inference Latency | 91.9 ms |
| Throughput | 10.9 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="intfloat_multilingual-e5-small.tflite")
7interpreter.allocate_tensors()
8input_details = interpreter.get_input_details()
9output_details = interpreter.get_output_details()
10
11tokenizer = AutoTokenizer.from_pretrained("intfloat/multilingual-e5-small")
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,)intfloat_multilingual-e5-small.tflite - The LiteRT model file1@article{wang2024multilingual,
2 title={Multilingual E5 Text Embeddings: A Technical Report},
3 author={Wang, Liang and Yang, Nan and Huang, Xiaolong and others},
4 journal={arXiv preprint arXiv:2402.05672},
5 year={2024}
6}