Skip to content

Resolve Seq2SeqTrainingArguments Version Compatibility (eval_strategy vs evaluation_strategy) #1

Description

@purvanshjoshi

Technical Overview

Recent updates to the Hugging Face transformers library (v4.46+) officially deprecated and subsequently removed the evaluation_strategy parameter in favor of eval_strategy. Conversely, environments pinned to older stable versions of transformers (e.g., v4.22.x) do not recognize eval_strategy and will throw immediate initialization exceptions.

Affected Modules

  • File: src/train.py
  • Target Class: Seq2SeqTrainingArguments (Line 111-138)

Detailed Traceback / Context

When running on legacy runtimes:

TypeError: __init__() got an unexpected keyword argument 'eval_strategy'

When running on modern runtimes with deprecated keys:

FutureWarning: The 'evaluation_strategy' argument is deprecated and will be removed in a future version, use 'eval_strategy' instead.

Acceptance Criteria

  1. Zero-Crash Execution: The training pipeline initializes seamlessly across both legacy (v4.22.0) and modern (v4.48+) environments.
  2. Behavioral Parity: Validation evaluation steps occur at the designated save_steps and eval_steps regardless of which underlying key is utilized.
  3. No Hardcoding: The script must dynamically inspect the environment rather than using hardcoded try-except blocks that swallow other valid parameters.

Proposed Implementation Approach

Implement a dynamic parameter mapping layer inside the argument dictionary definition prior to class instantiation:

import inspect
from transformers import Seq2SeqTrainingArguments

eval_param = "eval_strategy" if hasattr(Seq2SeqTrainingArguments, "eval_strategy") else "evaluation_strategy"
training_args_dict = {
    # ... other standard arguments
    eval_param: "steps",
}
training_args = Seq2SeqTrainingArguments(**training_args_dict)

Severity & Priority

  • Severity: High (Blocks startup on mismatching environments)
  • Priority: P1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions