Pre-converted ONNX versions of embedding models used by fhir4px for Tier 3 categorization.
NeuML/pubmedbert-base-embeddings converted to ONNX format for use with transformers.js.
1import { pipeline, env } from "@huggingface/transformers";
2env.allowRemoteModels = true;
3const extractor = await pipeline(
4 "feature-extraction",
5 "joelmontavon/fhir4px-embeddings-onnx",
6 {
7 dtype: "q8",
8 subfolder: "pubmedbert-base-embeddings",
9 }
10);
11const output = await extractor(texts, { pooling: "mean", normalize: true });
Each classification task has a JSON file with precomputed centroids (768-dim, L2-normalized).
When the centroid field is present, the runtime classifier skips prototype embedding entirely.
1{
2 "task": "observation_category",
3 "model": "joelmontavon/fhir4px-embeddings-onnx",
4 "classes": {
5 "lab": {
6 "centroid": [0.0123, -0.0456, ...],
7 "prototype_texts": ["Hemoglobin A1c", "Glucose", ...]
8 },
9 ...
10 }
11}
1const response = await fetch(
2 `https://huggingface.co/${MODEL_REPO}/resolve/main/centroids/observation_category.json`
3);
4const { classes } = await response.json();
5
6// For each class, use classes[className].centroid directly
7// (skip embedding prototype_texts since centroid is precomputed)