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

Update: ONNX conversion doc #2686

Merged
merged 8 commits into from
Jan 18, 2025
Merged

Update: ONNX conversion doc #2686

merged 8 commits into from
Jan 18, 2025

Conversation

b8zhong
Copy link
Contributor

@b8zhong b8zhong commented Jan 17, 2025

Update onnx + onnxruntime

Don't think quantize_onnx_model.py supports model name flag? Did not work w/ SPLADE++ Ensemble Distil earlier.

https://github.com/castorini/anserini/blob/master/src/main/python/onnx/quantize_onnx_model.py#L19-L24

@lintool
Copy link
Member

lintool commented Jan 17, 2025

Actually, @b8zhong you know what would be helpful? A snippet of code that compares the encoded output of the hgf model vs. the ONNX model - and take the two vectors and compute l1 norm or something - to confirm that the conversion worked.

would you might adding this?

@b8zhong
Copy link
Contributor Author

b8zhong commented Jan 18, 2025

@lintool any idea why such a large L1 diff?

L1 difference between PyTorch and ONNX outputs: 0.18276220560073853

Maybe AutoModel should actually be AutoModelForMaskedLM... ?

@lintool
Copy link
Member

lintool commented Jan 18, 2025

@b8zhong I ran into similar issues also. I believe you need to normalize the vector, see: #2645

The PR is defunct, but look at computeL2Norm.

@b8zhong
Copy link
Contributor Author

b8zhong commented Jan 18, 2025

Ty for the hint.. I don't think I would have ever thought of that 😛

There we go:
L1 difference between PyTorch and ONNX outputs: 0.009487475268542767

Acceptable I think?

@lintool
Copy link
Member

lintool commented Jan 18, 2025

Yup, that's good.

The page as written is specific to SPLADE++, can you make it generic, using SPLADE++ as an example?

@b8zhong
Copy link
Contributor Author

b8zhong commented Jan 18, 2025

Thoughts?

Copy link
Member

@lintool lintool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nits, I'll fix and then I'll merge.

docs/onnx-conversion.md Outdated Show resolved Hide resolved
docs/onnx-conversion.md Outdated Show resolved Hide resolved
@lintool lintool merged commit 8a7be85 into castorini:master Jan 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants