-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error export onxx with body roberta #338
Comments
I have no experience with ONNX myself, so I can't really comment on what could cause this. However, perhaps @nbertagnolli has some clue of what this could be? That is, if he has some time :)
|
Happy to take a look : ). @batman-do could you send over a small working example and I'll poke around and see what I can find? |
I use setfit's version == 0.6.0 and use export_onnx in the repo, I export onnx following examples work with checkpoints |
I was running into the same error with a roberta-based model body. After some debugging I noticed the following: In tensor([[1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, And a tensor([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, In my opinion, these tensors look as if they were switched. The error then occurs because we are trying to look up both the token_type_id embedding with index 0 and the one with index 1, but there is only one embedding in the matrix (at least for the model |
I ran into this problem too with I'm adding here a short code snippet to reproduce the issues (as inspired from one of @nbertagnolli from setfit import SetFitModel
from sentence_transformers import SentenceTransformer
from setfit import SetFitHead, SetFitHead, SetFitModel
from setfit.exporters.onnx import export_onnx
# Uncomment for different scenarios
model_id = "sentence-transformers/paraphrase-multilingual-mpnet-base-v2" # Not working, "index out of range"
# model_id = "sentence-transformers/distiluse-base-multilingual-cased-v2" # Not working, tensor sizes error
# model_id = "sentence-transformers/all-MiniLM-L6-v2" # Working
# Load pretrained transformer and create a head
model_body = SentenceTransformer(model_id)
model_head = SetFitHead(in_features = model_body.get_sentence_embedding_dimension(), out_features = 4)
model = SetFitModel(model_body = model_body, model_head = model_head)
# Export model
output_path = "setfit_onnx"
export_onnx(model.model_body,
model.model_head,
opset=12,
output_path=output_path) |
Any updates on this? |
@lucasalvarezlacasa how configure export_onnx for gpu and cuda for: |
help me fix issue @tomaarsen , thanks u guys
The text was updated successfully, but these errors were encountered: