Python toolkit for ML, CV, NLP and multimodal AI development
Project description
maque (麻雀)
Python toolkit for ML, CV, NLP and multimodal AI development
Features
- MLLM Processing - Batch image analysis with OpenAI/Gemini compatible APIs
- LLM Server - Local LLM inference with Transformers backend
- Embedding Service - Text/multimodal embedding API server
- Clustering Pipeline - UMAP + HDBSCAN for vector clustering and visualization
- Async Executor - Priority queue-based concurrent task execution with retry
- Rich CLI - Modular command groups for various tasks
Installation
# Basic installation
pip install maque
# With specific feature sets
pip install maque[torch,nlp,cv] # ML/NLP/CV features
pip install maque[clustering,embedding] # ML pipeline features
pip install maque[dev,test] # Development setup
# From source
pip install -e .
pip install -e .[dev,test]
CLI Usage
Commands are organized into groups: maque <group> <command>. Short alias mq is also available.
Config Management
maque config show # Show current configuration
maque config edit # Open config in editor
maque config init # Initialize config file
MLLM (Multimodal LLM)
# Process images from a table
maque mllm call-table data.xlsx --image_col="image_path" --model="gpt-4o"
# Process images from a folder
maque mllm call-images ./photos --recursive=True --output_file="results.csv"
LLM Server
# Start LLM inference server
maque llm serve Qwen/Qwen2.5-7B-Instruct --port=8000
# Interactive chat
maque llm chat --model="gpt-4o"
Embedding Service
# Start embedding API server
maque embedding serve --model=BAAI/bge-m3 --port=8001
# Test embedding endpoint
maque embedding test --text="Hello world"
Data Processing
# Interactive table viewer (Streamlit)
maque data table-viewer data.csv --port=8501
# Convert between formats
maque data convert input.json output.csv
System Utilities
# Kill processes on ports
maque system kill 8000 8001
# Pack directory
maque system pack ./folder
# Split large file
maque system split large_file.dat --chunk_size=1GB
Git Helpers
# Clone with options
maque git clone https://github.com/user/repo --branch=dev
# Generate SSH key
maque git gen-key project_name --email=your@email.com
Python API
IO Utilities
from maque import yaml_load, yaml_dump, json_load, json_dump, jsonl_load, jsonl_dump
# Load/save YAML
config = yaml_load("config.yaml")
yaml_dump(data, "output.yaml")
# Load/save JSONL
records = jsonl_load("data.jsonl")
jsonl_dump(records, "output.jsonl")
MLLM Client
from maque.mllm import MllmClient
client = MllmClient(
base_url="https://api.openai.com/v1",
api_key="your-api-key",
model="gpt-4o"
)
# Single image
response = client.call("Describe this image", image_path="photo.jpg")
# Batch processing
from maque.mllm import TableProcessor
processor = TableProcessor(client)
results = processor.process("data.xlsx", image_col="image_path", prompt="Describe the image")
Async Executor
from maque.async_api import ConcurrentExecutor
async def process_item(item):
# Your async processing logic
return result
executor = ConcurrentExecutor(
max_concurrent=10,
max_qps=5,
max_retries=3
)
results = await executor.run(
process_item,
items,
progress=True
)
Embedding & Retrieval
from maque.embedding import TextEmbedding
from maque.retriever import ChromaRetriever, Document
# Initialize
embedding = TextEmbedding(base_url="http://localhost:8001/v1", model="bge-m3")
retriever = ChromaRetriever(
embedding,
persist_dir="./chroma_db",
collection_name="my_data"
)
# Insert documents
documents = [Document(id="1", content="text...", metadata={"source": "file1"})]
retriever.upsert_batch(documents, batch_size=32, skip_existing=True)
# Search
results = retriever.search("query text", top_k=10)
Clustering Pipeline
from maque.clustering import ClusterAnalyzer
analyzer = ClusterAnalyzer(algorithm="hdbscan", min_cluster_size=15)
# Analyze from ChromaDB
result = analyzer.analyze_chroma(
persist_dir="./chroma_db",
collection_name="my_data",
output_dir="./results",
sample_size=10000,
visualize=True
)
# Access results
print(f"Found {result.n_clusters} clusters")
print(result.labels)
print(result.cluster_stats)
Performance Measurement
from maque import MeasureTime
with MeasureTime("model inference", gpu=True):
output = model(input)
# Prints: model inference took 0.123s (GPU: 0.089s)
Configuration
maque uses hierarchical configuration (highest priority first):
./maque_config.yaml(current directory)- Project root config
~/.maque/config.yaml(user config)
Example configuration:
mllm:
model: gpt-4o
base_url: https://api.openai.com/v1
api_key: ${OPENAI_API_KEY}
embedding:
model: BAAI/bge-m3
base_url: http://localhost:8001/v1
llm:
default_port: 8000
Initialize config:
maque config init
Development
# Install development dependencies
pip install -e .[dev,test]
# Run tests
pytest
pytest -m "not slow" # Skip slow tests
# Format code
black .
isort .
License
MIT License - see LICENSE for details.
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 maque-0.1.9.tar.gz.
File metadata
- Download URL: maque-0.1.9.tar.gz
- Upload date:
- Size: 1.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ef0987473079bef4a72c164822800b7d296f0b0e9854b95dc36e1ce725692ad
|
|
| MD5 |
94d80473f012c083ae607706d09e0ad8
|
|
| BLAKE2b-256 |
a41130792daeccc2b4316893a4a75381fab6c2cb36dc1be0ba114d1ba4b1bd29
|
Provenance
The following attestation bundles were made for maque-0.1.9.tar.gz:
Publisher:
python-publish.yml on KenyonY/maque
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
maque-0.1.9.tar.gz -
Subject digest:
9ef0987473079bef4a72c164822800b7d296f0b0e9854b95dc36e1ce725692ad - Sigstore transparency entry: 774962174
- Sigstore integration time:
-
Permalink:
KenyonY/maque@26945d392b4ade19687ef4a05abaa649d206e34d -
Branch / Tag:
refs/tags/v0.1.9 - Owner: https://github.com/KenyonY
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@26945d392b4ade19687ef4a05abaa649d206e34d -
Trigger Event:
push
-
Statement type:
File details
Details for the file maque-0.1.9-py3-none-any.whl.
File metadata
- Download URL: maque-0.1.9-py3-none-any.whl
- Upload date:
- Size: 1.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fdb22b573d0a59b19d31c1a44092593ef63e1512efa38404bb5302e763c4790
|
|
| MD5 |
ac8b9012ae347fd7ed3801de669d0e97
|
|
| BLAKE2b-256 |
fbf11259dbc7c960016637943cfca61ddf645dce2c9e98906ec9aae373b7dbde
|
Provenance
The following attestation bundles were made for maque-0.1.9-py3-none-any.whl:
Publisher:
python-publish.yml on KenyonY/maque
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
maque-0.1.9-py3-none-any.whl -
Subject digest:
0fdb22b573d0a59b19d31c1a44092593ef63e1512efa38404bb5302e763c4790 - Sigstore transparency entry: 774962175
- Sigstore integration time:
-
Permalink:
KenyonY/maque@26945d392b4ade19687ef4a05abaa649d206e34d -
Branch / Tag:
refs/tags/v0.1.9 - Owner: https://github.com/KenyonY
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@26945d392b4ade19687ef4a05abaa649d206e34d -
Trigger Event:
push
-
Statement type: