Getting started
Install
pip install -e . # from a checkout; provides the `papie` CLI and `python -m papie.cli`
Data
One token per line, a blank line between sentences, tab-separated, optional header. Column 0 is the form; the config maps each task to a column. Any language and any tagset work — labels are read from the data (example: Occitan):
token lemma pos
lo lo DET
gat gat NOUN
manja manjar VERB
CoNLL-U files convert with python -m papie.scripts.conllu_to_tsv in.conllu out.tsv.
Train, test, predict
Everything is configured by one YAML (tasks:, data:, model:, trainer:); several -c files merge, later ones winning.
python -m papie.cli fit -c configs/oc_lemma_pos.yaml
python -m papie.cli test -c configs/oc_lemma_pos.yaml --ckpt_path models/…/best.ckpt
A minimal task list:
tasks:
- {name: lemma, level: char, decoder: attentional, context: sentence, eos: true, bos: true}
- {name: pos, level: token, decoder: linear, context: sentence}
data:
path_train: train.tsv
path_val: dev.tsv
path_test: test.tsv
reader_params: {all: {header: true, tasks_columns: {lemma: 1, pos: 2}}}
Very long sentences are cut into chunks of data.dataset_params.all.max_sent_len tokens (each chunk is an independent sample; unset = no cutting). Set split_chars (for example .;!?·:) to prefer cutting right after a token ending in one of those characters, even when the mark is glued to the word.
Useful options: trainer.precision: bf16-mixed, trainer.accelerator: gpu, early stopping and checkpointing as ordinary Lightning callbacks, and fit --ckpt_path last.ckpt to resume.
Convert a PaPie model
python -m papie.scripts.convert_papie model.tar --out converted/ produces the label-encoder JSON and a Lightning checkpoint.
Commands
| Command | Purpose |
|---|---|
fit, validate, test, predict | the Lightning CLI |
distill-embeddings | distil the small T5 encoder (T5 approach) |
cpu-benchmark | speed and accuracy of a checkpoint on CPU, fp32 vs INT8 (CPU inference) |
python -m papie.lexicon.precompute | caches and oracle report for candidate features |