Downloads · 30 days
29
26% of all-time downloads
Bombek1/mobilebert-uncased-litert
mobilebert-uncased-litert is a machine learning model from Bombek1. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for litert. The card lists the license as apache-2.0.
This is a LiteRT (formerly TensorFlow Lite) export of google/mobilebert-uncased.
Downloads · 30 days
29
26% of all-time downloads
All-time downloads
111
Public
Repo size
99.2 MB
Likes
0
Public
Click a slice to open those files.
.tflite99.2 MB · 100%
From the Hugging Face model README
This is a LiteRT (formerly TensorFlow Lite) export of google/mobilebert-uncased.
It is optimized for mobile and edge inference (Android/iOS/Embedded).
| Attribute | Value |
|---|---|
| Task | Feature Extraction |
| Format | .tflite (Float32) |
| File Size | 94.6 MB |
| Input Length | 128 tokens |
| Output Dim | 512 |
import numpy as np
from ai_edge_litert.interpreter import Interpreter
from transformers import AutoTokenizer
# Load model
interpreter = Interpreter(model_path="google_mobilebert-uncased.tflite")
interpreter.allocate_tensors()
tokenizer = AutoTokenizer.from_pretrained("google/mobilebert-uncased")
def get_embedding(text):
inputs = tokenizer(text, max_length=128, padding="max_length", truncation=True, return_tensors="np")
input_details = interpreter.get_input_details()
interpreter.set_tensor(input_details[0]['index'], inputs['input_ids'].astype(np.int64))
interpreter.set_tensor(input_details[1]['index'], inputs['attention_mask'].astype(np.int64))
interpreter.invoke()
output_details = interpreter.get_output_details()
return interpreter.get_tensor(output_details[0]['index'])[0]
emb = get_embedding("Hello world")
print(f"Embedding shape: {emb.shape}")
Converted by Bombek1 using litert-torch