transformers - 💡(How to fix) Fix DOC: set_training() documents parameter as `num_train_epochs` but actual parameter name is `num_epochs` [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

In TrainingArguments.set_training(), the Args section of the docstring documents the parameter as num_train_epochs but the actual function parameter is num_epochs.

Root Cause

In TrainingArguments.set_training(), the Args section of the docstring documents the parameter as num_train_epochs but the actual function parameter is num_epochs.

Fix Action

Fixed

Code Example

def set_training(
    self,
    ...
    num_epochs: float = 3,
    ...
 

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

---

Result:
RAW_BUFFERClick to expand / collapse

System Info

Description

In TrainingArguments.set_training(), the Args section of the docstring documents the parameter as num_train_epochs but the actual function parameter is num_epochs.

Location

File: src/transformers/training_args.py, around line 2183

Function signature (actual parameter):

def set_training(
    self,
    ...
    num_epochs: float = 3,
    ...
 

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

```python
from transformers import TrainingArguments

args = TrainingArguments("./working_dir")

# Following the documented parameter name as shown in set_training()'s docstring:
args.set_training(num_train_epochs=5)

Result:

TypeError: set_training() got an unexpected keyword argument 'num_train_epochs'

The actual parameter name is num_epochs (see src/transformers/training_args.py line 2160), but the docstring at line 2183 documents it as num_train_epochs, misleading users into a TypeError.

Expected behavior

The docstring should match the actual parameter name. Either:

  1. Rename the docstring entry from num_train_epochs to num_epochs (matches current code, less invasive), OR
  2. Rename the parameter from num_epochs to num_train_epochs (matches the rest of TrainingArguments which uses num_train_epochs as the field name everywhere else)

The first fix is safer and is what this issue suggests.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The docstring should match the actual parameter name. Either:

  1. Rename the docstring entry from num_train_epochs to num_epochs (matches current code, less invasive), OR
  2. Rename the parameter from num_epochs to num_train_epochs (matches the rest of TrainingArguments which uses num_train_epochs as the field name everywhere else)

The first fix is safer and is what this issue suggests.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING