Installation

Requirements

  • Python 3.12 or later (tested on 3.12, 3.13 and 3.14);

  • PaPie 1.0 or later (imported as papie), installed with Pie Extended: it runs the models, and brings PyTorch, which decides which Python versions can be used. (The releases 1.0.x of Pie Extended run PaPie 0.x and the former .tar models.)

Install the package

pip install pie-extended

Without a backend, the package installs, and a model that needs a missing one says which extra to install.

No GPU, no CUDA?

By default, pip downloads a PyTorch built for CUDA, which is large. If you only have a CPU (or if you are in doubt), ask for the CPU build:

pip install pie-extended --extra-index-url https://download.pytorch.org/whl/cpu

This gives you the pie-extended command and the pie_extended Python package. Check it with:

pie-extended list

Optional dependencies

Extra

Command

What for

grecy

pip install "pie-extended[grecy]"

Models run through spaCy (grc_grecy, see Tagger usage)

soter

pip install "pie-extended[soter]"

The lemmatizer Sôtêr with a light spaCy pipeline (grc_soter, see Backends)

docs

pip install "pie-extended[docs]"

Build this documentation

Install the models

The models are not part of the package: they are downloaded for each model you need from Hugging Face, when it is first used, and kept in the cache of Hugging Face (~/.cache/huggingface, or HF_HOME). pie-extended download does it in advance, which you need to run offline (HF_HUB_OFFLINE=1). The few files that a model needs besides (the lexicons of lasla) go in the folder downloads of the package, or in PIE_EXTENDED_DOWNLOADS if you set it; pie-extended tag fetches them when they are missing, and get_tagger from Python raises FilesNotDownloaded (a FileNotFoundError) that says to run pie-extended download MODEL (or pie_extended.cli.utils.ensure_files("lasla")).

pie-extended download lasla        # the files of the model
pie-extended install-addons hy_xcl # what a model needs besides its files, for the few that need something

Which command does what depends on the model:

  • download fetches the model from Hugging Face, and the files that it needs besides; a model that runs a spaCy pipeline has none;

  • install-addons runs the extra installation of the model, for the two models that have one: hy_xcl learns from a treebank how to split the clitics of Classical Armenian, and grc_grecy installs its spaCy pipeline. For the others it does nothing.

Models tells what each model needs.

A note on safety

A Pie model is a file produced by PyTorch, and PyTorch files can contain code. With torch 2.6 or later (the default with a recent PaPie), loading refuses to run any code it finds. With torch 2.4 and 2.5, which PaPie still allows, it does not: only download the models of authors you trust.

Install the development version

Clone the repository, create an environment, and then:

pip install -e ".[docs]" --extra-index-url https://download.pytorch.org/whl/cpu
pip install pytest pytest-cov
pie-extended download lasla     # needed by some of the tests
pytest --doctest-modules tests pie_extended

Build this documentation with make docs: the result is in docs/_build/html (make docs-serve serves it on http://localhost:8000).

Release a new version

Releases are published on PyPI by a workflow, when a tag is pushed:

  1. change version in pyproject.toml and commit it;

  2. git tag vX.Y.Z (the tag must be v followed by that version) and git push origin vX.Y.Z.

The workflow runs the tests on every supported Python, builds the package, checks that the tag is the version, and publishes it. Nothing is published if one of these fails. No password is stored: PyPI trusts the workflow (trusted publishing, set up once in the settings of the project on PyPI).