Skip to main content

Domain-agnostic text, image, PDF, and DOCX classification engine powered by LLMs

Project description

cat-stack

Domain-agnostic text, image, and PDF classification engine powered by LLMs.

cat-stack is the shared base package for the CatLLM ecosystem. It provides the core classification, extraction, exploration, and summarization engine that all domain-specific CatLLM packages build on.

Installation

pip install cat-stack

Optional extras:

pip install cat-stack[pdf]         # PDF support (PyMuPDF)
pip install cat-stack[embeddings]  # Embedding similarity scoring
pip install cat-stack[formatter]   # JSON formatter fallback model

Ecosystem

cat-stack is independently useful for classifying any text column. Domain-specific packages extend it with tuned prompts and workflows:

Package Domain
cat-stack General-purpose text, image, PDF classification (this package)
cat-survey Survey response classification
cat-vader Social media text (Reddit, Twitter/X)
cat-ademic Academic papers, PDFs, citations
cat-cog Cognitive assessment & visual scoring (CERAD)
cat-pol Political text (manifestos, speeches, legislation)

Installing cat-llm pulls in all of the above.

Quick Start

import cat_stack as cat

# Classify text into predefined categories
result = cat.classify(
    input_data=df["text_column"],
    categories=["Positive", "Negative", "Neutral"],
    models=[("gpt-4o", "openai", OPENAI_KEY)],
    filename="classified.csv"
)

Core API

classify()

Assign predefined categories to text, images, or PDFs. Supports single-model and multi-model ensemble classification with consensus voting.

cat.classify(
    input_data=df["text"],
    categories=["Cat A", "Cat B", "Cat C"],
    models=[("gpt-4o", "openai", key1), ("claude-sonnet-4-20250514", "anthropic", key2)],
    filename="results.csv"
)

extract()

Discover categories from a corpus using LLM-driven exploration.

cat.extract(
    input_data=df["text"],
    survey_question="What is this text about?",
    models=[("gpt-4o", "openai", key)],
)

explore()

Raw category extraction for saturation analysis.

cat.explore(
    input_data=df["text"],
    description="Describe the main themes",
    models=[("gpt-4o", "openai", key)],
)

summarize()

Summarize text or PDF documents, with optional multi-model ensemble.

cat.summarize(
    input_data=df["text"],
    models=[("gpt-4o", "openai", key)],
    filename="summaries.csv"
)

Supported Providers

OpenAI, Anthropic, Google (Gemini), Mistral, Perplexity, xAI (Grok), HuggingFace, Ollama (local models).

All providers use the same (model_name, provider, api_key) tuple format. Provider is auto-detected from model name if omitted.

Features

  • Multi-model ensemble with consensus voting and agreement scores
  • Batch API support for OpenAI, Anthropic, Google, Mistral, and xAI
  • Prompt strategies: Chain-of-Thought, Chain-of-Verification, step-back prompting, few-shot examples
  • Text, image, and PDF input auto-detection
  • Embedding similarity tiebreaker for ensemble consensus ties

License

GPL-3.0-or-later

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cat_stack-0.2.0.tar.gz (450.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cat_stack-0.2.0-py3-none-any.whl (470.8 kB view details)

Uploaded Python 3

File details

Details for the file cat_stack-0.2.0.tar.gz.

File metadata

  • Download URL: cat_stack-0.2.0.tar.gz
  • Upload date:
  • Size: 450.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.14

File hashes

Hashes for cat_stack-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4536326dc6370c2f0ad3b5ddae00bc78ab7cf22e3ef56cfd04b49bdfdf7fda17
MD5 9861982d4bbd4f53191c655cab5e62b5
BLAKE2b-256 d6502ad1217677c3eab4125952a67da405c13e2da3d02b38d9dbb6e615b32fa5

See more details on using hashes here.

File details

Details for the file cat_stack-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cat_stack-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 470.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.14

File hashes

Hashes for cat_stack-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f4d25bf22e3077fa02fdf50a78aaefaadcf24a55bd3c0cd2eccd091e2b8d4c6
MD5 fac61b6c201a8b017d4b5b04eb76d578
BLAKE2b-256 dc326d91ba3f0f2c8289fe11888f09c59679ab4413d7a0fdc5eb3a4c8a25d357

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page