Fix remaining RAG doc examples that crash on current transformers#46044
Merged
stevhliu merged 1 commit intoMay 19, 2026
Conversation
- 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
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: rag |
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 toRagConfig, which lacks the requiredquestion_encoderandgeneratorsub-configs. Fixed by using"facebook/rag-sequence-nq"which ships a properRagConfig.Issue 1 (cont.) —
prepare_seq2seq_batchremoved:tokenizer.prepare_seq2seq_batch()no longer exists. Replaced with the standardtokenizer()call.Issue 2 — Wrong model for
RagSequenceForGeneration:The examples used
"facebook/rag-token-nq"withRagSequenceForGeneration, 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 formattingsrc/transformers/models/rag/retrieval_rag.py: Fix model IDs in all 4RagRetrieverdocstring examplesCoordination
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.