gte-base-litert / README.md
Bombek1's picture
Upload README.md with huggingface_hub
65cda3e verified
metadata
tags:
  - sentence-transformers
  - embeddings
  - litert
  - tflite
  - edge
  - on-device
license: mit
base_model: thenlper/gte-base
pipeline_tag: feature-extraction

gte-base - LiteRT

This is a LiteRT (formerly TensorFlow Lite) conversion of thenlper/gte-base for efficient on-device inference.

Model Details

Property Value
Original Model thenlper/gte-base
Format LiteRT (.tflite)
File Size 416.0 MB
Task Sentence Embeddings / Retrieval
Max Sequence Length 512
Output Dimension 768
Pooling Mode Mean Pooling

Performance

Benchmarked on AMD CPU (WSL2):

Metric Value
Inference Latency 313.0 ms
Throughput 3.2 tokens/sec
Cosine Similarity vs Original 1.0000 ✅

Quick Start

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

# Load model and tokenizer
interpreter = Interpreter(model_path="thenlper_gte-base.tflite")
interpreter.allocate_tensors()
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()

tokenizer = AutoTokenizer.from_pretrained("thenlper/gte-base")

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}")  # (768,)

Files

  • thenlper_gte-base.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:

Citation

@article{li2023towards,
    title={Towards General Text Embeddings with Multi-stage Contrastive Learning},
    author={Li, Zehan and Zhang, Xin and Zhang, Yanzhao and others},
    journal={arXiv preprint arXiv:2308.03281},
    year={2023}
}

Acknowledgments


Converted by Bombek1