Skip to main content
Do you like Artifex? Give it a ⭐ star on GitHub!

topic_classification()

Perform inference with a Topic Classification model, on a single input string or a list of input strings. For each input string, this will return the predicted topic label, which is one of the classes that the model was trained on.

If no model is loaded, the base Topic Classification model tanaos/tanaos-topic-classification-v1 will be used by default. For more information on what topics the base Topic Classification model is trained to recognize, see the model's Hugging Face page.

Arguments


  • text
    str | list[str]

    A string or a list of strings to classify. The model will return a label for each input string.

Response


A list[dict], each dict containing a "label" key with the predicted topic label for the corresponding input string, and a "score" key with a float value representing the model's confidence in its prediction.

from artifex import Artifex

topic_classification = Artifex().topic_classification

topic = topic_classification("What do you think about the latest AI advancements?")
print(topic)
[{'label': 'technology', 'score': 0.9910}]