A multi-agent LLM topic modeling library.
Project description
MALTopic: Multi-Agent LLM Topic Modeling Library
MALTopic is a powerful library designed for topic modeling using a multi-agent approach. It leverages the capabilities of large language models (LLMs) to enhance the analysis of survey responses by integrating structured and unstructured data.
MALTopic as a research paper was published in 2025 World AI IoT Congress. Links here.
Features
- Multi-Agent Framework: Decomposes topic modeling into specialized tasks executed by individual LLM agents.
- Data Enrichment: Enhances textual responses using structured and categorical survey data.
- Latent Theme Extraction: Extracts meaningful topics from enriched responses.
- Topic Deduplication: Refines and consolidates identified topics for better interpretability.
Installation
To install the MALTopic library, you can use pip:
pip install maltopic
Usage
To use the MALTopic library, you need to initialize the main class with your API key and model name. You can choose between different LLMs such as OpenAI, Google Gemini (not supported yet), or Llama (not supported yet).
from maltopic import MALTopic
# Initialize the MALTopic class
mal_topic = client = MALTopic(
api_key="your_api_key",
default_model_name="gpt-4.1-nano",
llm_type="openai",
)
enriched_df = client.enrich_free_text_with_structured_data(
survey_context="context about survey, why, how of it...",
free_text_column="column_1",
structured_data_columns=["columns_2", "column_3"],
df=df,
examples=["free text response, category 1 -> free text response with additional context", "..."], # optional
)
topics = client.generate_topics(
topic_mining_context="context about what kind of topics you want to mine",
df=enriched_df,
enriched_column="column_1" + "_enriched", # MALTopic adds _enriched as the suffix.
)
print(topics)
Agents
- Enrichment Agent: Enhances free-text responses using structured data.
- Topic Modeling Agent: Extracts latent themes from enriched responses.
- Deduplication Agent: Refines and consolidates the extracted topics. (not supported yet)
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Citation
If you use MALTopic in your research, please cite:
@software{Sharma2025maltopic,
author = {Sharma, Yash},
title = {MALTopic: A library for topic modeling},
year = {2025},
url = {https://github.com/yash91sharma/MALTopic-py}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file maltopic-1.0.0.tar.gz.
File metadata
- Download URL: maltopic-1.0.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.10 Linux/6.10.14-linuxkit
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2afcee89a244d65c96ecd621ba119704dbb07a236b3b481637233080316a373
|
|
| MD5 |
f399a4da1feada5b6874497c2bbbb5f5
|
|
| BLAKE2b-256 |
b22bcb2460e6b47855707b83659badf47b7120cfc84703a8f42e5b635b8e80e5
|
File details
Details for the file maltopic-1.0.0-py3-none-any.whl.
File metadata
- Download URL: maltopic-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.10 Linux/6.10.14-linuxkit
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
514e889a40c4c29a991b43d6dd631bbda157852a5b9e7953b572a2d259f4e3c5
|
|
| MD5 |
3ac905b1dba982360c11819f7116b0c0
|
|
| BLAKE2b-256 |
b54bf2ddbbc018823683b2e082ab3bb54971582ff4f4d4769e20338d7e81051c
|