Download Latest Version Release 0.15.1 source code.zip (2.5 MB)
Email in envelope

Get an email when there's a new version of flair

Home / v0.15.1
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2025-02-05 4.0 kB
Release 0.15.1 source code.tar.gz 2025-02-05 2.3 MB
Release 0.15.1 source code.zip 2025-02-05 2.5 MB
Totals: 3 Items   4.8 MB 0

This release fixes compatibility bugs with the newest PyTorch and SciPy versions, and adds a number of small improvements and new features.

Improvements and new features

New Model: Deep Nearest Class Means Classifier (#3532)

Adds a new Nearest Class Mean classification approach to Flair that classifies data points to the class with the closest class data mean. This approach can be used as an alternative to fitting a Softmax Classifier. It is now available for any class in Flair that implements DefaultClassifier. For instance, to train a TextClassifier with DeepNCMs you can use the following code:

:::python
from flair.data import Corpus
from flair.datasets import TREC_50
from flair.embeddings import TransformerDocumentEmbeddings
from flair.models import TextClassifier
from flair.nn import DeepNCMDecoder
from flair.trainers import ModelTrainer
from flair.trainers.plugins import DeepNCMPlugin

# load the TREC dataset
corpus: Corpus = TREC_50()

label_type = "class"

# make a transformer document embedding
document_embeddings = TransformerDocumentEmbeddings("distilbert-base-uncased", fine_tune=True)

# create the label_dictionary
label_dictionary = corpus.make_label_dictionary(label_type=label_type)

# create a text classifier with a special DeepNCM decoder
classifier = TextClassifier(
    document_embeddings,
    label_type=label_type,
    label_dictionary=label_dictionary,
    decoder=DeepNCMDecoder(
        mean_update_method="condensation",
        embeddings_size=document_embeddings.embedding_length,
        label_dictionary=label_dictionary,
    ),
)

# initialize the trainer
trainer = ModelTrainer(classifier, corpus)

# train the model using the DeepNCM plugin
trainer.fine_tune(
    "resources/taggers/deepncm_baseline",
    plugins=[DeepNCMPlugin()],
)

Contributed by @sheldon-roberts in https://github.com/flairNLP/flair/pull/3532

Datasets

Bug Fixes

New Contributors

Full Changelog: https://github.com/flairNLP/flair/compare/v0.15.0...v0.15.1

Source: README.md, updated 2025-02-05