Skip to content
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

onnx output shape is wrong #2211

Open
2 of 4 tasks
CallmeZhangChenchen opened this issue Mar 11, 2025 · 0 comments
Open
2 of 4 tasks

onnx output shape is wrong #2211

CallmeZhangChenchen opened this issue Mar 11, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@CallmeZhangChenchen
Copy link

CallmeZhangChenchen commented Mar 11, 2025

System Info

optimum  1.24.0

Who can help?

@michaelbenayoun

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction (minimal, reproducible, runnable)

from optimum.onnxruntime import ORTModelForFeatureExtraction
from transformers import AutoTokenizer

model_checkpoint = "moka-ai/m3e-base"
save_directory = "test"

# Load a model from transformers and export it to ONNX
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
import pdb;pdb.set_trace()
ort_model = ORTModelForFeatureExtraction.from_pretrained(model_checkpoint, export=True, from_transformers=True)

# Save the ONNX model and tokenizer
ort_model.save_pretrained(save_directory)
tokenizer.save_pretrained(save_directory)

onnx output
{'name': 'last_hidden_state',
'shape': ['batch_size', 'sequence_length', 768],
'type': 'tensor(float)'}

Expected behavior

onnx output
{'name': 'last_hidden_state',
'shape': ['batch_size', 1, 768],
'type': 'tensor(float)'}

@CallmeZhangChenchen CallmeZhangChenchen added the bug Something isn't working label Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant