CoolFace
Modelpublic

Hosstia/bert-base-chinese-onnx

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes
Model Card

BERT-base Chinese (ONNX INT8)

INT8 quantized ONNX export of google-bert/bert-base-chinese for feature extraction (embedding extraction).

Files

  • model_int8.onnx — INT8 quantized ONNX model (~28 MB)
  • vocab.txt — WordPiece vocabulary

Usage

The [CLS] token hidden state (position 0) is used as a 768-dim embedding vector.

python
import onnxruntime as ort
import numpy as np

session = ort.InferenceSession("model_int8.onnx")
inputs = {
    "input_ids": np.array([[...]], dtype=np.int64),
    "attention_mask": np.array([[...]], dtype=np.int64),
    "token_type_ids": np.array([[...]], dtype=np.int64),
}
last_hidden_state = session.run(None, inputs)[0]  # (batch, seq_len, 768)
cls_embedding = last_hidden_state[:, 0, :]         # (batch, 768)