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

Add support for exporting custom models #556

Merged
merged 4 commits into from
Feb 19, 2024
Merged

Add support for exporting custom models #556

merged 4 commits into from
Feb 19, 2024

Conversation

xenova
Copy link
Collaborator

@xenova xenova commented Feb 1, 2024

Needed for https://huggingface.co/nomic-ai/nomic-embed-text-v1

Example:

$ python -m scripts.convert --model_id nomic-ai/nomic-embed-text-v1 --opset 12 --custom_onnx_configs '{"model":"bert"}' --trust_remote_code --task feature-extraction
Framework not specified. Using pt to export to ONNX.
<All keys matched successfully>
Using framework PyTorch: 2.1.2+cu121
Overriding 1 configuration item(s)
        - use_cache -> False
/home/codespace/.cache/huggingface/modules/transformers_modules/nomic-ai/nomic-embed-text-v1/98b6aaaf6dc0f3d1fd63f6cb72593fc3b9a8ac9e/modeling_hf_nomic_bert.py:631: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if seqlen > self._seq_len_cached:
/home/codespace/.cache/huggingface/modules/transformers_modules/nomic-ai/nomic-embed-text-v1/98b6aaaf6dc0f3d1fd63f6cb72593fc3b9a8ac9e/modeling_hf_nomic_bert.py:584: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  seqlen > self._seq_len_cached
/home/codespace/.cache/huggingface/modules/transformers_modules/nomic-ai/nomic-embed-text-v1/98b6aaaf6dc0f3d1fd63f6cb72593fc3b9a8ac9e/modeling_hf_nomic_bert.py:514: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  assert ro_dim <= x.shape[-1]
Post-processing the exported models...
Deduplicating shared (tied) weights...
Validating ONNX model models/nomic-ai/nomic-embed-text-v1/model.onnx...
        -[✓] ONNX model output names match reference model (last_hidden_state)
        - Validating ONNX Model output "last_hidden_state":
                -[✓] (2, 16, 768) matches (2, 16, 768)
                -[✓] all values close (atol: 0.0001)
The ONNX export succeeded and the exported model was saved at: models/nomic-ai/nomic-embed-text-v1

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@xenova xenova marked this pull request as ready for review February 19, 2024 12:22
@xenova xenova merged commit 351dbed into main Feb 19, 2024
4 checks passed
@xenova xenova deleted the convert-custom-models branch March 21, 2024 12:28
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