# Python text classification libraries

Python text classification libraries assign one or more labels to a piece of text, such as a topic, an intent, or a sentiment. A zero-shot model scores labels chosen at runtime rather than labels fixed during training. These libraries let support tools, content filters, and AI agents route text by what it says.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [scikit-learn](#scikit-learn) | 214.9M | 68.2K | Sep 2026 | BSD-3-Clause |
| [Transformers](#transformers) | 120.5M | 169.1K | Nov 2026 | Apache-2.0 |
| [nltk](#nltk) | 48.7M | 14.8K | Oct 2026 | Apache-2.0 |
| [spacy](#spacy) | 25.2M | 34.0K | Oct 2026 | MIT |
| [catboost](#catboost) | 6.9M | 9.2K | Feb 2026 | Apache-2.0 |
| [textblob](#textblob) | 3.2M | 9.6K | Jul 2026 | MIT |
| [fastText](#fasttext) | 2.2M | 26.5K | Jun 2024 | MIT |
| [keras-hub](#keras-hub) | 471.7K | 999 | Nov 2026 | Apache-2.0 |

Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[scikit-learn](#scikit-learn) has the most monthly downloads in this comparison, at 214.9M, a count that covers all its machine learning work.

## Capabilities

| Library | Zero-shot custom labels | CSR feature input |
| --- | --- | --- |
| [scikit-learn](#scikit-learn) | No | Yes |
| [Transformers](#transformers) | Yes | No |
| [nltk](#nltk) | No | No |
| [spacy](#spacy) | No | No |
| [catboost](#catboost) | No | Yes |
| [textblob](#textblob) | No | No |
| [fastText](#fasttext) | No | No |
| [keras-hub](#keras-hub) | No | No |

## Libraries

### scikit-learn

[GitHub](https://github.com/scikit-learn/scikit-learn) · [PyPI](https://pypi.org/project/scikit-learn) · [Docs](https://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html)

Combines a text feature vectorizer with a classifier in a pipeline.

- Downloads / mo: 214.9M
- Stars: 68.2K
- Last release: 1.9.1
- License: BSD-3-Clause
- Capabilities: [From the scikit-learn docs](https://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html)

**Strengths**

- **Combines text with structured features.** Transform separate input columns and concatenate their features before classification.
- **Tunes complete text pipelines.** Search vectorizer and classifier settings together.

**Watch out for**

- **Unigrams lose word order.** Use word n-grams when short phrases carry the label.

```sh
python -m pip install scikit-learn==1.9.1
```

**mozilla/bugbug** (581 stars)

[mozilla/bugbug](https://github.com/mozilla/bugbug) 

```python
def __init__(self, lemmatization=False):
    BugModel.__init__(self, lemmatization)

    self.cross_validation_enabled = False
    self.calculate_importance = False
    # The test set is made of the most recent bugs (see train_test_split), so
    # retrain on all bugs after the evaluation.
    self.entire_dataset_training = True

    feature_extractors = [
        bug_features.HasSTR(),
        bug_features.Severity(),
        bug_features.Keywords(),
        bug_features.HasCrashSignature(),
        bug_features.HasURL(),
        bug_features.HasW3CURL(),
        bug_features.HasGithubURL(),
        bug_features.Whiteboard(),
        bug_features.Patches(),
        bug_features.Landings(),
        bug_features.BugReporter(),
        # Bugs are rolled back to their creation, so this is the product the bug
        # was filed in.
        bug_features.Product(),
        bug_features.OpSys(),
        bug_features.Platform(),
        bug_features.MentionedPathsComponents(),
    ]

    cleanup_functions = [
        feature_cleanup.fileref(),
        feature_cleanup.url(),
        feature_cleanup.synonyms(),
    ]

    self.extraction_pipeline = Pipeline(
        [
            (
                "bug_extractor",
                bug_features.BugExtractor(
                    feature_extractors, cleanup_functions, rollback=True
                ),
            ),
        ]
    )

    # A linear model on sparse n-gram features is more accurate (and faster
    # to train) than gradient boosted trees for this task. The L1 penalty
    # keeps the weights sparse, so the model stays small despite the large
    # vocabulary. Probabilities are calibrated on out-of-fold predictions.
    estimator = CalibratedClassifierCV(
        LinearSVC(penalty="l1", dual=False),
        method="isotonic",
        cv=3,
        ensemble=False,
        n_jobs=3,
    )

    self.clf = Pipeline(
        [
            (
                "union",
                ColumnTransformer(
                    [
                        ("data", DictVectorizer(), "data"),
                        (
                            "title",
                            self.text_vectorizer(
                                min_df=2,
                                ngram_range=(1, 2),
                                sublinear_tf=True,
                                max_features=30000,
                            ),
                            "title",
                        ),
                        (
                            "title_char",
                            TfidfVectorizer(
                                min_df=3,
                                analyzer="char_wb",
                                ngram_range=(2, 5),
                                sublinear_tf=True,
                                max_features=30000,
                            ),
                            "title",
                        ),
                        (
                            "comments",
                            self.text_vectorizer(
                                min_df=2,
                                ngram_range=(1, 2),
                                sublinear_tf=True,
                                max_features=80000,
                            ),
                            "comments",
                        ),
                    ]
                ),
            ),
            (
                "estimator",
                estimator,
            ),
        ]
    )
```

[bugbug/models/component.py](https://github.com/mozilla/bugbug/blob/a28668766fc58c0b4564fcfbe981eada71058313/bugbug/models/component.py#L43-L147) · [More projects using scikit-learn →](https://dashboard.exa.ai/playground/search?q=Python%20applications%20using%20scikit-learn%20for%20custom%20document%20labels%20multilabel%20classification%20training%20evaluation%20and%20zero%20shot%20inference&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
from sklearn.pipeline import Pipeline
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression

model = Pipeline([("text", TfidfVectorizer()), ("classifier", LogisticRegression())])
model.fit(["invoice due", "pay invoice", "reset password", "forgot password"],
          ["billing", "billing", "account", "account"])
print(model.predict(["invoice"]))

```

From [plot_grid_search_text_feature_extraction.py](https://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html)

### Transformers

[GitHub](https://github.com/huggingface/transformers) · [PyPI](https://pypi.org/project/transformers) · [Docs](https://huggingface.co/docs/transformers/v5.23.0/en/main_classes/pipelines)

Scores runtime candidate labels through sequence models trained for natural language inference.

- Downloads / mo: 120.5M
- Stars: 169.1K
- Last release: 5.23.0
- License: Apache-2.0
- Capabilities: [From the Transformers docs](https://huggingface.co/docs/transformers/v5.23.0/en/main_classes/pipelines)

**Strengths**

- **Accepts labels at prediction time.** Choose candidate classes without fixing the output labels during model training.
- **Fine-tunes sequence classifiers.** Train a classification model with the task’s label mappings.

**Watch out for**

- **Zero-shot needs entailment models.** Use models trained to judge whether text supports a candidate label.
- **Long zero-shot inputs are truncated.** Split long documents before candidate-label scoring.

```sh
python -m pip install 'transformers[torch]==5.23.0'
```

**deepset-ai/haystack** (27.0K stars)

[deepset-ai/haystack](https://github.com/deepset-ai/haystack) 

```python
def run(self, text: str) -> dict[str, str]:
    """
    Routes the text strings to different connections based on a category label.

    :param text: A string of text to route.
    :returns:
        A dictionary with the label as key and the text as value.

    :raises TypeError:
        If the input is not a str.
    :raises RuntimeError:
        If the pipeline has not been loaded because warm_up() was not called before.
    """
    if self.pipeline is None:
        raise RuntimeError(
            "The component TransformersZeroShotTextRouter wasn't warmed up. Run 'warm_up()' before calling 'run()'."
        )

    if not isinstance(text, str):
        raise TypeError("TransformersZeroShotTextRouter expects a str as input.")

    prediction = self.pipeline([text], candidate_labels=self.labels, multi_label=self.multi_label)
    predicted_scores = prediction[0]["scores"]
    max_score_index = max(range(len(predicted_scores)), key=predicted_scores.__getitem__)
    label = prediction[0]["labels"][max_score_index]
    return {label: text}

```

[haystack/components/routers/zero_shot_text_router.py](https://github.com/deepset-ai/haystack/blob/dc1d72228adeaac8e657d3a4946c3e246d45784d/haystack/components/routers/zero_shot_text_router.py#L192-L217) · [More projects using Transformers →](https://dashboard.exa.ai/playground/search?q=Python%20applications%20using%20transformers%20for%20custom%20document%20labels%20multilabel%20classification%20training%20evaluation%20and%20zero%20shot%20inference&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
from transformers import pipeline

classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli", device=-1)
print(classifier("Please reset my password", candidate_labels=["billing", "account"]))

```

From [zero_shot_classification.py](https://huggingface.co/docs/transformers/v5.23.0/en/main_classes/pipelines)

### nltk

[GitHub](https://github.com/nltk/nltk) · [PyPI](https://pypi.org/project/nltk) · [Docs](https://www.nltk.org/api/nltk.classify.naivebayes.html)

Provides a natural language toolkit.

- Downloads / mo: 48.7M
- Stars: 14.8K
- Last release: 3.10.4
- License: Apache-2.0
- Capabilities: [From the nltk docs](https://www.nltk.org/api/nltk.classify.naivebayes.html)

```sh
python -m pip install nltk==3.10.4
```

**sloria/TextBlob** (9.6K stars)

[sloria/TextBlob](https://github.com/sloria/TextBlob) 

```python
def train(self, *args, **kwargs):
    """Train the classifier with a labeled feature set and return
    the classifier. Takes the same arguments as the wrapped NLTK class.
    This method is implicitly called when calling ``classify`` or
    ``accuracy`` methods and is included only to allow passing in arguments
    to the ``train`` method of the wrapped NLTK class.

    .. versionadded:: 0.6.2

    :rtype: A classifier
    """
    try:
        self.classifier = self.nltk_class.train(
            self.train_features, *args, **kwargs
        )
        return self.classifier
    except AttributeError as error:
        raise ValueError(
            "NLTKClassifier must have a nltk_class variable that is not None."
        ) from error
```

[src/textblob/classifiers.py](https://github.com/sloria/TextBlob/blob/629e60e0b1cfc5fa6d7df4bed9ccc7b98ac8917d/src/textblob/classifiers.py#L235-L254) · [More projects using nltk →](https://dashboard.exa.ai/playground/search?q=nltk%20GitHub%20projects)

**Quickstart**

```python
from nltk.classify import NaiveBayesClassifier

training = [({"invoice": True}, "billing"), ({"password": True}, "account")]
classifier = NaiveBayesClassifier.train(training)
print(classifier.classify({"invoice": True}))

```

From [nltk.classify.naivebayes.html](https://www.nltk.org/api/nltk.classify.naivebayes.html)

### spacy

[GitHub](https://github.com/explosion/spaCy) · [PyPI](https://pypi.org/project/spacy) · [Docs](https://spacy.io/api/textcategorizer)

Processes natural language in Python.

- Downloads / mo: 25.2M
- Stars: 34.0K
- Last release: 3.8.18
- License: MIT
- Capabilities: [From the spacy docs](https://spacy.io/api/textcategorizer)

```sh
python -m pip install spacy==3.8.18
```

**explosion/prodigy-recipes** (512 stars)

[explosion/prodigy-recipes](https://github.com/explosion/prodigy-recipes) 

```python
@prodigy.recipe(
    "textcat.teach",
    dataset=("The dataset to use", "positional", None, str),
    spacy_model=("The base model", "positional", None, str),
    source=("The source data as a JSONL file", "positional", None, str),
    label=("One or more comma-separated labels", "option", "l", split_string),
    patterns=("Optional match patterns", "option", "p", str),
    exclude=("Names of datasets to exclude", "option", "e", split_string),
)
def textcat_teach(
    dataset: str,
    spacy_model: str,
    source: str,
    label: Optional[List[str]] = None,
    patterns: Optional[str] = None,
    exclude: Optional[List[str]] = None,
):
    """
    Collect the best possible training data for a text classification model
    with the model in the loop. Based on your annotations, Prodigy will decide
    which questions to ask next.
    """
    labels = label
    # Load the stream from a JSONL file and return a generator that yields a
    # dictionary for each example in the data.
    stream = JSONL(source)

    # Load the spaCy model
    nlp = spacy.load(spacy_model)

    # Specify the name of the classifier pipeline.
    name = "textcat_multilabel"

    # Initialize classification pipeline from scratch (using a dummy training example) or from the base model if available.
    if name not in nlp.pipe_names:
        pipe = nlp.add_pipe(name)
        # dummy doc
        doc = nlp.make_doc("hello")
        # dummy weights
        cats = {label: 0.5 for label in labels} 
        pipe.initialize(get_examples=lambda: [Example.from_dict(doc, {"cats":cats})])
    else:
        pipe = nlp.get_pipe(name)

    # Initialize Prodigy's text classifier model, which outputs
    # (score, example) tuples
    model = TextClassifier(nlp, labels, name)

    if patterns is None:
        # No patterns are used, so just use the model to suggest examples
        # and only use the model's update method as the update callback
        predict = model
        update = model.update
    else:
        # Initialize the pattern matcher and load in the JSONL patterns.
        # Set the matcher to not label the highlighted spans, only the text.
        matcher = PatternMatcher(
            nlp,
            prior_correct=5.0,
            prior_incorrect=5.0,
            label_span=False,
            label_task=True,
        )
        matcher = matcher.from_disk(patterns)
        # Combine the NER model and the matcher and interleave their
        # suggestions and update both at the same time
        predict, update = combine_models(model, matcher)

    # Use the prefer_uncertain sorter to focus on suggestions that the model
    # is most uncertain about (i.e. with a score closest to 0.5). The model
    # yields (score, example) tuples and the sorter yields just the example
    stream = prefer_uncertain(predict(stream))

    return {
        "view_id": "classification",  # Annotation interface to use
        "dataset": dataset,  # Name of dataset to save annotations
        "stream": stream,  # Incoming stream of examples
        "update": update,  # Update callback, called with batch of answers
        "exclude": exclude,  # List of dataset names to exclude
        "config": {"lang": nlp.lang},  # Additional config settings, mostly for app UI
    }
```

[textcat/textcat_teach.py](https://github.com/explosion/prodigy-recipes/blob/428bccb5a04ecfe6211049824aaf735a5907861c/textcat/textcat_teach.py#L15-L95) · [More projects using spacy →](https://dashboard.exa.ai/playground/search?q=spacy%20GitHub%20projects)

**Quickstart**

```python
import spacy
from spacy.training import Example

nlp = spacy.blank("en")
nlp.add_pipe("textcat")
samples = [("invoice payment", {"billing": 1.0, "account": 0.0}),
           ("reset password", {"billing": 0.0, "account": 1.0})]
examples = [Example.from_dict(nlp.make_doc(text), {"cats": cats}) for text, cats in samples]
optimizer = nlp.initialize(get_examples=lambda: examples)
nlp.update(examples, sgd=optimizer)
print(nlp("invoice").cats)

```

From [README.md](https://spacy.io/api/textcategorizer)

### catboost

[GitHub](https://github.com/catboost/catboost) · [PyPI](https://pypi.org/project/catboost) · [Docs](https://catboost.ai/docs/en/features/text-features)

Provides the CatBoost Python package.

- Downloads / mo: 6.9M
- Stars: 9.2K
- Last release: 1.2.10
- License: Apache-2.0
- Capabilities: [From the catboost docs](https://catboost.ai/docs/en/features/text-features)

```sh
python -m pip install catboost==1.2.10
```

**catboost/tutorials** (1.1K stars)

[catboost/tutorials](https://github.com/catboost/tutorials) 

```python
def fit_catboost_one_column(X_train, X_test, y_train, y_test, catboost_params={}, verbose=0):
    learn_pool = Pool(X_train, y_train, text_features=[0])
    test_pool = Pool(X_test, y_test, text_features=[0])
    
    catboost_default_params = {
        'iterations': 1000,
        'learning_rate': 0.03,
        'eval_metric': 'Accuracy',
    }
    
    catboost_default_params.update(catboost_params)
    
    model = CatBoostClassifier(**catboost_default_params)
    model.fit(learn_pool, eval_set=test_pool, verbose=verbose)

    return model
```

[text_features/text_features_in_catboost.ipynb](https://github.com/catboost/tutorials/blob/1409fb3faab40861542f7962b4310833305ed2c0/text_features/text_features_in_catboost.ipynb?plain=1#L1647-L1664) · [More projects using catboost →](https://dashboard.exa.ai/playground/search?q=catboost%20GitHub%20projects)

**Quickstart**

```python
from catboost import CatBoostClassifier

texts = [["invoice payment"]] * 10 + [["password login"]] * 10
labels = ["billing"] * 10 + ["account"] * 10
model = CatBoostClassifier(iterations=5, text_features=[0], verbose=False)
model.fit(texts, labels)
print(model.predict([["invoice payment"]]))

```

From [README.md](https://catboost.ai/docs/en/concepts/python-reference_catboostclassifier)

### textblob

[GitHub](https://github.com/sloria/TextBlob) · [PyPI](https://pypi.org/project/textblob) · [Docs](https://textblob.readthedocs.io/en/dev/classifiers.html)

Processes text with sentiment analysis, part-of-speech tagging, and noun phrase parsing.

- Downloads / mo: 3.2M
- Stars: 9.6K
- Last release: 0.20.1
- License: MIT
- Capabilities: [From the textblob docs](https://textblob.readthedocs.io/en/dev/classifiers.html)

```sh
python -m pip install textblob==0.20.1 && python -m textblob.download_corpora
```

**Roibal/Cryptocurrency-Trading-Bots-Python-Beginner-Advance** (1.4K stars)

[Roibal/Cryptocurrency-Trading-Bots-Python-Beginner-Advance](https://github.com/Roibal/Cryptocurrency-Trading-Bots-Python-Beginner-Advance) 

```python
def get_tweet_sentiment(self, tweet):
    '''
    Utility function to classify sentiment of passed tweet
    using textblob's sentiment method
    '''
    # create TextBlob object of passed tweet text
    analysis = TextBlob(self.clean_tweet(tweet))
    # set sentiment
    if analysis.sentiment.polarity > 0:
        return 'positive'
    elif analysis.sentiment.polarity == 0:
        return 'neutral'
    else:
        return 'negative'

```

[Crypto-Trading-Bots/Crypto_Sentiment_Analysis_SocialMedia_Bot.py](https://github.com/Roibal/Cryptocurrency-Trading-Bots-Python-Beginner-Advance/blob/6cd9f639ac7f9d914d556738ca3aeeef53618146/Crypto-Trading-Bots/Crypto_Sentiment_Analysis_SocialMedia_Bot.py#L79-L92) · [More projects using textblob →](https://dashboard.exa.ai/playground/search?q=textblob%20GitHub%20projects)

**Quickstart**

```python
from textblob.classifiers import NaiveBayesClassifier

training = [("invoice payment", "billing"), ("reset password", "account")]
classifier = NaiveBayesClassifier(training)
print(classifier.classify("invoice"))

```

From [classifiers.html](https://textblob.readthedocs.io/en/dev/classifiers.html)

### fastText

[GitHub](https://github.com/facebookresearch/fastText) · [PyPI](https://pypi.org/project/fasttext) · [Docs](https://fasttext.cc/docs/en/python-module.html)

Trains supervised text classifiers through train_supervised.

- Downloads / mo: 2.2M
- Stars: 26.5K
- Last release: 0.9.3
- License: MIT
- Capabilities: [From the fastText docs](https://fasttext.cc/docs/en/python-module.html)

**Strengths**

- **Returns labels with probabilities.** Use predict to retrieve labels and their corresponding probabilities.
- **Compresses trained classifier files.** Quantize supervised models after training to reduce their stored size.

**Watch out for**

- **Upstream repository is archived.** The original repository is now read-only.
- **Needs labeled training examples.** Supply documents with their corresponding category labels before training.

```sh
python -m pip install fasttext==0.9.3
```

**mlfoundations/dclm** (1.5K stars)

[mlfoundations/dclm](https://github.com/mlfoundations/dclm) 

```python
def main():
    args = get_args()
    random.seed(args.seed)
    train_input = args.input

    train_was_split = False
    if args.valid_input:
        valid_input = args.valid_input
    elif args.valid_frac > 0:
        train_input, valid_input = split_train_val(train_input, args.valid_frac)
        train_was_split = True
    else:
        valid_input = None

    hyperparams = {'lr': args.lr, 'dim': args.dim, 'ws': args.ws, 'epoch': args.epoch, 'minCount': args.minCount, 'wordNgrams': args.wordNgrams}
    model = fasttext.train_supervised(input=train_input, **hyperparams)

    print("Training results")
    print_results(*model.test(train_input))

    if valid_input is not None:
        print("Validation results")
        print_results(*model.test(valid_input))

    # Save the model
    output = args.name if args.name.endswith(".bin") else args.name + ".bin"
    model.save_model(os.path.join(args.output_dir, output))

    if train_was_split:
        os.remove(train_input)
        os.remove(valid_input)

```

[baselines/train_fasttext_classifier.py](https://github.com/mlfoundations/dclm/blob/361714bdd60bb9b7f4b2d8354cebbf0dec0c329e/baselines/train_fasttext_classifier.py#L55-L85) · [More projects using fastText →](https://dashboard.exa.ai/playground/search?q=Python%20applications%20using%20fasttext%20for%20custom%20document%20labels%20multilabel%20classification%20training%20evaluation%20and%20zero%20shot%20inference&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
from pathlib import Path
from tempfile import TemporaryDirectory
import fasttext

with TemporaryDirectory() as directory:
    training = Path(directory) / "train.txt"
    training.write_text("__label__billing invoice payment\n__label__account reset password\n", encoding="utf-8")
    model = fasttext.train_supervised(str(training), minCount=1)
    print(model.get_labels())

```

From [README.md](https://fasttext.cc/docs/en/python-module.html)

### keras-hub

[GitHub](https://github.com/keras-team/keras-hub) · [PyPI](https://pypi.org/project/keras-hub) · [Docs](https://keras.io/keras_hub/api/base_classes/text_classifier/)

Provides pretrained models for Keras.

- Downloads / mo: 471.7K
- Stars: 999
- Last release: 0.33.0
- License: Apache-2.0
- Capabilities: [From the keras-hub docs](https://keras.io/keras_hub/api/base_classes/text_classifier/)

```sh
python -m pip install keras-hub==0.33.0 tensorflow==2.21.0
```

**keras-team/keras-io** (3.0K stars)

[keras-team/keras-io](https://github.com/keras-team/keras-io) 

```python
def preprocess(x, y=None, sequence_length=256):
    x = tokenizer(x)
    x = packer(x, sequence_length=sequence_length)
    x = {
        "token_ids": x,
        "padding_mask": x != tokenizer.pad_token_id,
    }
    return keras.utils.pack_x_y_sample_weight(x, y)
```

[guides/keras_hub/getting_started.py](https://github.com/keras-team/keras-io/blob/f5891b3cd4df69f6bd5a3c26ea92310f3a973626/guides/keras_hub/getting_started.py#L637-L644) · [More projects using keras-hub →](https://dashboard.exa.ai/playground/search?q=keras-hub%20GitHub%20projects)

**Quickstart**

```python
import os
os.environ["KERAS_BACKEND"] = "tensorflow"
import tensorflow as tf
import keras_hub

training = tf.data.Dataset.from_tensor_slices(
    (["invoice payment", "reset password"], [0, 1])
).batch(2)
classifier = keras_hub.models.TextClassifier.from_preset("bert_tiny_en_uncased", num_classes=2)
classifier.fit(training, epochs=1)
print(classifier.predict(["invoice"]))

```

From [README.md](https://keras.io/keras_hub/api/base_classes/text_classifier/)

## FAQ

### Which Python text classification library should I use?

[scikit-learn](#scikit-learn) suits pipelines that combine text features with a classifier and structured data. [Transformers](#transformers) suits fine-tuned sequence classifiers and zero-shot labels chosen at prediction time. [fastText](#fasttext) suits compact supervised classifiers trained from labeled examples.

### What is fastText?

[fastText](#fasttext) trains supervised text classifiers that return labels with probabilities. It can compress trained classifier files, and its upstream repository is archived.

### What is zero-shot classification?

A zero-shot pipeline in [Transformers](#transformers) scores candidate labels chosen at runtime. It needs a model fine-tuned for natural language inference rather than an arbitrary language model.

### How does scikit-learn classify text?

[scikit-learn](#scikit-learn) combines a text feature vectorizer with a classifier in one pipeline. Unigram bag-of-words features disregard word order.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best Python text classification libraries custom labels multilabel zero shot scikit-learn Transformers fastText SetFit code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
