Skip to content
Back to skills

Transformers Knowledge Patch

ASecurity

Transformers

  • 25 stars
  • 0 votes
  • 0 copies
  • 12 views
  • Added September 5, 2026
ai-agentspythonrustapibackend

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill transformers-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Transformers Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Transformers Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-transformers-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-transformers-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: transformers-knowledge-patch
description: Transformers
version: "5.24.1"
license: MIT
metadata:
  author: Nevaberry
---


# Transformers knowledge patch

Load this skill when updating Transformers integrations or working on model
loading, generation, caches, processors, pipelines, training, or export.
Use the quick references below for common migrations and the topic files for
complete guidance, examples, model-specific limits, and release attribution.

## Reference index

| Reference | Topics |
| --- | --- |
| [Compatibility and API migration](references/compatibility-and-api-migration.md) | Runtime requirements, tokenizer APIs, configs, model imports and outputs, export, compilation |
| [Generation, caches, and serving](references/generation-caches-and-serving.md) | Cache migration, input preparation, decoding, continuous batching, server routes and CLI |
| [Loading, quantization, and kernels](references/loading-quantization-and-kernels.md) | Checkpoint conversion and placement, quantization formats, GGUF, attention backends, custom kernels |
| [Model and task integrations](references/model-and-task-integrations.md) | Text and multimodal checkpoints, embeddings, retrieval, OCR, vision, speech, codecs, proteins, robotics |
| [Multimodal processing and pipelines](references/multimodal-processing-and-pipelines.md) | Chat inputs, response parsing, tool schemas, image/video/audio preprocessing, pipeline behavior |
| [Training and distributed execution](references/training-and-distributed-execution.md) | Tensor/pipeline/expert parallelism, FSDP, losses, evaluation, collators, callbacks, checkpointing |

## Breaking changes and deprecations

### Cache calls, outputs, and subclasses

In 5.24.0, use `cache` in model calls, `generate()`,
`prepare_inputs_for_generation()`, masking utilities, and model outputs.
Upgrade to `peft>=0.22.0` for PEFT integration.
The legacy names `past_key_values` and `cache_params` warn and remain accepted
until 5.40.0 in `forward()` and `prepare_inputs_for_generation()` and until
6.0.0 in `generate()`. Combining a legacy name with `cache` raises `ValueError`.

```python
outputs = model(input_ids, cache=cache, use_cache=True)
cache = outputs.cache
```

Custom `Cache.update()` overrides must accept the keyword argument in
`cache.update(key_states, value_states, layer_idx, kwargs=kwargs)`.
Legacy output field names still work for reads and construction; 5.24.1
improves compatibility with remote code that uses the old cache names.

### Cache positions, capacity, cropping, and reuse

In 5.4.0, drop `cache_position` from direct `forward()` and `generate()` calls
to affected built-in models. Generation retains a compatibility path for
remote-code models that still expect it. From 5.3.0, `generate()` passes full
`input_ids` to `prepare_inputs_for_generation()`; update custom overrides
that depended on `cache_position` to slice generation inputs.

Use `get_max_length()` to query cache capacity in 5.13.0. Deprecated methods
in `cache_utils.py` are removed in 5.20.0.
In 5.15.0, `cache.crop()` takes a strictly negative offset:

```python
offset = target_length - cache.get_seq_length()
if offset < 0:
    cache.crop(offset)
```

A static cache created by `generate()` belongs to that individual call in
5.15.0. Manage an explicit cache if later calls need to reuse it.

### Tokenizer and configuration migration

In 5.0.0, tokenizing with `tokenizer.apply_chat_template()` returns a
`BatchEncoding` by default. Read `inputs["input_ids"]` or unpack the encoding
into `generate()` to pass the attention mask too.
`encode_plus()` is deprecated in favor of `tokenizer(...)`; migrate
`batch_decode()` to `decode()` and decode generated sequences individually
when they are held in a nested Python list.

Replace `as_target_tokenizer()`, `_switch_to_input_mode()`, and
`_switch_to_target_mode()` with `tokenizer(text_target=targets)`.
Custom Python tokenizers can subclass `PythonBackend`, the successor to
`PreTrainedTokenizer`. The reference covers special-token access, removed
methods, serialization, and checkpoint-specific tokenizer resolution.

In 5.4.0, `PreTrainedConfig` and model-specific config classes use dataclasses;
use keyword arguments for all constructor parameters. For affected custom
composite configs in 5.20.0, declare nested defaults in dataclass fields for
`SubConfigSpec`. In 5.23.0, processing defaults move to the processor class;
check class attributes when overriding defaults in a custom processor.

### Attention selection, imports, and outputs

Since 4.53.0, `output_attentions=True` with an incompatible backend raises a
configuration error. Select `attn_implementation="eager"` when that backend
cannot return attention weights; automatic eager fallback has been removed.
In 5.2.0, eager attention uses a supplied mask as-is. When passing a prebuilt
mask, make it broadcastable to attention scores at the actual query and key lengths.

In 5.24.0, migrate mask helpers from the removed `modeling_attn_mask_utils.py`
to `transformers.masking_utils`. The legacy module is restored in 5.24.1 for
remote-code compatibility. In 5.20.0, incidental re-exports of components from
other model modules are removed. Import affected components from the modules
that define them.

In 5.23.0, `ModelOutput` drops `rope_deltas`. In 5.24.0, generative multimodal
models return `MultimodalBaseModelOutputWithPast`,
`MultimodalCausalLMOutputWithPast`, or their MoE variants from `forward()`;
update type checks to use the shared classes.

### Loading precision, quantization, and kernels

