Skip to main content

topic-autolabel

Documentation Status License Python Version Code style: black Ruff

Given text data, generates labels to classify the data into a set number of topics completely unsupervised.

Example usage:

First, install the package with pip: pip install topic_autolabel

# Labelling with supplied labels
from topic_autolabel import process_file
import pandas as pd

df = pd.read_csv('path/to/file')
candidate_labels = ["positive", "negative"]

# labelling column "review" with "positive" or "negative"
new_df = process_file(
    df=df,
    text_column="review",
    candidate_labels=candidate_labels,
    model_name="meta-llama/Llama-3.1-8B-Instruct" # default model to pull from huggingface hub
)

Alternatively, one can label text completely unsupervised by not providing the candidate_labels argument

from topic_autolabel import process_file
import pandas as pd

df = pd.read_csv('path/to/file')

# labelling column "review" with open-ended labels (best results when dataset talks about many topics)
new_df = process_file(
    df=df,
    text_column="review",
    model_name="meta-llama/Llama-3.1-8B-Instruct",
    num_labels=5 # generate up to 5 labels for each of the rows
)

Ollama integration:

Provided you have an ollama server running, you can pass in the tag of the model you want to use to generate labels.

from topic_autolabel import process_file
import pandas as pd

df = pd.read_csv('path/to/file')

# labelling column "review" with open-ended labels, using llama3.1 hosted with ollama (llama 3.1 must be running, run ollama ps to verify)
new_df = process_file(
    df=df,
    text_column="review",
    model_name="llama3.1",
    num_labels=5 # generate up to 5 labels for each of the rows
)

Release files for topic-autolabel 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for topic-autolabel 0.1.6
File Size Uploaded
topic_autolabel-0.1.6.tar.gz 13.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for topic-autolabel 0.1.6
File Interpreter ABI Platform
topic_autolabel-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 24.8 kB

Release files / topic_autolabel-0.1.6.tar.gz

Download URL topic_autolabel-0.1.6.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6136974635226ebe0fc4e91d5f8e19877f5fddd023d02418242b0c42226f506c
BLAKE2b-256 checksum
How to use checksums
128b02c2d6e4535faf486207d311b369b7adec551288616eaf26de364632d68e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / topic_autolabel-0.1.6-py3-none-any.whl

Download URL topic_autolabel-0.1.6-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5dfab0bff9d83e7da51c401109a7d5cf2c6f1da64e960c015ce09b42b8b633af
BLAKE2b-256 checksum
How to use checksums
11438b5e3fc28db95dfcbb96cf448f51a6da5dca1a374064e3c5e4b0e7ceb9b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page