This is a patch release with two notable fixes:
- Compatibility with
transformers
v4.45.2 is introduced; tested up to v4.48.0, including support for finetuning with ModernBERT, e.g. nomic-ai/modernbert-embed-base (see #577) - Prevent
report_to="none"
in the TrainingArguments from being ignored (see #570)
Click to expand a ModernBERT training script
from datasets import load_dataset
from setfit import SetFitModel, Trainer, TrainingArguments
# Load a dataset from the Hugging Face Hub
dataset = load_dataset("sst2")
# Simulate the few-shot regime by sampling 8 examples per class
train_dataset = dataset["train"].select(range(200))
eval_dataset = dataset["validation"].select(range(200))
test_dataset = dataset["validation"].select(range(200, len(dataset["validation"])))
# Load a SetFit model from Hub
model = SetFitModel.from_pretrained(
"nomic-ai/modernbert-embed-base",
labels=["negative", "positive"],
)
# Train for 100 steps; log, evaluate (with 100 steps)
args = TrainingArguments(
batch_size=16,
max_steps=100,
logging_steps=10,
eval_strategy="steps",
eval_steps=10,
eval_max_steps=100,
save_total_limit=-1,
)
trainer = Trainer(
model=model,
args=args,
train_dataset=train_dataset,
eval_dataset=eval_dataset,
metric="accuracy",
column_mapping={"sentence": "text", "label": "label"}
)
# Train and evaluate
trainer.train()
metrics = trainer.evaluate(test_dataset)
print(metrics)
# {'accuracy': 0.9092261904761905}
preds = model.predict(["I loved the spiderman movie!", "Pineapple on pizza is the worst 🤮"])
print(preds)
# ['positive', 'negative']
What's Changed
- The smallest typo fix in the guide by @JoramMillenaar in #580
- Let server decide default repo visibility by @Wauplin in #573
- fixed to work transformers after v4.45.2 by @DemirTonchev in #577
- [
fix
] Prevent report_to="none" from being ignored by @tomaarsen in #570 - [
tests
] Add 'save_strategy="no"' in tests to counteract transformers v4.48.0 bug by @tomaarsen in #582
New Contributors
- @JoramMillenaar made their first contribution in #580
- @DemirTonchev made their first contribution in #577
Full Changelog: v1.1.0...v1.1.1