Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Deserialization of DefaultClassifier model trained with loss weights fails #3585

Closed
alanakbik opened this issue Dec 19, 2024 · 1 comment · Fixed by #3586
Closed
Labels
bug Something isn't working

Comments

@alanakbik
Copy link
Collaborator

Describe the bug

A DefaultClassifier if trained with special loss weights train normally, but the model cannot be loaded.

To Reproduce

from flair.datasets import CONLL_03
from flair.embeddings import TransformerWordEmbeddings
from flair.models import TokenClassifier
from flair.trainers import ModelTrainer

corpus = CONLL_03().downsample(0.01)

dictionary = corpus.make_label_dictionary("ner")

classifier = TokenClassifier(
    embeddings=TransformerWordEmbeddings("distilbert-base-uncased", fine_tune=False),
    label_dictionary=dictionary,
    label_type="ner",
    loss_weights={"B-PER": 0.0, "I-PER": 0.0, "E-PER": 0.0, "S-PER": 0.0},
)

trainer = ModelTrainer(classifier, corpus)

trainer.train("resources/models/tune", max_epochs=1)

Expected behavior

Correct loading of model

Logs and Stack traces

No response

Screenshots

No response

Additional Context

No response

Environment

Versions:

Flair

0.14.0

Pytorch

2.0.0+cu117

Transformers

4.39.1

GPU

True

@alanakbik alanakbik added the bug Something isn't working label Dec 19, 2024
@alanakbik
Copy link
Collaborator Author

Fix is forthcoming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant