File size: 2,295 Bytes
cd8ae16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
license: apache-2.0
language:
- grc
library_name: transformers
tags:
- ancient-greek
- classical-philology
- character-level
- masked-diffusion
- dependency-parsing
- pos-tagging
- lemmatization
pipeline_tag: token-classification
---

# Stoicheia -- joint tagger and dependency parser

**Stoicheia** is a 405M-parameter character-level masked-diffusion encoder for Ancient Greek
(`d_model` 1024, depth 32, banded attention: three of every four blocks attend within a
256-character window, the fourth globally). Its input is factored into five aligned planes --
letters, word/sentence boundaries, diacritics, capitalization, punctuation -- each of which can
be masked independently to an explicit *unknown* state at inference. That is what lets one model
read an edited text, *scriptio continua*, and a lacuna of unknown length without changing
anything but its input.

Anonymous release accompanying a paper under review.

`Stoicheia-doc_clean` with four heads on one shared backbone through an ELMo-style scalar mix:
factored XPOS, an edit-script lemmatizer, a UPOS auxiliary, and a biaffine dependency parser.
Everything below comes from a single forward pass -- there is no pipeline of separate models.

## Usage

```python
import sys, torch
from transformers import AutoModel
from huggingface_hub import snapshot_download

REPO = "Ericu950/Stoicheia-tagger-parser"
# this model's processor needs the label vocabularies beside it, so take the whole snapshot
local = snapshot_download(REPO, allow_patterns=["*.json", "*.txt", "*.py", "*.model"])
sys.path.insert(0, local)
from processing_char_bert_joint import CharBertJointProcessor

model = AutoModel.from_pretrained(REPO, trust_remote_code=True).eval()
proc = CharBertJointProcessor.from_pretrained(local)

batch = proc(["μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος".split()])
with torch.no_grad():
    out = model(**batch)

for i, w in enumerate(proc.decode(out, batch, ud=True)[0], 1):
    print(i, w["form"], w["lemma"], w["upos"], w["xpos"], w["head"], w["deprel"])
# 1 μῆνιν μῆνις NOUN ... 2 obj
# 2 ἄειδε ἀείδω VERB ... 0 root
# 3 θεὰ θεά NOUN ... 2 orphan
# 4 Πηληϊάδεω Πηληιάδης NOUN ... 5 appos
# 5 Ἀχιλῆος Ἀχιλλεύς NOUN ... 1 nmod
```