CoolFace
Modelpublic

OpenMed/MedPsy-1.7B-ONNX

sourceHugging Faceapache-2.0updated 17h agoView on Hugging Face
0likes247downloads
Model Card

MedPsy-1.7B - ONNX 4-bit

An ONNX conversion of `qvac/MedPsy-1.7B` for ONNX Runtime, quantized to a 4-bit body with 8-bit sensitive layers, for on-device use on Android, desktop and the browser (Transformers.js). The model is QVAC's MedPsy medical fine-tune of Qwen3; OpenMed made and published this conversion and is not affiliated with or endorsed by the model's authors.

Size and fidelity

Source (BF16)This repo
Parameters1.72 B1.72 B (unchanged)
Weights, measured from the tensors-1.32 GiB
Bits per weight, measured from the tensors166.58

Measured against the source model in FP32 on 4,092 tokens of public-domain prose (Project Gutenberg), ONNX Runtime 1.30.0, CPU:

MetricValue
Mean KL divergence of next-token distributions0.140
Top-1 next-token agreement78.7%
Perplexity change+10.7%

The FP32 export this build was quantized from matches the source model (top-1 agreement 100%), so the difference above is the quantization. The width is higher than the "4-bit" label suggests because the tensors that lose most at 4 bits, and the shared embedding table, are kept at 8 bits. Weights exclude the rotary-position tables stored in the graph.

Quantization

FieldValue
Bodyint4 asymmetric round-to-nearest (uint4 + packed zero point), block 32, fp32 scales; MatMulNBits accuracy_level 4
Kept at 8 bitsint8 asymmetric, block 32, on the tensors llama.cpp's Q4KM rule upgrades (downproj in the first and last eighth of layers and every third layer between; vproj by the same rule over attention layers)
Embedding and output headone int8 asymmetric block-32 table stored once, read by GatherBlockQuantized for the embedding and by MatMulNBits (bits 8) for the output head
Calibrationnone (round-to-nearest); no calibration data
Exportonnxruntime-genai 0.16.0 model builder, FP32 CPU graph
Quantizeronnxruntime 1.30.0 MatMulNBitsQuantizer

The tokenizer, chat template and generation defaults are the upstream files, unchanged. Exact commands, tool versions and every file's SHA-256 are in openmed_build.json; the graph's metadata_props record the source revision and the modification notice.

Architecture

FieldValue
Source model typeqwen3 (Qwen3ForCausalLM), a fine-tune of Qwen3-1.7B
Hidden size2048
Layers28, grouped-query attention
Vocabulary151,936, tied input/output embeddings

Quick start

Transformers.js (browser or Node)

js
import { pipeline } from "@huggingface/transformers";

const generator = await pipeline("text-generation", "OpenMed/MedPsy-1.7B-ONNX", { dtype: "q4" });
const messages = [
  { role: "user", content: "Explain the difference between a panic attack and a heart attack in plain language." },
];
const output = await generator(messages, { max_new_tokens: 256, do_sample: false });
console.log(output[0].generated_text.at(-1).content);

ONNX Runtime (Python, Android and elsewhere)

The graph is a standard ONNX Runtime decoder: feed input_ids, attention_mask and the past_key_values.* cache inputs, then feed each present* output back as the matching past* input on the next step. It uses ONNX Runtime's com.microsoft operators (MatMulNBits, GatherBlockQuantized, GroupQueryAttention), so run it with ONNX Runtime 1.30 or later (onnxruntime-android on Android).

Tested with onnxruntime 1.30.0 (CPU execution provider) on macOS and with Transformers.js 4.3.0, which produced identical greedy tokens. It has not yet been measured on an Android device.

File set

FileSizeSHA-256
ATTRIBUTIONS.md0.1 MiB0a88dcaf9f2c86a1…
LICENSE0.0 MiB809fa1ed21450f59…
added_tokens.json0.0 MiBc0284b582e14987f…
chat_template.jinja0.0 MiBa8b0dcfcc923bd26…
config.json0.0 MiB4a83b36bdea9961c…
generation_config.json0.0 MiBac1d241e9617d6ca…
merges.txt1.6 MiB8831e4f1a0444713…
onnx/model_q4.onnx0.3 MiB6fcba01792e3e293…
onnx/model_q4.onnx_data1,368.9 MiB4116b03a0ce23786…
special_tokens_map.json0.0 MiB76862e765266b85a…
tokenizer.json10.9 MiBaeb13307a71acd8f…
tokenizer_config.json0.0 MiBeea5f48cdcc82dda…
vocab.json2.6 MiBca10d7e9fb3ed185…

Intended use

For research and education. QVAC describes MedPsy as a model for research and educational purposes, trained on data generated from CC-BY-NC datasets; see the upstream card. It is not a medical device and not a substitute for professional medical advice, diagnosis or treatment. Outputs can be wrong; verify them.

Licence

Distributed under the Apache License 2.0, the source model's licence (with the upstream attributions in ATTRIBUTIONS.md). The ONNX graphs and weight files in onnx/ were converted and quantized from the source model's PyTorch weights by OpenMed on 2026-09-23; all other files are unchanged upstream copies.

Source: `qvac/MedPsy-1.7B` at revision 59335b96dd541b0061d748d7a6e9536e92274985. Please cite the original model when you use this conversion.