|
Download README.md from Urdatorn/Makron-code: direct link, hf CLI and curl.
- Browser
- Download file 3.87 kB
-
https://huggingface.co/Urdatorn/Makron-code/resolve/main/README.md
- Command line
-
hf download hf://Urdatorn/Makron-code/README.md
-
curl -L -o README.md https://huggingface.co/Urdatorn/Makron-code/resolve/main/README.md
3.87 kB
| license: gpl-3.0 | |
| language: | |
| - grc | |
| tags: | |
| - ancient-greek | |
| - vowel-length | |
| - macronization | |
| - code | |
| # Makron-code | |
| Training, hyperparameter search and evaluation code for | |
| [Urdatorn/Makron-seed1](https://huggingface.co/Urdatorn/Makron-seed1), [-seed2](https://huggingface.co/Urdatorn/Makron-seed2) and [-seed3](https://huggingface.co/Urdatorn/Makron-seed3), the revised versions of the char-level | |
| Ancient Greek macronizer | |
| ([Ericu950/oga-macronizer-char](https://huggingface.co/Ericu950/oga-macronizer-char)), | |
| as revised for the reviewed version of *Automatic Annotation of Ancient Greek | |
| Vowel Length* (Thörn Cleland & Cullhed). | |
| Compared to the original code in | |
| [grc-macronizer/macron_model](https://github.com/Urdatorn/grc-macronizer/tree/oga-macronization-improvements/macron_model) | |
| (commit `456c970`): | |
| - **Decontaminated training data:** training uses | |
| [Urdatorn/oga-macronized-no-norma](https://huggingface.co/datasets/Urdatorn/oga-macronized-no-norma), | |
| from which every sentence overlapping the benchmark has been removed. | |
| - **Current Norma layout:** evaluation reads the jsonl version of | |
| [Urdatorn/norma](https://huggingface.co/datasets/Urdatorn/norma) | |
| (`data/test.jsonl`, `data/validation.jsonl`) and reports the metrics of the | |
| paper's Table 1 (per-label accuracy, P, R, F1 and coverage) and per-position | |
| predictions for error analysis. | |
| - **Model selection on gold data:** Norma validation, which is gold-annotated, | |
| is scored at every evaluation and can drive checkpoint selection, early | |
| stopping and hyperparameter search. The test split is used only in the final | |
| evaluation. | |
| - **Hyperparameter search:** an Optuna search over learning rate and weight | |
| decay, with dropout optional. | |
| - **Faster training input:** the corpus is encoded once into flat arrays, and | |
| padding and diacritic masking are vectorized. | |
| `model.py` and `tokenizer.py` are unchanged from the original, so checkpoints | |
| are compatible both ways. | |
| ## Files | |
| | file | purpose | | |
| |---|---| | |
| | `model.py`, `tokenizer.py` | model and char-plane tokenizer (unchanged) | | |
| | `prepare_data.py` | encode the silver corpus into `cache/` (fixed 90/10 split, `--data_seed 0`) | | |
| | `train.py` | train one model, logging silver-val and Norma-val metrics at every evaluation | | |
| | `hpo.py` | Optuna study shared by several slurm workers through a journal file | | |
| | `evaluate.py` | score checkpoints (local or Hub) on Norma, writing metrics and per-position jsonl | | |
| | `norma.py` | Norma loading and scoring | | |
| | `rule_based.py` | score the rule-based grc-macronizer on Norma with the same scorer | | |
| | `analysis/` | error analysis (`error_analysis.py`, results in `error_analysis.{test,validation}.md`) | | |
| | `predict.py` | batched inference (`MacronPredictor`) | | |
| | `slurm/` | jobs for the Arrhenius GH200 nodes: `prepare.slurm` (venv + data cache), then `hpo.slurm` (search), `epochs.slurm`, `final.slurm`, `rule_based.slurm` | | |
| ## Usage | |
| ```sh | |
| pip install -r requirements.txt | |
| python prepare_data.py --out cache/oga-no-norma | |
| python train.py --cache cache/oga-no-norma --output_dir runs/seed1 --seed 1 | |
| python evaluate.py --models runs/seed1/best --splits test validation --out results/seed1 | |
| ``` | |
| ## Scoring | |
| The scored positions are the gold-marked dichrona in open syllables. In test, | |
| openness comes from the parallel syllabify lines, giving 1,916 positions. In | |
| validation, which has no syllabify lines, every gold mark is scored, giving | |
| 2,498 positions. | |
| - **Accuracy:** an unmarked position counts as wrong. | |
| - **Per label:** accuracy equals recall; precision is computed over that | |
| label's predictions. | |
| - **Mixed (micro-averaged):** recall = accuracy; precision = correct / marked | |
| positions; F1 is their harmonic mean. This reproduces Table 1. | |
| - **Defaults-to-short accuracy:** an unmarked position counts as "short". | |
| This is the metric reported on the model cards. | |
| ## License | |
| GNU GPL v3. | |