Metadata-Version: 2.4
Name: paperus-ml
Version: 0.0.13
Summary: Machine learning service of paperus: text embeddings, reranking and OCR
Keywords: embeddings,onnx,ocr,semantic search,self-hosted
Author: paperus contributors
License-Expression: Apache-2.0
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering
Requires-Dist: fastapi>=0.162.0
Requires-Dist: huggingface-hub>=2.4.0
Requires-Dist: numpy>=2.5.4
Requires-Dist: onnxruntime>=1.31.1
Requires-Dist: opencv-python-headless>=5.0.0.93
Requires-Dist: prometheus-client>=0.26.0
Requires-Dist: pydantic-settings>=2.16.2
Requires-Dist: pyyaml>=6.0.3
Requires-Dist: tokenizers>=0.23.3
Requires-Dist: uvicorn[standard]>=0.54.0
Requires-Python: >=3.13
Project-URL: Homepage, https://github.com/qcode-uni-a/paperus
Project-URL: Source, https://github.com/qcode-uni-a/paperus
Project-URL: Issues, https://github.com/qcode-uni-a/paperus/issues
Description-Content-Type: text/markdown

# paperus-ml

Machine learning service of [paperus](https://github.com/qcode-uni-a/paperus):
text embeddings for search by meaning, reranking of search hits, and OCR of
scanned pages, with ONNX Runtime on the CPU or an NVIDIA GPU. Models are
downloaded from Hugging Face on first use and unloaded when idle.

```sh
pip install paperus-ml
PAPERUS_ML_TOKEN=… paperus-ml --host 0.0.0.0   # port 3003
```

Settings are environment variables:

| Variable | Default | Meaning |
| --- | --- | --- |
| `PAPERUS_ML_TOKEN` | none | Shared secret; requests need `Authorization: Bearer <token>` |
| `PAPERUS_ML_CACHE_PATH` | `~/.cache/paperus-ml` | Downloaded models |
| `PAPERUS_ML_PRELOAD` | `[]` | Models to load at start and keep, e.g. `["arctic-embed-m-v2"]` (paperus then sends the one in use) |
| `PAPERUS_ML_MODEL_TTL` | `300` | Unload other models after this many idle seconds (0: never) |
| `PAPERUS_ML_INTRA_OP_THREADS` | `0` | CPU cores per model at start (0: all it sees); paperus' administration sets it afterwards |
| `PAPERUS_ML_MAX_BATCH_TEXTS` / `_TOKENS` | `32` / `16384` | Batch size (memory grows with both) |

paperus sends its settings with `PUT /config` (cores, models to keep
loaded). One batch runs at a time per model, using all its cores; simultaneous
requests take turns batch by batch.

Most installations use the `paperus-ml` container image instead. Status:
early version (0.0.x); expect breaking changes.
