Skip to main content

redup.python.topicmodel

Docker test Python test

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)
  num_processors: 1

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/.

Metadata

Release files for redup-topicmodel 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redup-topicmodel 0.1.3
File Size Uploaded Provenance Actions
redup_topicmodel-0.1.3.tar.gz 12.9 kB Without provenance Details for redup_topicmodel-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for redup-topicmodel 0.1.3
File Interpreter ABI Platform Actions
redup_topicmodel-0.1.3-py3-none-any.whl Python 3 none any Details for redup_topicmodel-0.1.3-py3-none-any.whl

Total release size: 26.6 kB

Release files / redup_topicmodel-0.1.3.tar.gz

Download URL redup_topicmodel-0.1.3.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e4913cb4a675413948dfde9359013f43c60c9c9ce48cad828fe0f1e6cdbf7458
BLAKE2b-256 checksum
How to use checksums
e4d9cabede482d7a95419ff32c3df86941359e066f4b193137be1940dafd55eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / redup_topicmodel-0.1.3-py3-none-any.whl

Download URL redup_topicmodel-0.1.3-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8526c5ca8864462d2ef9a3cbf06e85192b55a7f8b4ade9106424d9cc00d00202
BLAKE2b-256 checksum
How to use checksums
3ffa02f7f34f38aa610273120772d43d6d3f43677921386ddff4d69676de050b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Security for redup-topicmodel 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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