Skip to content

Fix remaining RAG doc examples that crash on current transformers#46044

Merged
stevhliu merged 1 commit into
huggingface:mainfrom
Sriniketh24:fix/rag-doc-examples-46015
May 19, 2026
Merged

Fix remaining RAG doc examples that crash on current transformers#46044
stevhliu merged 1 commit into
huggingface:mainfrom
Sriniketh24:fix/rag-doc-examples-46015

Conversation

@Sriniketh24
Copy link
Copy Markdown
Contributor

Summary

Follow-up to #46035 (merged), which fixed issue 3 of 3 from #46015. This PR addresses the remaining two issues:

Issue 1 — First doc example crashes with ValueError:
RagRetriever.from_pretrained("facebook/dpr-ctx_encoder-single-nq-base", ...) passes a DPR checkpoint to RagConfig, which lacks the required question_encoder and generator sub-configs. Fixed by using "facebook/rag-sequence-nq" which ships a proper RagConfig.

Issue 1 (cont.) — prepare_seq2seq_batch removed:
tokenizer.prepare_seq2seq_batch() no longer exists. Replaced with the standard tokenizer() call.

Issue 2 — Wrong model for RagSequenceForGeneration:
The examples used "facebook/rag-token-nq" with RagSequenceForGeneration, but the consistent checkpoint is "facebook/rag-sequence-nq".

Changes

  • docs/source/en/model_doc/rag.md: Fix model IDs, replace deprecated tokenizer call, fix formatting
  • src/transformers/models/rag/retrieval_rag.py: Fix model IDs in all 4 RagRetriever docstring examples

Coordination

closes: #46015


AI-assisted: Yes — Claude Code (Opus 4.6) was used to identify the fixes and draft this PR. All changes were reviewed by the human submitter.

- Use `facebook/rag-sequence-nq` instead of `facebook/dpr-ctx_encoder-single-nq-base`
  for `RagRetriever.from_pretrained()`. The DPR checkpoint lacks the
  `question_encoder` and `generator` sub-configs that `RagConfig` requires,
  causing a `ValueError` on construction.
- Replace removed `tokenizer.prepare_seq2seq_batch()` with `tokenizer()`
  in the doc page examples.
- Use consistent `facebook/rag-sequence-nq` checkpoint for
  `RagSequenceForGeneration` instead of `facebook/rag-token-nq`.

closes: huggingface#46015
@github-actions
Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: rag

Copy link
Copy Markdown
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

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

thanks for the fix!

@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.

@stevhliu stevhliu added this pull request to the merge queue May 19, 2026
Merged via the queue into huggingface:main with commit a5c05e3 May 19, 2026
18 checks 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.

Outdated examples about RAG

3 participants