papie lemmatization · tagging · any language

Architecture

Tokens are embedded (word and character), a sentence encoder adds context, and every task has its own decoder [Manjavacas et al. 2019; PyTorch Lightning] .

tokensform per lineEmbeddingword + char BiRNNSentence encoderBiLSTM / GRU (optional)Lemma decoderchar level, one per wordLinear headPOS / morphology
Data flow. Tasks share the embedding and sentence encoder.

Embedding

A character BiRNN encodes each word: its last hidden state is the word vector and its per-character states are what the lemma decoder attends over. A word embedding can be concatenated. Alternatives for the source encoder: byt5 (frozen ByT5 [Xue et al. 2022] ) and soter (the T5 approach).

charactersof one wordchar embeddingchar BiRNN1+ layersper-char statesattended by the lemma decoderlast hidden state= word vector+ word embedding (optional)
Character embedding module (source_encoder: char_rnn).

Sentence encoder

A bidirectional LSTM/GRU over the sentence turns word vectors into contextual vectors. It is optional.

word vectorsw1 … wnBiLSTM / BiGRUover the sentencecontextual vectorsh1 … hn
Bypassed (use_sentence_encoder: false) when the source encoder is already contextual.

Lemma decoders

Select with decoder: in the task.

decoder:Idea
attentionalcharacter seq2seq with attention [Bahdanau et al. 2015]
advanced_attentionaladds a copy / pointer-generator distribution, source-conditioned init and scheduled sampling [See et al. 2017; Bengio et al. 2015]
levenshteinparallel edit-based decoder [Gu et al. 2019]
maskednon-autoregressive mask-and-refine decoder with a length head [Ghazvininejad et al. 2019]
t5small Transformer decoder over per-byte encoder states [Raffel et al. 2020]

Attentional and copy decoder

word's context(sentence vector)per-char statesof the source wordRNN cellstate hattentionover source statessoftmaxover characterscopy distributionoptional (pointer-generator)next charfeed back (greedy / teacher forcing)
Greedy decoding of one lemma. The dashed branch is the optional copy mechanism.

Masked decoder

per-char statesof the source wordlength headpredicts target length[MASK] × lengthtarget skeletonTransformer layercross-attention to sourcecharactersrefine: re-mask low-confidence characters, repeat
Non-autoregressive decoding: predict the length, fill a masked skeleton, refine.

Levenshtein decoder

source worda r m aedit predictorper source chareditsCOPY · DELETE · REPLACE + bounded insertionstarget wordapplied in one passTrained against an edit-distance alignment of source and gold; no autoregression.

T5 decoder

See T5 decoders.

Token-level heads

POS and morphology use a linear softmax on the word vector (or contextual vector).

word vectorafter sentence encoderLineard → #tagssoftmaxtagPOS / morph

Training defaults

bf16 [Micikevicius et al. 2018] , AdamW [Loshchilov & Hutter 2019] or Ranger [Zhang et al. 2019; Liu et al. 2020] , label smoothing 0.1 [Szegedy et al. 2016] , early stopping on dev lemma accuracy.