Hi,
I am trying to use Bert-like models to predict words in a context.
HuggingFace has a default bert-base model, but its performances are appaling (“Once upon a [MASK]” → mostly punctuation suggestions, full stop ‘.’ with 95% probabilities).
So I was trying to convert another Bert model to onnx format.
I have been following the notebook instructions and came up with this script:
from pathlib import Path
from transformers.convert_graph_to_onnx import convert
import torch
# Handles all the above steps for you
convert(framework="pt", model="google-bert/bert-large-uncased-whole-word-masking", output=Path("onnx/bert-large-uncased-whole-word-masking.onnx"), opset=14)
It runs and produces a onnx file, but when trying to use this file, I get this error:
An error occurred during model execution: "RangeError: invalid or out-of-range index". transformers:70:11852
v https://cdn.jsdelivr.net/npm/@xenova/transformers:70
I https://cdn.jsdelivr.net/npm/@xenova/transformers:70
forward https://cdn.jsdelivr.net/npm/@xenova/transformers:70
_call https://cdn.jsdelivr.net/npm/@xenova/transformers:70
_call https://cdn.jsdelivr.net/npm/@xenova/transformers:70
e https://cdn.jsdelivr.net/npm/@xenova/transformers:88
_call https://cdn.jsdelivr.net/npm/@xenova/transformers:73
e https://cdn.jsdelivr.net/npm/@xenova/transformers:88
From what I’ve read it means that there is an issue with the model itself?
I have tried a few things, like changing the task from “fill-mask” to “masked-lm” or using optimum, but I end up with the same result.
Any idea of what I’m doing wrong?
Kind regards,
A.G.