gRPC inference service for multilingual BigARTM topic embeddings.
Project description
redup.python.topicmodel
gRPC inference service for a multilingual BigARTM topic model: document embeddings and topic explanations.
Contract: redup.topicmodel.v1 (GetDocumentsEmbedding, GetTopicExplanation).
PyPI package: redup-topicmodel.
Model
Weights and tokenizers are published on Hugging Face:
redup-ai/topicmodel-multilingual
Expected artifact layout:
<data>/
artm/parameters.bin
artm/p_wt.bin
tokenizers.json.gz
config.json
Download locally:
pip install huggingface_hub
python -c "from huggingface_hub import snapshot_download; print(snapshot_download('redup-ai/topicmodel-multilingual'))"
Configuration
config/config.yaml:
service:
port: "[::]:9878"
TopicModel:
artifact_root: /data # HF artifact root (Docker default mount)
Override without editing the file via servicekit env substitution (section___key):
export TopicModel___artifact_root=/path/to/topicmodel-multilingual
Instead of artifact_root, you can set paths explicitly: model_path (artm/ directory) and bpe_path (tokenizers.json.gz or a tokenizers directory) — also overridable as TopicModel___model_path / TopicModel___bpe_path.
Run with Docker
Pull the published image and mount the downloaded artifacts at /data (as in the config):
docker run --rm -p 9878:9878 \
-v /path/to/topicmodel-multilingual:/data:ro \
redup4ai/redup.python.topicmodel:0.1.0-3.11-slim
The service listens for gRPC on port 9878.
Call it from Python:
import asyncio
from redup_proto_topicmodel.client import Client
from redup_proto_topicmodel.redup.topicmodel.v1.topicmodel_pb2 import (
Document,
DocumentPack,
)
async def main():
client = Client("grpc://localhost:9878")
pack = DocumentPack(documents=[
Document(
document_id="doc-en",
tokens=["hello", "world"],
modalities={"lang": "en"},
),
])
response = await client.get_documents_embedding("example", pack)
print(response["embeddings"])
asyncio.run(main())
Run locally without Docker
python -m venv .venv && source .venv/bin/activate
pip install -r src/requirements.txt
pip install -e src
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
export TopicModel___artifact_root=/path/to/topicmodel-multilingual
PYTHONPATH=src python -m redup_topicmodel.service config/config.yaml
Tests
PYTHONPATH=src python -m pytest tests -q -m "not smoke"
Smoke test with a real model (requires TOPICMODEL_DATA or TopicModel___artifact_root):
export TOPICMODEL_DATA=/path/to/topicmodel-multilingual
PYTHONPATH=src python -m pytest tests -q --smoke
License
MIT — see LICENSE.
Parts of the inference logic are adapted from text_categorization (Copyright (c) 2020, Machine Intelligence Team), BSD 3-Clause. See NOTICE and third_party/text_categorization/.
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
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 redup_topicmodel-0.1.1.tar.gz.
File metadata
- Download URL: redup_topicmodel-0.1.1.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5104b744caaa5aab10fa3174e8b4cc48572e9c6535e62b180c0e54030b1260ba
|
|
| MD5 |
340f918e7e2bdc8484ea62be10cd497a
|
|
| BLAKE2b-256 |
6abdd5153bd704a46fc2d36c124ba055dde3a288e5df4309fc3185d8a9e2aded
|
File details
Details for the file redup_topicmodel-0.1.1-py3-none-any.whl.
File metadata
- Download URL: redup_topicmodel-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ca8d152f73cc3820fedeae9d5bb0fde136f9deb090cb3cba7b33709497baadb
|
|
| MD5 |
4ac58837ffe5bca3c0b5e86d52af398f
|
|
| BLAKE2b-256 |
dc1669fb169a869602927cb10b50aec72e676ffd768c8888b02e3e932916f274
|