Skip to content

[EXPERIMENT][WIP][OpenVINO] Add support for Nomic Bert - #1864

Draft
mlukasze wants to merge 3 commits into
huggingface:mainfrom
mlukasze:enable/nomic-ai-nomic-embed-text-v1.5
Draft

[EXPERIMENT][WIP][OpenVINO] Add support for Nomic Bert#1864
mlukasze wants to merge 3 commits into
huggingface:mainfrom
mlukasze:enable/nomic-ai-nomic-embed-text-v1.5

Conversation

@mlukasze

Copy link
Copy Markdown
Contributor

⚠️ AUTOMATICALLY GENERATED BY OMEGA AGENT — REQUIRES HUMAN REVIEW ⚠️
This PR was created by an AI agent as part of automated model enablement.
A human maintainer must review and approve it before it can be considered for merge.
Do NOT merge without human review and sign-off.


Known blocker requiring human action before merge: the Hub-hosted tiny test fixture optimum-intel-internal-testing/tiny-random-nomic-bert referenced in the new utils_tests.py entry does not exist yet. A creation script (create_tiny_nomic_bert.py) has been generated and needs a maintainer with write access to the optimum-intel-internal-testing org to run it and upload the result before the new CI test can pass end-to-end on the Hub-hosted path. The new tests were independently verified passing (2 passed) against an equivalent local tiny native-transformers nomic_bert model in this session (substitution reverted before commit; committed diff still points to the pending Hub path).

What does this PR do?

Adds OpenVINO export and inference support for nomic_bert (NomicBertOpenVINOConfig), enabling nomic-ai/nomic-embed-text-v1.5 and other native-transformers nomic_bert architecture models.

  • Added NomicBertOpenVINOConfig as a one-line subclass of BertOpenVINOConfig in optimum/exporters/openvino/model_configs.py, following the same minimal pattern used by sibling BERT-family models (Albert, ConvBert, Electra, RoFormer, SqueezeBert, MobileBert, RemBert). No custom ModelPatcher is required; real-model tracing succeeds cleanly.
  • Added "nomic_bert" to OVModelForFeatureExtractionIntegrationTest.SUPPORTED_ARCHITECTURES in tests/openvino/test_modeling.py.
  • Added the tiny-model registry entry to tests/openvino/utils_tests.py.
  • Added a Nomic Bert row to docs/source/openvino/models.mdx.

Verified with a real end-to-end export of nomic-ai/nomic-embed-text-v1.5 via optimum-cli (single-file openvino_model.xml/.bin layout, no fatal warnings) and OVModelForFeatureExtraction inference matching expected shape/dtype for both PyTorch and NumPy inputs. WWB accuracy validation passed on both CPU (0.9999992) and GPU (0.9999988).

Installation instructions

pip install git+https://github.com/mlukasze/optimum-intel.git@enable/nomic-ai-nomic-embed-text-v1.5
pip install --pre -U openvino openvino-tokenizers nncf --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly

Exporting cmd-line

optimum-cli export openvino --model nomic-ai/nomic-embed-text-v1.5 --task feature-extraction ov_model

Inference script

from optimum.intel import OVModelForFeatureExtraction
from transformers import AutoTokenizer

model_id = "nomic-ai/nomic-embed-text-v1.5"
model = OVModelForFeatureExtraction.from_pretrained("ov_model")
tokenizer = AutoTokenizer.from_pretrained(model_id)

inputs = tokenizer("search_query: What is TSP?", return_tensors="pt")
outputs = model(**inputs)
print(outputs.last_hidden_state.shape)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

omega-intel and others added 2 commits July 13, 2026 18:31
- Register NomicBertOpenVINOConfig as a one-line subclass of BertOpenVINOConfig
  in optimum/exporters/openvino/model_configs.py, matching the existing pattern
  used by sibling BERT-family models (Albert, ConvBert, Electra, RoFormer,
  SqueezeBert, MobileBert, RemBert).
- Add nomic_bert to OVModelForFeatureExtractionIntegrationTest.SUPPORTED_ARCHITECTURES
  in tests/openvino/test_modeling.py.
- Add nomic_bert tiny-model registry entry in tests/openvino/utils_tests.py.
- Add Nomic Bert docs row in docs/source/openvino/models.mdx.

Verified against the real nomic-ai/nomic-embed-text-v1.5 checkpoint: export via
optimum-cli produces a single-file openvino_model.xml/.bin, OVModelForFeatureExtraction
inference passes for both PyTorch and NumPy inputs, and a locally-built tiny
native-transformers nomic_bert model produces OV output matching the HF baseline
(torch.allclose, atol=1e-4). No ModelPatcher needed - tracing succeeds cleanly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

The earlier 'Apply black formatting' commit used a newer black version than
CI's pinned black~=23.1, which removed a blank line after the import block in
both files. This confused ruff==0.4.4's isort check (I001). Restored via
'ruff check --fix', verified clean against the exact CI-pinned tool versions
(black~=23.1, ruff==0.4.4).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
omega-intel added a commit to mlukasze/openvino.genai that referenced this pull request Jul 13, 2026
The new test_nomic_bert_text_embedding_pipeline_matches_hf test depends on
NomicBertOpenVINOConfig support in optimum-intel, which is only available in
an unmerged draft PR (huggingface/optimum-intel#1864). CI here installs a
stock optimum-intel release from PyPI that does not yet recognize the
nomic_bert architecture, causing a fixture-setup error (not a real bug in
this repo).

Catch the specific 'unsupported architecture' ValueError in the fixture and
skip cleanly with a message pointing at the blocking PR, following the same
pattern as other known-issue markers in this file (pytest.mark.xfail with a
ticket reference). The test will start running for real once optimum-intel
releases nomic_bert support.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

3 participants