From df772fc6b2c0e51f0c2761c8f4e431774989be68 Mon Sep 17 00:00:00 2001 From: burrows99 Date: Mon, 16 Nov 2026 01:33:18 +0000 Subject: [PATCH] [docs] Fix imports that fail on main in four English docs - tapas.md: AdamW was removed from transformers; import it from torch.optim - trocr.md: BitsandBytesConfig -> BitsAndBytesConfig - persimmon.md: there is no PersimmonTokenizer; load it with AutoTokenizer - testing.md: MemoryCleanupMixin lives in tests/test_memory_cleanup_mixin.py, not transformers.testing_utils; also import unittest, which the snippet uses --- docs/source/en/model_doc/persimmon.md | 4 ++-- docs/source/en/model_doc/tapas.md | 4 +++- docs/source/en/model_doc/trocr.md | 4 ++-- docs/source/en/testing.md | 6 +++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/source/en/model_doc/persimmon.md b/docs/source/en/model_doc/persimmon.md index 147e22f51b66..e3aec67f13db 100644 --- a/docs/source/en/model_doc/persimmon.md +++ b/docs/source/en/model_doc/persimmon.md @@ -67,11 +67,11 @@ tar -xvf 8b_base_model_release.tar Thereafter, models can be loaded via: ```python -from transformers import PersimmonForCausalLM, PersimmonTokenizer +from transformers import AutoTokenizer, PersimmonForCausalLM model = PersimmonForCausalLM.from_pretrained("/output/path", device_map="auto") -tokenizer = PersimmonTokenizer.from_pretrained("/output/path") +tokenizer = AutoTokenizer.from_pretrained("/output/path") ``` - Perismmon uses a `sentencepiece` based tokenizer, with a `Unigram` model. It supports bytefallback, which is only available in `tokenizers==0.14.0` for the fast tokenizer. diff --git a/docs/source/en/model_doc/tapas.md b/docs/source/en/model_doc/tapas.md index 9d1ae30ca639..993e3128f901 100644 --- a/docs/source/en/model_doc/tapas.md +++ b/docs/source/en/model_doc/tapas.md @@ -220,7 +220,9 @@ index) and batch encode each table with its questions. This will make sure that You can then fine-tune [`TapasForQuestionAnswering`] as follows (shown here for the weak supervision for aggregation case): ```python -from transformers import AdamW, TapasConfig, TapasForQuestionAnswering +from torch.optim import AdamW + +from transformers import TapasConfig, TapasForQuestionAnswering # this is the default WTQ configuration diff --git a/docs/source/en/model_doc/trocr.md b/docs/source/en/model_doc/trocr.md index 59c0f81c344d..fff9aee1b9a2 100644 --- a/docs/source/en/model_doc/trocr.md +++ b/docs/source/en/model_doc/trocr.md @@ -67,12 +67,12 @@ The example below uses [bitsandbytes](../quantization/bitsandbytes) to quantize ```python # pip install bitsandbytes accelerate -from transformers import TrOCRProcessor, VisionEncoderDecoderModel, BitsandBytesConfig +from transformers import TrOCRProcessor, VisionEncoderDecoderModel, BitsAndBytesConfig import requests from PIL import Image # Set up the quantization configuration -quantization_config = BitsandBytesConfig(load_in_8bit=True) +quantization_config = BitsAndBytesConfig(load_in_8bit=True) # Use a large checkpoint for a more noticeable impact processor = TrOCRProcessor.from_pretrained("microsoft/trocr-large-handwritten") diff --git a/docs/source/en/testing.md b/docs/source/en/testing.md index 92901beffa98..ade9822a7952 100644 --- a/docs/source/en/testing.md +++ b/docs/source/en/testing.md @@ -370,9 +370,13 @@ Mixin tests use tiny configs with random weights to verify model behavior quickl Place integration tests in a separate test class, mark them with `@slow`, and mix in `MemoryCleanupMixin`. Each test downloads real weights, runs inference, and checks outputs against expected values. The mixin frees the memory each test takes and runs the test methods under `torch.no_grad()` — see [Releasing memory between tests](#releasing-memory-between-tests) for what it does and how to opt out. ```py +import unittest + import torch from transformers import AutoTokenizer -from transformers.testing_utils import MemoryCleanupMixin, require_torch, slow, torch_device +from transformers.testing_utils import require_torch, slow, torch_device + +from ...test_memory_cleanup_mixin import MemoryCleanupMixin class MyModelIntegrationTest(MemoryCleanupMixin, unittest.TestCase): @slow