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.
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)