huggingface / setfit

Efficient few-shot learning with Sentence Transformers
https://hf.co/docs/setfit
Apache License 2.0
2.24k stars 222 forks source link

`max_length` parameter of `TrainingArguments` not applied #561

Open cjuracek-tess opened 1 month ago

cjuracek-tess commented 1 month ago

Description: I don't believe the max_length parameter of TrainingArguments is actually being used.

Minimal working example (borrowed from quickstart):

from datasets import load_dataset
from setfit import SetFitModel, Trainer, TrainingArguments, sample_dataset

model = SetFitModel.from_pretrained("BAAI/bge-small-en-v1.5")
dataset = load_dataset("SetFit/sst2")
train_dataset = sample_dataset(dataset["train"], label_column="label", num_samples=8)
model.labels = ["negative", "positive"]

args = TrainingArguments(
    max_length=5,
    batch_size=32,
    num_epochs=10,
)

trainer = Trainer(
    model=model,
    args=args,
    train_dataset=train_dataset,
)
trainer.train()

Expected Behavior:

Actual Behavior:

Possible Culprits:

Environment Info:

{'python': '3.11.7',
 'sentence_transformers': '3.1.1',
 'transformers': '4.44.2',
 'torch': '2.4.1',
 'accelerate': '0.34.2',
 'datasets': '3.0.0',
 'tokenizers': '0.19.1'}

Happy to look into / propose a fix if appropriate!