Skip to content

Instantly share code, notes, and snippets.

@davidmezzetti
Created December 23, 2025 15:35
Show Gist options
  • Select an option

  • Save davidmezzetti/23d8ddecd918c2b4f5c4d825860c1efc to your computer and use it in GitHub Desktop.

Select an option

Save davidmezzetti/23d8ddecd918c2b4f5c4d825860c1efc to your computer and use it in GitHub Desktop.
from txtai import Embeddings
from txtai.pipeline import HFOnnx
# Export as quantized onnx model
# Model Size = 1.1 MB!
path = HFOnnx()(
"neuml/biomedbert-hash-nano-embeddings",
"pooling", "model.onnx", True
)
# Load onnx model for similarity
# No custom code anymore
embeddings = Embeddings(
path=path,
tokenizer="neuml/biomedbert-hash-nano-embeddings"
)
embeddings.similarity("cancer", ["tumor", "diabetes"])
# [(0, 0.8546434640884399), (1, -0.027852479368448257)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment