Skip to content

fix: update deprecated NVIDIA retrieval models - #9750

Open
C10H14N2O5 wants to merge 1 commit into
AstrBotDevs:masterfrom
C10H14N2O5:fix/9729-nvidia-models
Open

fix: update deprecated NVIDIA retrieval models#9750
C10H14N2O5 wants to merge 1 commit into
AstrBotDevs:masterfrom
C10H14N2O5:fix/9729-nvidia-models

Conversation

@C10H14N2O5

@C10H14N2O5 C10H14N2O5 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

TL;DR

  • Update the default NVIDIA Embedding model to nvidia/nemotron-3-embed-1b
  • Update the default embedding dimension from 1024 to 2048
  • Update the default NVIDIA Rerank model to nvidia/llama-nemotron-rerank-vl-1b-v2
  • Keep existing NVIDIA API request/response handling and legacy explicit model configurations unchanged
  • Add focused regression tests and verify provider testing, knowledge base creation, document retrieval, and reranking against the live NVIDIA API

Background

Fixes #9729

NVIDIA has marked the APIs used by some existing Embedding and Rerank models for deprecation on 2026-08-24.

AstrBot currently uses the affected models as the defaults for its NVIDIA Embedding and NVIDIA Rerank provider templates:

  • Embedding: nvidia/llama-nemotron-embed-1b-v2
  • Rerank: nv-rerank-qa-mistral-4b:1

This PR updates the defaults to the replacement models proposed in #9729:

  • Embedding: nvidia/nemotron-3-embed-1b
  • Rerank: nvidia/llama-nemotron-rerank-vl-1b-v2

The new embedding model uses a native output dimension of 2048, so the default embedding_dimensions value is updated from 1024 to 2048 as part of the migration.

This dimension update is required because AstrBot validates the actual embedding vector length against the configured provider dimension when creating a knowledge base, and the FAISS index is initialized using that configured dimension.

The existing NVIDIA Embedding and Rerank adapters already support the API contracts used by the replacement models, so no endpoint, payload, response parsing, knowledge base, or vector database logic needs to be changed.


Modifications / 改动点

NVIDIA Embedding

In astrbot/core/config/default.py:

  • Change the default model from:

    • nvidia/llama-nemotron-embed-1b-v2
  • To:

    • nvidia/nemotron-3-embed-1b
  • Change the default embedding dimension:

    • 10242048

In astrbot/core/provider/sources/nvidia_embedding_source.py:

  • Update the provider fallback model to nvidia/nemotron-3-embed-1b

The existing NVIDIA Embedding API contract is retained unchanged:

  • POST /v1/embeddings
  • Existing input, model, input_type, and encoding_format payload
  • Existing data[].embedding response parsing

NVIDIA Rerank

In astrbot/core/config/default.py:

  • Change the default model from:

    • nv-rerank-qa-mistral-4b:1
  • To:

    • nvidia/llama-nemotron-rerank-vl-1b-v2

In astrbot/core/provider/sources/nvidia_rerank_source.py:

  • Update the provider fallback model to nvidia/llama-nemotron-rerank-vl-1b-v2

The existing endpoint construction logic already generates the hosted NVIDIA endpoint for the new model:

https://ai.api.nvidia.com/v1/retrieval/nvidia/llama-nemotron-rerank-vl-1b-v2/reranking

The existing Rerank request and response handling is also retained unchanged:

  • query.text
  • passages[].text
  • Optional truncate
  • rankings[].index
  • rankings[].logit

Regression Tests

Added:

  • tests/test_nvidia_embedding_source.py
  • tests/test_nvidia_rerank_source.py

The tests cover:

  • New model defaults in the provider configuration templates
  • The new 2048 default embedding dimension
  • Provider fallback defaults
  • Preservation of explicitly configured legacy models and dimensions
  • Existing Embedding payload and response parsing
  • Existing and new Rerank endpoint construction
  • Rerank text payload generation
  • Official rankings[].index / rankings[].logit response parsing

Existing saved provider configurations are not automatically migrated or overwritten. This PR only changes the defaults used for newly created providers or when the corresponding model field is absent.

Existing knowledge base indexes are not automatically rebuilt or reindexed.

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

Test Environment

  • Windows 11 Home 64-bit
  • DisplayVersion: 25H2
  • Build: 26200.9168
  • Python: 3.12.13
  • AstrBot baseline: 4fe29759758255a35ad01ea6177a91c2293bfcd3
  • Tested commit: 74c5d2bada441b285399bb5b6aa8d9fad83bc22d

NVIDIA Embedding Default Configuration

A newly created NVIDIA Embedding provider uses:

  • Model: nvidia/nemotron-3-embed-1b
  • Embedding dimensions: 2048
嵌入模型默认页面

NVIDIA Rerank Default Configuration

A newly created NVIDIA Rerank provider uses:

  • Model: nvidia/llama-nemotron-rerank-vl-1b-v2
重排模型默认页面

NVIDIA Embedding Provider Test

The NVIDIA Embedding provider test completes successfully using the new default model and returns embeddings normally.

嵌入测试

NVIDIA Rerank Provider Test

The NVIDIA Rerank provider test completes successfully using the new default model and returns reranking results normally.

重排测试

End-to-End Knowledge Base Verification

The change was tested against a running AstrBot instance using the NVIDIA hosted APIs.

A new knowledge base was created using:

  • nvidia/nemotron-3-embed-1b as the Embedding provider
  • nvidia/llama-nemotron-rerank-vl-1b-v2 as the Rerank provider

The following workflow was verified successfully:

  • Create the NVIDIA Embedding and Rerank providers using the new defaults
  • Run the built-in provider tests successfully
  • Create a new knowledge base with the new providers
  • Generate and store 2048-dimension embeddings without dimension mismatch errors
  • Upload and index knowledge base content normally
  • Perform knowledge base retrieval successfully
  • Apply NVIDIA reranking to retrieved results successfully
  • Receive expected knowledge base results in the conversation
Knowledge Base Verification 1
知识库1
Knowledge Base Verification 2
知识库2
Knowledge Base Verification 3
知识库3

Automated Tests

The NVIDIA provider tests and related knowledge base / FAISS regression tests were executed with:

uv run pytest tests/test_nvidia_embedding_source.py tests/test_nvidia_rerank_source.py tests/unit/test_knowledge_base_service_contract.py tests/unit/test_faiss_vec_db.py -q

Result:

32 passed

The focused NVIDIA provider tests were also rerun after formatting:

9 passed

Formatting and static checks:

uv run ruff format .
uv run ruff check .

Result:

All checks passed!

A whitespace check was also performed:

git diff --check

Result:

No whitespace errors

No new dependencies are introduced by this change.

Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Update NVIDIA retrieval provider defaults to supported embedding and reranking models without changing existing API integrations.

Bug Fixes:

  • Replace deprecated NVIDIA embedding and reranking defaults with supported models.

Enhancements:

  • Update the default NVIDIA embedding dimension to 2048 while preserving explicitly configured legacy models and existing API behavior.

Tests:

  • Add regression coverage for NVIDIA provider defaults, legacy configuration compatibility, request construction, and response parsing.

@C10H14N2O5
C10H14N2O5 marked this pull request as ready for review August 20, 2026 04:16
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. feature:knowledge-base The bug / feature is about knowledge base labels Aug 20, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/test_nvidia_embedding_source.py" line_range="26-35" />
<code_context>
+    assert provider.get_model() == NEW_MODEL
+
+
+def test_nvidia_embedding_provider_preserves_explicit_old_model():
+    provider = NvidiaEmbeddingProvider(
+        {
+            "embedding_model": OLD_MODEL,
+            "embedding_dimensions": 1024,
+        },
+        {},
+    )
+
+    assert provider.model == OLD_MODEL
+    assert provider.get_dim() == 1024
+
+
</code_context>
<issue_to_address>
**suggestion (testing):** Add coverage for explicit non-default embedding dimensions with the new model

This test only checks that the old model keeps its 1024 dimension. Please also add a test that verifies an explicitly configured non-default dimension is honored for `NEW_MODEL`, e.g. instantiate `NvidiaEmbeddingProvider` with `{"embedding_model": NEW_MODEL, "embedding_dimensions": 4096}` and assert `get_dim() == 4096`.

Suggested implementation:

```python
    assert templates["NVIDIA Embedding"]["embedding_dimensions"] == 2048


def test_nvidia_embedding_provider_uses_new_fallback_model():
    provider = NvidiaEmbeddingProvider({}, {})

    assert provider.model == NEW_MODEL
    assert provider.get_model() == NEW_MODEL


def test_nvidia_embedding_provider_honors_explicit_new_model_dimensions():
    provider = NvidiaEmbeddingProvider(
        {
            "embedding_model": NEW_MODEL,
            "embedding_dimensions": 4096,
        },
        {},
    )

    assert provider.model == NEW_MODEL
    assert provider.get_dim() == 4096


NEW_MODEL = "nvidia/nemotron-3-embed-1b"
OLD_MODEL = "nvidia/llama-nemotron-embed-1b-v2"

```

If the constants `NEW_MODEL` and `OLD_MODEL` are actually defined earlier in the file (the snippet may be out of order), you may prefer to move this new test closer to the existing `test_nvidia_embedding_provider_preserves_explicit_old_model` for readability, keeping the same body. The logic of the test—instantiating `NvidiaEmbeddingProvider` with an explicit `embedding_dimensions` of `4096` for `NEW_MODEL` and asserting `get_dim() == 4096`—should remain unchanged.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread tests/test_nvidia_embedding_source.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. feature:knowledge-base The bug / feature is about knowledge base size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nvidia模型部分嵌入模型和重排序模型api即将弃用

1 participant