YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

MedASR ONNX β€” BizenLabs

ONNX-exported variants of google/medasr for local, offline medical speech recognition.

Published at: bizenlabs/medasr-onnx

Model Variants

Variant File Size Precision Use Case
FP32 model-fp32.onnx 405 MB Full Baseline β€” highest accuracy
FP16 model-fp16.onnx 204 MB Mixed Smaller footprint (auto-rejected if accuracy degrades)
INT8 model-int8.onnx 149 MB Quantized Low-resource CPU β€” 1.8x faster, 2.7x smaller

Quick Start

import numpy as np
import onnxruntime as ort
from transformers import AutoProcessor

processor = AutoProcessor.from_pretrained("google/medasr", trust_remote_code=True)
session = ort.InferenceSession("model-fp32.onnx", providers=["CPUExecutionProvider"])

# audio: float32 numpy array, mono, 16 kHz
encoded = processor(audio, sampling_rate=16000, return_tensors="np", padding=True)
feed = {"input_features": encoded["input_features"]}
if "attention_mask" in encoded:
    feed["attention_mask"] = encoded["attention_mask"]

logits = session.run(None, feed)[0]
token_ids = np.argmax(logits, axis=-1)
text = processor.batch_decode(token_ids)[0]

Source Model

Spec Value
Architecture Conformer-CTC (LasrForCTC)
Parameters 105M
Input 16 kHz mono audio
Vocab size 512
Training data ~5,000 hours physician dictations
WER (radiology) 4.6%
License Apache 2.0 (code) + HAI-DEF (weights)
Source google/medasr

Conversion Details

  • Exported with torch.onnx.export using legacy TorchScript path (dynamo=False)
  • ONNX opset version: 17
  • Dynamic axes: batch + sequence (supports variable-length audio)
  • FP16: mixed-precision with LayerNormalization, Softmax, ReduceMean, Attention ops kept in FP32
  • INT8: dynamic quantization on MatMul/Gemm ops
  • All variants validated against FP32 baseline (logit-level max_abs_diff + text-level WER)

See CONVERSION.md for the full process, key decisions, and reconversion checklist.

Directory Contents

File Purpose
convert_medasr.py Self-contained conversion script: export + quantize + validate + manifest
upload.py Upload artifacts to HuggingFace Hub
requirements.lock.txt Pinned Python dependencies
CONVERSION.md Detailed conversion process, key decisions, and reconversion checklist

Setup

cd tools/medasr-onnx
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.lock.txt

Login to Hugging Face (required for gated model access):

huggingface-cli login

Convert

python convert_medasr.py \
  --model-id google/medasr \
  --version 2026.02.20 \
  --output-dir ./artifacts

The script will:

  1. Export FP32 baseline and validate (structure, dynamic axes, runtime load)
  2. Build FP16 variant β€” auto-rejected if logit divergence or WER exceeds threshold
  3. Build INT8 variant with accuracy gate
  4. Write manifest.json with SHA256 checksums for all passing variants

To skip FP16 entirely:

python convert_medasr.py \
  --model-id google/medasr \
  --version 2026.02.20 \
  --output-dir ./artifacts \
  --skip-fp16

Upload to HuggingFace

Preview what will be uploaded:

python upload.py --version 2026.02.20 --dry-run

Upload all passing variants:

python upload.py --version 2026.02.20

Upload specific variants only:

python upload.py --version 2026.02.20 --variants fp32 int8

Reconverting (New Model Release)

When Google releases a new MedASR version:

  1. Update the transformers pin in requirements.lock.txt if the model card specifies a new commit
  2. Run conversion: python convert_medasr.py --model-id google/medasr --version YYYY.MM.DD
  3. Review the console output for any rejected variants
  4. Upload: python upload.py --version YYYY.MM.DD

See CONVERSION.md for the full reconversion checklist.

License

ONNX conversion code: Apache 2.0 Model weights: subject to google/medasr license (Apache 2.0 code + HAI-DEF weights)

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support