API reference
Reference for the Python API, the configuration options and the command line, generated from the source. Pages: Model · Embeddings and encoders · Decoders · Data · Candidate features · Pretraining and benchmarking · Configuration · Command line.
Short examples
Candidate sources (see Candidate features):
from papie.lexicon import CandidateFeatures, build_source
src = build_source({"name": "dictionary", "path": "train.tsv"}) # form -> lemma/POS readings
src.candidates("manja") # [Candidate(lemma=..., pos=...)]
feats = CandidateFeatures([src], emb_dim=256, inject=["emb"])
feats.featurize([["lo", "gat", "manja"]]).shape # (3 words, feature_dim)
The tiny T5 encoder as a standalone module:
import torch
from papie.layers.soter import SoterEmbedding
enc = SoterEmbedding(soter_init="scratch", output_dim=256)
emb, outs, src_lengths = enc([["lo", "gat", "manja"]], torch.tensor([3]))
INT8 quantization of a loaded model: PaPie.load_from_checkpoint(...).eval().quantize().