| Model | FP32 | Task |
|---|---|---|
| mmBERT-small | model_mask.onnx | masked word prediction |
# onnxruntime-gpu for run it on GPU
pip install onnxruntime tokenizers numpy
Every model folder has the same layout:
src/helper.py = onnx session builder (provider selection, threads, memory options)src/example.py = full pipeline: tokenization, mask of one word, batching, inference, softmaxonnx/ = the model fileRun the commands from the repository root.
python3 mmBERT-small/src/example.py
0.760337 | ▁Paris | The capital of France is <mask>.
0.044998 | ▁Strasbourg | The capital of France is <mask>.
0.044616 | ▁Nice | The capital of France is <mask>.
0.289269 | ▁Roma | La capitale dell'Italia è <mask>.
0.164299 | ▁Firenze | La capitale dell'Italia è <mask>.
0.131539 | ▁Milano | La capitale dell'Italia è <mask>.
0.329165 | 東京 | 日本の首都は<mask>です。
0.121238 | 京都 | 日本の首都は<mask>です。
0.119146 | 大阪 | 日本の首都は<mask>です。
Note:
model_mask.onnx = the original graph with one more input, mask_index: the vocabulary projection runs only[batch, 256000] instead of [batch, length, 256000] (same values, about 4 times faster).input_ids [batch, length], attention_mask [batch, length], mask_index [batch, 1], all int64.tokenizers library: it adds <bos> and <eos>.<mask> (id 4): writing <mask><pad> (id 0) with attention_mask 0, per batch to the longest sequence.▁ at the start of a token is the leading space.