Skip to main content

LLM-powered semantic taxonomy generator for raw categorical data

Project description

OpenTaxonomy

LLM-powered semantic taxonomy generator for raw categorical data.

What it does

OpenTaxonomy takes a column of messy raw values (bank transactions, product names, survey responses — anything) and generates a structured semantic taxonomy from it using Claude as the reasoning engine.

Output for each value:

  • {column}_normalized — cleaned entity name (e.g. "REWE SAGT DANKE 46654184/...""REWE")
  • canonical_id — taxonomy path (e.g. ft.expenditure.variable.groceries)

The taxonomy itself is a set of YAML files — a seed.yaml capturing the domain structure, one node.yaml per tree node (each an ontological contract with inclusion/exclusion criteria and a decision record), and a placement_map.yaml that is the source of truth for all mappings.

Architecture

The core is the Prima Seed — a universal questioning protocol that generates domain-specific taxonomic trees from any categorical data:

  • Q0 Identify the Form: what unifies all values?
  • Q0b Establish context: what operational realm governs classification?
  • Q1 Primary differentiation: the most essential splitting criterion
  • Q2 Recursive differentiation: applied per branch at each level
  • Q3 Dialectical check: values that resist placement expose flawed criteria

Installation

pip install opentaxonomy

Requires Python 3.11+ and an Anthropic API key.

Usage

export ANTHROPIC_API_KEY=sk-ant-...

# Generate a new taxonomy from raw data
opentaxonomy create -i transactions.csv -c description -o ./taxonomy

# Place new/unseen values into an existing taxonomy
opentaxonomy run -i new_data.csv -c description -s ./taxonomy

Supported input formats

Format Example
CSV / TSV data.csv, data.tsv
JSON data.json
Excel data.xlsx
Parquet data.parquet
Database postgresql://user:pass@host/db + --db-table

Options

opentaxonomy create
  -i, --input        Input file or database connection string  [required]
  -c, --column       Column containing raw values to classify  [required]
  -o, --output-dir   Where to write taxonomy files  [default: ./taxonomy]
  --domain-hint      Optional hint to guide the LLM (e.g. "German grocery products")
  --model            Claude model  [default: claude-sonnet-4-6]
  --api-key          Anthropic API key (or set ANTHROPIC_API_KEY)

opentaxonomy run
  -i, --input        Input file or database connection string  [required]
  -c, --column       Column containing raw values to classify  [required]
  -s, --seed-dir     Directory with seed.yaml and placement_map.yaml  [default: ./taxonomy]
  --model            Claude model  [default: claude-sonnet-4-6]
  --api-key          Anthropic API key (or set ANTHROPIC_API_KEY)

Output structure

taxonomy/
├── seed.yaml                  # Domain seed: context, levels, edge cases
├── placement_map.yaml         # Raw values → canonical IDs (source of truth)
└── nodes/
    ├── root.yaml              # Root node
    ├── expenditure.yaml       # Internal node with decision record
    ├── groceries.yaml         # Leaf node with inclusion/exclusion criteria
    └── ...

Each node file is an ontological contract:

node: Groceries
canonical_id: ft.expenditure.variable.groceries
question: Is this a purchase of food or household staples from a supermarket or grocery store?
criteria:
  includes:
    - Supermarket purchases (REWE, LIDL, EDEKA, etc.)
    - Organic/bio market purchases
  excludes:
    - Restaurant meals
    - Drugstore purchases unless food items
edge_cases:
  - term: REWE TO GO
    resolution: Included — still a grocery/convenience purchase
    decided: true
parent: Variable Necessities
children: []
version: 1.0.0

License

MIT

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

opentaxonomy-0.1.3.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

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

opentaxonomy-0.1.3-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file opentaxonomy-0.1.3.tar.gz.

File metadata

  • Download URL: opentaxonomy-0.1.3.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for opentaxonomy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a3f57c3a20374956cff1bbb55673ba92f91a5d231a6b9a196c2a3a6d0fede57b
MD5 c9cdaf4423cc3f9c72fd166f0524ddf6
BLAKE2b-256 bf81752acc2726a176e0f1701cc27a9d6d948bf99c3505f86153b6f100254807

See more details on using hashes here.

File details

Details for the file opentaxonomy-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: opentaxonomy-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 27.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for opentaxonomy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4b45fbf46f8f367a81afbb21fe64b100b66043a08150f5c09d5785671a937e62
MD5 ae0e3edfe167f37376d3d97aa06e6fb0
BLAKE2b-256 49565160f6efda5e06349b879959ddc69fa5336dffff482b17427e96f27f5451

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