Use `dtype` where APIs previously took `torch_dtype`; existing calls continue
to work during the transition introduced in 4.56.0. In 5.0.0,
`from_pretrained()` defaults to `dtype="auto"`, using checkpoint precision.
Set `dtype` explicitly for fixed precision. Pass 4-bit and 8-bit flags through
`quantization_config`, rather than directly to `from_pretrained()`.

Installing `kernels` does not automatically activate supported custom kernels;
pass `use_kernels=True` when loading a compatible checkpoint. In 5.18.0,
`use_mamba_kernels` is deprecated and has no effect; use `use_kernels=True`.
In 5.20.0, kernel integration requires `kernels>=0.17.2`;
`use_fallback=KernelizeFallback.ALL` uses the original implementation if
loading a kernel fails. The Hub rotary kernel is used only for CUDA inference;
training uses the regular implementation to avoid incorrect gradients.

### Distributed plans and training losses

Tensor-parallel inference and training use DTensor in 5.16.0, and the legacy
`tp_plan` argument to `from_pretrained()` enters a deprecation cycle.
In 5.23.0, migrate `ep_router` plans to `ep_dispatch_experts`.
`ep_implementation` offers all-reduce for inference and all-to-all for
training, with `deepgemm_megamoe` available for compatible experts.
In 5.24.1, `tp_plan={}` is accepted for expert parallelism on its own.

In 5.19.0, use `Trainer.loss_is_scaled_for_ga` to declare whether a custom
`compute_loss()` already scales loss for gradient accumulation.
In 5.18.0, evaluation raises on out-of-memory with `auto_find_batch_size=True`;
set an evaluation batch size that fits available memory.

### Removed integrations and audio dependencies

`transformers.agents` is removed; migrate agent code to `smolagents`.
TensorFlow and JAX backends are deprecated. Transformers drops TorchScript
and `torch.fx` support; supported export paths use Dynamo and `torch.export`.
Apex integration is removed, including Apex-backed RMSNorm; migrate mixed
precision and fused operations to native PyTorch equivalents.

In 5.23.0, `transformers[audio]` installs `torchaudio`, `soundfile`, and `soxr`.
Install `librosa` or `phonemizer` explicitly if the workflow imports them.
`Wav2Vec2ProcessorWithLM` and decoding through `pyctcdecode` and `kenlm` are
deprecated in that release.

## Frequently used features

### Continuous batching and assisted generation

In 5.19.0, use `sdpa` or `flash_attention_2` directly for continuous batching.
Their `paged|` aliases are deprecated; eager attention still uses `paged|eager`.
Continuous batching supports XPU and can run inside `torch.inference_mode()`
in 5.24.0.

```python
from transformers import AutoModelForCausalLM

model = AutoModelForCausalLM.from_pretrained(checkpoint, attn_implementation="sdpa")
outputs = model.generate_batch(inputs=token_id_batches)
```

Continuous batching supports per-request sampling settings and CPU offloading
of request state. In 5.24.0, assisted generation can use
`cache_implementation="static"` with an assistant model, and generation can
use a static cache with flex attention.

### Export persistence and loading

In 5.23.0, `export()` returns an `ExportedModel` with the original model's call
keywords and output class; its ONNX program is an `onnx_ir.Model`.
Use `save_pretrained()` in place of ONNX/OpenVINO `output_path` settings,
`push_to_hub()` to publish an export, and `register_backend()` for a custom backend.

```python
from transformers.exporters import ExportedModel, OnnxConfig, OnnxExporter

exported = OnnxExporter().export(model, inputs, OnnxConfig(dynamic=True, ort_fusions="cpu"))
exported.save_pretrained(export_dir)
reloaded = ExportedModel.from_pretrained(export_dir, device="cpu")
outputs = reloaded(**inputs)
```

In 5.24.0, loading pickled `.pt2` exports requires `trust_remote_code=True`
because unpickling can execute code. Exported ONNX, OpenVINO, and ExecuTorch
programs load without that flag. In 5.20.0, native exporters support static
and dynamic quantization, INT8 or INT4 weight-only compression, and calibration.

### Multimodal pipelines and response parsing

In 5.24.0, the any-to-any pipeline accepts media-only inputs, and multimodal
pipelines accept string assistant prefills. When returning tensors for a chat,
`input_text` contains the input messages. In 5.23.0, image, video, and audio
classification pipelines honor the checkpoint's `problem_type`.

Serving supports `response_template`; the old `response_schema` is deprecated
in 5.15.0. Response parsing supports `python-call-list` in 5.24.0, and
`unquoted_keys` handles bare keys with surrounding whitespace.
`get_json_schema()` supports `Enum` annotations in 5.23.0 and argument types
in parentheses in docstrings in 5.24.0; unsupported custom classes raise.

### Adapter training and activation memory

In 5.22.0, PEFT can train adapters such as LoRA on FP8-quantized base weights;
both dense and grouped expert FP8 matrix multiplications support backward passes.
Use `every_n_layers` to checkpoint selected layers at an interval in 5.16.0.
In 5.17.0, offload activations saved by gradient checkpointing with:

```python
model.gradient_checkpointing_enable(offload=True)
```

Files in this skill

  • SKILL.md9 KB
  • coverage.json2 KB
  • references/compatibility-and-api-migration.md9.5 KB
  • references/generation-caches-and-serving.md7.6 KB
  • references/loading-quantization-and-kernels.md8.8 KB
  • references/model-and-task-integrations.md14.9 KB
  • references/multimodal-processing-and-pipelines.md7.2 KB
  • references/training-and-distributed-execution.md6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.