Skip to main content

GraphTopic

Graph-based topic modeling built on semantic graphs.

GraphTopic is a Python library for discovering document topics using graph-based community detection instead of traditional clustering algorithms.

It is built on top of Graphion, a modular graph processing framework, allowing every stage of the topic modeling pipeline to be customized.


Features

  • Graph-based topic discovery
  • Pluggable embedding models
  • Pluggable graph construction
  • Pluggable community detection
  • Pluggable topic representation
  • Simple sklearn-like API
  • Built on Graphion

Installation

Install the core library:

pip install graphtopic

To use the built-in SentenceTransformer embedding model:

pip install "graphtopic[embedding]"

Quick Start

from graphtopic import GraphTopic
from graphtopic.embedding_models import (
    SentenceTransformerEmbedding,
)

documents = [
    "Apple released a new iPhone.",
    "Samsung announced a new Galaxy phone.",
    "Barcelona won the football match.",
    "Real Madrid signed a new player.",
]

model = GraphTopic(
    embedding_model=SentenceTransformerEmbedding(
        "sentence-transformers/all-MiniLM-L6-v2"
    )
)

topics = model.fit_transform(documents)

for topic in model.get_topic_info():
    print(topic)

Pipeline

GraphTopic follows a modular processing pipeline:


Documents
↓
Embeddings
↓
FeatureSet
↓
Relation Graph
↓
Community Detection
↓
Topic Representation
↓
Topic Information

Each stage can be replaced with custom implementations.


Custom Components

GraphTopic is designed around interchangeable components.

You can replace:

  • Embedding Model
  • Reducer
  • Relation Builder
  • Graph Builder
  • Graph Refiner
  • Community Detector
  • Partition Refiner
  • Representation Model

This makes it easy to experiment with different graph construction and topic discovery strategies.


Built on Graphion

GraphTopic uses Graphion as its graph processing backend.

Graphion provides reusable components for:

  • similarity computation
  • graph construction
  • graph refinement
  • community detection
  • graph processing pipelines

GraphTopic focuses only on topic modeling while delegating graph operations to Graphion.


Requirements

  • Python 3.11+
  • NumPy
  • scikit-learn
  • Graphion

Project Status

GraphTopic is currently in Pre-Alpha (0.0.x).

The public API is expected to evolve as new functionality is added.


License

MIT License

Download files

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

Source Distribution

graphtopic-0.0.2.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

graphtopic-0.0.2-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file graphtopic-0.0.2.tar.gz.

File metadata

  • Download URL: graphtopic-0.0.2.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for graphtopic-0.0.2.tar.gz
Algorithm Hash digest
SHA256 f80a07e1a11cf8bbddd37394385b705db4c27ebeace99187b5af16eac7642c99
MD5 c69d8af985800f745a56a1aaf34701d3
BLAKE2b-256 f4807f5a9ddb4523151ede3c4e0e9f3a823e2f9e83170dbdd8729734e97d5826

See more details on using hashes here.

File details

Details for the file graphtopic-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: graphtopic-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for graphtopic-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 58c6c80e242f0a673dc6bae4824d3fab4409a6c0695aaeac30317608e94e2cf4
MD5 f3d113701ab6fd552473514ea612b20b
BLAKE2b-256 957155983e714173c2ef1a4ef6d9b88d4ecefc3165b4ee55016871c9e2e454d4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 files

0.0.1

2 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