papie lemmatization · tagging · any language

Command line

All commands run as python -m papie.cli <command> (or papie <command> once installed).

Generated from the source by tools/make_api.py; do not edit by hand.

CommandWhat it does
fit, validate, test, predictthe Lightning CLI; configured by YAML, several -c files merge
distill-embeddingsdistil the small T5 encoder (-c config --set key=value …)
export-modelexport a checkpoint as a publishable folder (safetensors, no pickles)
push-modelupload an exported folder to the Hugging Face Hub (private by default)
fit-silverpretrain on silver data for a set number of epochs, then fine-tune on gold
annotatelabel raw text with a trained model to create silver data
cpu-benchmarkCPU speed and accuracy, fp32 vs INT8

python -m papie.lexicon.precompute is a separate module.

papie.cli export-model

usage: papie export-model [-h] --ckpt CKPT --out OUT [--license LICENSE]
                          [--language LANGUAGE] [--description DESCRIPTION]
                          [--dataset-note DATASET_NOTE] [--metrics METRICS]
                          [--max-sent-len MAX_SENT_LEN] [--keep-stats]
                          [--base-model BASE_MODEL] [--variant VARIANT]
                          [--default]

Export a checkpoint as a publishable folder.

options:
  -h, --help            show this help message and exit
  --ckpt CKPT
  --out OUT
  --license LICENSE     license id for the card (e.g. cc-by-4.0); none is
                        assumed
  --language LANGUAGE   ISO 639 code; repeatable
  --description DESCRIPTION
  --dataset-note DATASET_NOTE
                        free text on the training data for the card
  --metrics METRICS     JSON file {name: value} to list in the card
  --max-sent-len MAX_SENT_LEN
                        cut longer sentences when annotating
  --keep-stats          keep known/ambiguous-token statistics (large)
  --base-model BASE_MODEL
                        repo id of the model this one was fine-tuned from
  --variant VARIANT     write into <out>/<variant> and register it in
                        <out>/papie.json (several variants in one repository;
                        pick one with from_pretrained(variant=...))
  --default             make this variant the default one

papie.cli push-model

usage: papie push-model [-h] [--public | --private] [--message MESSAGE]
                        [--create-pr]
                        folder repo_id

Upload an exported folder to the Hugging Face Hub.

positional arguments:
  folder
  repo_id            e.g. my-org/pie-thunder-grc-lemma-pos

options:
  -h, --help         show this help message and exit
  --public           make the repository public
  --private          make the repository private
  --message MESSAGE
  --create-pr        open a pull request instead of pushing to main

papie.cli fit-silver

usage: papie fit-silver [-h] -c CONFIG --silver SILVER --silver-epochs
                        SILVER_EPOCHS [--workdir WORKDIR] [--force]
                        [--dry-run]

``fit-silver`` — train for a *manual number of epochs on silver data*
(automatically annotated, noisier, usually much larger), then fine-tune on the
gold data with the usual early stopping::

options:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        config(s) for `fit` on the GOLD data
  --silver SILVER       silver TSV (same columns/format as the gold);
                        repeatable
  --silver-epochs SILVER_EPOCHS
                        epochs to train on silver before gold
  --workdir WORKDIR     stage configs, label encoder and the silver checkpoint
                        (default: runs/silver/<config name>)
  --force               redo the silver stage even if its checkpoint exists
  --dry-run             write the stage configs and print the plan only

papie.cli annotate

usage: papie annotate [-h] [-c CONFIG] [--ckpt CKPT] [--model MODEL]
                      [--revision REVISION] [--variant VARIANT]
                      [--tasks TASKS [TASKS ...]]
                      [--disable DISABLE [DISABLE ...]] --input INPUT --output
                      OUTPUT [--max-sent-len MAX_SENT_LEN]
                      [--batch-size BATCH_SIZE] [--device DEVICE]
                      [--workers WORKERS] [--quantize]

python -m papie.cli fit-silver -c config.yaml --silver silver.tsv --silver-
epochs 5

options:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        config of the annotator (with --ckpt)
  --ckpt CKPT           trained Lightning checkpoint (the annotator / teacher)
  --model MODEL         alternative to -c/--ckpt: an exported model folder or
                        a Hub repo id
  --revision REVISION   Hub revision (commit sha) for --model
  --variant VARIANT     variant of a multi-variant repository (default: its
                        default)
  --tasks TASKS [TASKS ...]
                        --model only: keep only these heads
  --disable DISABLE [DISABLE ...]
                        --model only: switch these heads off
  --input INPUT         raw text or a TSV with tokens in column 0
  --output OUTPUT
  --max-sent-len MAX_SENT_LEN
                        longer sentences are split
  --batch-size BATCH_SIZE
  --device DEVICE       cpu | cuda
  --workers WORKERS     --model only, CPU: that many single-thread processes
                        (much faster than many threads in one)
  --quantize            --model only, CPU: INT8 dynamic quantization (about
                        1.5x faster)

papie.cli cpu-benchmark

usage: papie cpu-benchmark [-h] -c CONFIG --ckpt CKPT [--test TEST]
                           [--tokens TOKENS] [--max-sent-len MAX_SENT_LEN]
                           [--threads THREADS] [--variants VARIANTS]
                           [--batch-size BATCH_SIZE] [--seed SEED]
                           [--json JSON]

``papie cpu-benchmark``: CPU inference speed and accuracy of a trained
checkpoint, with and without dynamic INT8 quantization, at one or several
thread counts.

options:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        training config(s), as for `fit`
  --ckpt CKPT
  --test TEST           TSV to sample from (default: data.path_test of the
                        config)
  --tokens TOKENS
  --max-sent-len MAX_SENT_LEN
  --threads THREADS     comma-separated, e.g. 1,8
  --variants VARIANTS   comma-separated: fp32,int8
  --batch-size BATCH_SIZE
  --seed SEED
  --json JSON           also write the results to this file

papie.lexicon.precompute

usage: precompute.py [-h] -c CONFIG [--split {train,dev,test}] [--no-save]

options:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        repeatable; later files override earlier ones (as the
                        Lightning CLI does)
  --split {train,dev,test}
  --no-save