gsw-eval / README.md
mischeiwiller's picture
Upload folder using huggingface_hub
9561cab verified
|
Raw
History Blame Contribute Delete
5.97 kB
---
license: cc-by-sa-4.0
language:
- gsw
- de
pretty_name: gsw-eval Swiss-German LID benchmark
size_categories:
- n<1K
multilinguality: multilingual
annotations_creators:
- found
source_datasets:
- mischeiwiller/swiss-german-text
task_categories:
- text-classification
tags:
- swiss-german
- alemannic
- gsw
- dialect
- language-identification
- low-resource
- mundart
- benchmark
configs:
- config_name: lid
data_files:
- split: train
path: lid_train.jsonl
- split: test
path: lid_test.jsonl
- config_name: probe
data_files:
- split: train
path: probe_gsw_de.jsonl
---
# gsw-eval — Swiss-German evaluation benchmark
A small, honest benchmark over held-out text from
[`mischeiwiller/swiss-german-text`](https://huggingface.co/datasets/mischeiwiller/swiss-german-text).
Built by `scripts/build_eval_split.py` (task 6.1) via the pure `mundart.eval` layer.
> **Why not regional dialect-ID?** Every row of the source corpus carries
> `region="unknown"` — no greenlit source supplies a defensible dialect-region
> label — so a *regional* classification task would require inventing labels we
> cannot defend. The task the data genuinely supports is **gsw-vs-de language
> identification**, framed below.
## Task 1 — gsw-vs-de language identification (LID)
Given one sentence, predict whether it is **written Swiss-German (`gsw`)** or
**Standard German (`de`)**. This is a real, useful gap: off-the-shelf language
detectors collapse Swiss-German into German, so a gsw-aware LID number is worth
reporting.
| | |
|---|---|
| **Labels** | `de`, `gsw` (binary) |
| **Positives (`gsw`)** | held-out `swiss-german-text` sentences, sampled round-robin across the three slices (Alemannic-Wikipedia, Tatoeba, Leipzig) so encyclopedic, conversational and web registers are all represented |
| **Negatives (`de`)** | the Standard-German side of genuine Tatoeba `gsw→deu` alignment links — real Standard German, never machine-generated |
| **Balance** | 1:1 — the 334 Standard-German negatives are the binding constraint, matched by an equal gsw sample |
| **Split** | per-class stratified, `seed=6`, `test_frac=0.30`**train 468** (234/234), **test 200** (100/100); `train ∩ test = ∅` |
| **Primary metric** | macro-F1 over `{de, gsw}` (reported with accuracy) |
Files: `lid_train.jsonl`, `lid_test.jsonl` — one example per line
(`{id, text, label, source}`).
## Task 2 — gsw→de understanding probe
The **334** Tatoeba `gsw→de` aligned pairs (`probe_gsw_de.jsonl`,
`{id, gsw, de, source}`) ship as a parallel set for a gsw→de understanding probe
(retrieval / translation eval). These pairs are kept **disjoint** from the LID
`gsw` positives — no sentence appears in both — so a model cannot see a probe gsw
sentence during LID evaluation.
## Scoring
`mundart.eval.score(y_true, y_pred)``{n, accuracy, macro_f1, per_class_f1}`.
The macro-F1 is dependency-free and matches scikit-learn's
`f1_score(average="macro")` over the union of gold ∪ predicted labels.
```python
from mundart.eval import score
# y_true / y_pred are lists of "de" / "gsw"
print(score(y_true, y_pred))
```
## Baseline
A light, CPU-only reference baseline ships with the benchmark: a **character
n-gram multinomial Naive Bayes** (`mundart.baseline`, orders 2–4, Laplace
`alpha=1.0`). Naive Bayes is chosen over fastText / logreg because it is
**deterministic by construction** — closed-form counts, no optimizer, no RNG, no
seed — so one command regenerates the exact number with no thread/seed caveats.
| Split | accuracy | macro-F1 | F1 `de` | F1 `gsw` |
|---|---|---|---|---|
| test (n=200) | 0.6700 | **0.6324** | 0.5147 | 0.7500 |
The per-class gap (`de` < `gsw`) is honest: the `de` negatives are short single
Tatoeba sentences while the `gsw` positives include longer Leipzig/Wikipedia
text, so the model over-predicts `gsw` on short inputs. This is a deliberately
beatable floor — the benchmark's value is the held-out split + task definition;
better LID models should clear 0.63 macro-F1 comfortably.
Regenerate the number (byte-identical — `eval/baseline.json` carries the full
scorecard + config):
```bash
# from projects/03-mundart/ (uses only the committed eval/ split)
PYTHONPATH=src .venv/bin/python scripts/run_baseline.py
```
## Reproduce
```bash
# from projects/03-mundart/ (needs the gitignored storage/output/*.jsonl slices)
PYTHONPATH=src .venv/bin/python scripts/build_eval_split.py
```
Regenerating is byte-identical (fixed seed, order-independent stable shuffle).
Counts and provenance are mirrored in `manifest.json`.
## Provenance & license
- Derived from `mischeiwiller/swiss-german-text` (per-slice licenses:
Alemannic-Wikipedia CC-BY-SA-4.0, Tatoeba CC-BY-2.0-FR, Leipzig CC-BY-4.0).
- The benchmark inherits the most restrictive compatible license of its included
text (**CC-BY-SA-4.0**); eval code is Apache-2.0.
- PII was scrubbed at ingest and re-scrubbed (idempotent) when the split is built.
## Companion artifacts
Part of the **Mundart** project (dataset + eval + demo):
- **Dataset:** [`mischeiwiller/swiss-german-text`](https://huggingface.co/datasets/mischeiwiller/swiss-german-text)
— the open written-`gsw` corpus this benchmark is carved from.
- **Space:** [`mischeiwiller/mundart-explorer`](https://huggingface.co/spaces/mischeiwiller/mundart-explorer)
— paste a sentence → gsw-vs-de LID guess (this baseline) + nearest gsw→de
aligned pair from the probe set.
- **Neighbour reference:** [`ZurichNLP/swissbert`](https://huggingface.co/ZurichNLP/swissbert)
— a Swiss-German-aware multilingual encoder; a strong candidate to evaluate on
this LID task.
## Status
Task 6.1 shipped the held-out split + task/metric definitions; task 6.2a adds the
deterministic char n-gram NB baseline (macro-F1 0.6324) + the reproducible
command above. Task 6.2b pushes `mischeiwiller/gsw-eval` (private) with this card,
the split, the probe, and `baseline.json`.