How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("feature-extraction", model="weemed/IlhaEmbed")
# Load model directly
from transformers import AutoTokenizer, AutoModel

tokenizer = AutoTokenizer.from_pretrained("weemed/IlhaEmbed")
model = AutoModel.from_pretrained("weemed/IlhaEmbed", device_map="auto")
Quick Links

IlhaEmbed v2

English | 繁體中文

IlhaEmbed is a 38.9 MB INT8 ONNX encoder for Taiwanese clinical terminology, hospital shorthand, and Traditional Chinese medical text. It is intended for on-premise candidate retrieval and semantic routing with human or deterministic confirmation. It is not an autonomous medical coder.

This release replaces the incorrect 97.9 MB artifact previously published as v2. The replacement is derived from the shipped 97M-parameter IlhaEmbed v1, adapts it with the approved MODA/NAER medical terminology collection, and retains 25% of the selected epoch-1 weight movement. The deployed artifact uses per-channel dynamic INT8 quantization and the original 25.5k-token canonical tokenizer.

What changed

  • Source: 13 National Academy for Educational Research medical terminology sets distributed through the Ministry of Digital Affairs open-data API.
  • Admitted source inventory: 111,386 concepts. The concept-isolated training split contains 62,838 concepts / 134,125 surfaces; evaluation contains 3,245 concepts / 6,949 surfaces, with zero surface or concept overlap.
  • Training: seed 42, learning rate 2e-6, batch size 128, relational retention weight 20, and four repeats of the legacy retention pairs. Epoch 1 was selected; the released weights are base + 0.25 * (epoch1 - base).
  • Pooling: attention-mask-aware mean pooling followed by L2 normalization.

Exact INT8 evaluation

All v1/v2 comparisons below use the same evaluator, data, canonical tokenizer, CPU path, and exact released INT8 ONNX artifacts.

Gate shipped v1 v2 Interpretation
Isolated NAER top-1 (6,949 queries) 0.1131 0.1318 +16.5% relative
Isolated NAER top-5 0.2199 0.2500 +13.7% relative
Clinical shorthand top-1 85/108 84/108 one-case trade-off
Clinical shorthand top-5 95/108 98/108 +3 cases
Card slang top-1 49/62 49/62 unchanged
Card abbreviation top-1 303/399 311/399 +8 cases
Card apposition top-1 331/371 332/371 +1 case
Card semantic macro 0.8140 0.8215 improved
Taigi clinical semantic top-1 131/141 132/141 +1 case
Production category top-1 0.7129 0.7426 improved

The fixed shorthand, card, Taigi, and production-category sets are regression sets and are partly source-contaminated; they are not presented as clean held-out evidence. One- to two-case movements are within the sampling noise already documented for these small sets. The concept-isolated NAER split is the clean evidence for the terminology gain.

The v2 INT8 file is 38,865,358 bytes. In the release-host smoke benchmark it measured 3.21 ms/text for a batch of 96 versus 3.48 ms/text for v1. This short benchmark checks for a gross latency regression; it is not a hardware-independent service-level claim.

ONNX usage

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

tokenizer = AutoTokenizer.from_pretrained("weemed/IlhaEmbed")
session = ort.InferenceSession("model_int8.onnx", providers=["CPUExecutionProvider"])


def encode(texts: list[str]) -> np.ndarray:
    batch = tokenizer(
        texts,
        max_length=32,
        truncation=True,
        padding="max_length",
        return_tensors="np",
    )
    attention = batch["attention_mask"].astype(np.int64)
    hidden = session.run(
        ["last_hidden_state"],
        {
            "input_ids": batch["input_ids"].astype(np.int64),
            "attention_mask": attention,
        },
    )[0]
    mask = attention[:, :, None].astype(np.float32)
    pooled = (hidden * mask).sum(axis=1) / np.clip(mask.sum(axis=1), 1e-9, None)
    return pooled / np.clip(np.linalg.norm(pooled, axis=1, keepdims=True), 1e-9, None)


vectors = encode(["斷腦筋", "中風", "定期心內門診-戒菸"])

Provenance and licensing

The student lineage is IBM Granite Embedding 97M Multilingual R2 (Apache-2.0). The v2 delta uses the MODA/NAER open-data medical terminology sets under Taiwan's Government Data Open License. The complete source ledger and exclusions are in SOURCES.md. Raw third-party training pairs are not redistributed.

Released code and weights are Apache-2.0. Model outputs are suggestions and must not replace clinical judgment, coding review, or terminology-system validation.

IlhaEmbed v2 繁體中文

IlhaEmbed 是供台灣臨床術語、院內簡寫與繁體中文醫療文字使用的 38.9 MB INT8 ONNX 編碼器。它適合在院內作候選檢索與語意路由,後面仍須人工或確定性規則 確認;它不是可自主決定診斷或編碼的模型。

本版取代先前誤上傳的 97.9 MB v2。新權重以已發布的 IlhaEmbed v1 為基礎,使用 數發部/國教院 13 套核准醫療學術名詞調整,再保留 epoch 1 權重位移的 25%。部署版 採 per-channel dynamic INT8、原始 25.5k canonical tokenizer,以及 attention-mask-aware mean pooling。

在完全相同的 exact INT8 評測下,來源隔離的 6,949 筆 NAER query top-1 由 0.1131 提升至 0.1318,top-5 由 0.2199 提升至 0.2500。card semantic macro 由 0.8140 提升至 0.8215,production category top-1 由 0.7129 提升至 0.7426;shorthand top-1 少 1 筆、top-5 多 3 筆,屬小型 regression set 的樣本 噪音尺度。

資料來源、排除條件與授權記載於 SOURCES.md。模型只提供建議,不取代臨床判斷、 編碼覆核或正式術語系統驗證。

Downloads last month
103
Safetensors
Model size
38.1M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for weemed/IlhaEmbed

Quantized
(12)
this model