huggingface / huggingface/setfit

AttributeError: 'SetFitHead' object has no attribute 'multitarget'

Open
#323 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
2.8k
Forks
267
Avg merge
36m
Merged PRs (30d)
5

Description

```
# Load a SetFit model from Hub
model = SetFitModel.from_pretrained(
"/content/drive/MyDrive/custom_model",
use_differentiable_head=True,
head_params={"out_features": 2},
)
model.sequence_length = 128

trainer = SetFitTrainer(
model=model,
train_dataset=train_dataset,
eval_dataset=eval_dataset,
loss_class=losses.MultipleNegativesRankingLoss(model),
metric="accuracy",
batch_size=8,
num_iterations=20, # The number of text pairs to generate for contrastive learning
num_epochs=10, # The number of epochs to use for contrastive learning
# column_mapping={"text": "text", "labels": "label"} # Map dataset columns to text/label expected by trainer
)

trainer.unfreeze(keep_body_frozen=False)

trainer.train(
num_epochs=5, # The number of epochs to train the head or the whole model (body and head)
batch_size=64,
max_length = 128,
body_learning_rate=1e-5, # The body's learning rate
learning_rate=1e-4, # The head's learning rate
l2_weight=0.0, # Weight decay on **both** the body and head. If `None`, will use 0.01.
)
```

> Outputs: "AttributeError: 'SetFitHead' object has no attribute 'multitarget'"

Above, "custom_model" is the "sentence-transformers/all-mpnet-base-v2" trained on the same hyperparameters and SetFit release version [v0.5.0](https://github.com/huggingface/setfit/releases/tag/v0.5.0).

The problem was resolved once I installed SetFit [v0.5.0](https://github.com/huggingface/setfit/releases/tag/v0.5.0), but it persists in SetFit [v0.6.0](https://github.com/huggingface/setfit/releases/tag/v0.6.0).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.