katrohrb commited on
Commit
ab02861
·
verified ·
1 Parent(s): ded9e95

Model card in English; add widget examples, link to EN counterpart

Browse files
Files changed (1) hide show
  1. README.md +51 -27
README.md CHANGED
@@ -8,54 +8,78 @@ tags:
8
  - literature
9
  - digital-humanities
10
  - narratology
 
 
 
 
 
 
 
 
 
 
 
11
  ---
12
 
13
  # de-setting-classifier
14
 
15
- Satzweiser Klassifikator für die räumliche Darstellung in deutschsprachiger Prosa.
16
- Feinabgestimmt auf [`lkonle/fiction-gbert-large`](https://huggingface.co/lkonle/fiction-gbert-large)
17
- (BERT-large, für deutschsprachige erzählende Prosa vortrainiert).
18
 
19
- ## Kategorien
 
 
20
 
21
- | Label | Deutsche Bezeichnung | Beschreibung |
22
- |---------------------|-----------------------|------------------------------------------------------------------------|
23
- | `action_space` | Aktionsraum | Raum, der durch Bewegung und direkten Kontakt einer Figur erfasst wird |
24
- | `visual_space` | Anschauungsraum | Raum, wie er von einer Figur aus der Distanz wahrgenommen wird |
25
- | `perceived_space` | gestimmter Raum | Raum, wie er Stimmung und Atmosphäre widerspiegelt |
26
- | `descriptive_space` | Raumbeschreibung | Dinge/Objekte im Raum, ohne Bezug zu einer Figur |
27
- | `no_space` | kein Raum | kein Raumbezug |
 
 
 
 
 
28
 
29
  ## Training
30
 
31
- ⟨Trainingskorpus (Umfang, Herkunft, Zeitraum), Annotationsverfahren, Anzahl Annotator:innen
32
- und Inter-Annotator-Übereinstimmung ergänzen.⟩
33
 
34
  ## Evaluation
35
 
36
- ⟨Gütemaß (z. B. F1 pro Klasse und makro-gemittelt) auf zurückgehaltenem Testset ergänzen.⟩
37
-
38
- ## Verwendung
39
 
40
- Über das begleitende Python-Paket [`de-setting-classifier`](⟨GitHub-URL ergänzen⟩):
41
 
42
  ```python
43
- from de_setting_classifier import SpaceClassifier
 
 
 
 
 
44
 
45
- clf = SpaceClassifier.from_pretrained("katrohrb/de-setting-classifier")
46
- clf.predict("Er trat durch die Tür und schloss sie hinter sich.")
47
- # → "action_space"
 
 
48
  ```
49
 
50
- Oder direkt über `transformers`:
51
 
52
  ```python
53
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
54
 
55
- tok = AutoTokenizer.from_pretrained("katrohrb/de-setting-classifier")
56
- model = AutoModelForSequenceClassification.from_pretrained("katrohrb/de-setting-classifier")
 
57
  ```
58
 
59
- ## Zitation
60
 
61
- ⟨Bibliographische Angabe der zugrundeliegenden Studie ergänzen.⟩
 
8
  - literature
9
  - digital-humanities
10
  - narratology
11
+ widget:
12
+ - text: "Er trat durch die Tür und schloss sie hinter sich."
13
+ example_title: action_space
14
+ - text: "Vom Hügel aus konnte sie das ganze Tal unter sich liegen sehen."
15
+ example_title: visual_space
16
+ - text: "Das Zimmer wirkte schwer und bedrückend, als rückten die Wände näher."
17
+ example_title: perceived_space
18
+ - text: "In der Ecke stand ein Tisch, bedeckt mit staubigen Büchern."
19
+ example_title: descriptive_space
20
+ - text: "Sie fragte sich, ob er ihr jemals zurückschreiben würde."
21
+ example_title: no_space
22
  ---
23
 
24
  # de-setting-classifier
25
 
26
+ Sentence-level classifier for the representation of space in German narrative prose.
27
+ Fine-tuned from [`lkonle/fiction-gbert-large`](https://huggingface.co/lkonle/fiction-gbert-large)
28
+ (BERT-large, pre-trained on German fiction).
29
 
30
+ German counterpart to
31
+ [`katrohrb/narrative-space-classifier`](https://huggingface.co/katrohrb/narrative-space-classifier);
32
+ both models use the same five categories and the same label encoding.
33
 
34
+ ## Categories
35
+
36
+ | Label | German term | Description |
37
+ |---------------------|--------------------|-----------------------------------------------------------------------------|
38
+ | `action_space` | Aktionsraum | Space registered through a character's movement and direct physical contact |
39
+ | `visual_space` | Anschauungsraum | Space as perceived by a character from a distance |
40
+ | `perceived_space` | gestimmter Raum | Space as it carries mood and atmosphere |
41
+ | `descriptive_space` | Raumbeschreibung | Things and objects in space, without reference to a character |
42
+ | `no_space` | kein Raum | No spatial reference |
43
+
44
+ Label ids: `0 perceived_space`, `1 action_space`, `2 visual_space`, `3 descriptive_space`,
45
+ `4 no_space` (stored in `config.json` as `id2label`).
46
 
47
  ## Training
48
 
49
+ ⟨Training corpus (size, source, period), annotation procedure, number of annotators and
50
+ inter-annotator agreement to be added.⟩
51
 
52
  ## Evaluation
53
 
54
+ ⟨Per-class and macro-averaged F1 on a held-out test set to be added.⟩
 
 
55
 
56
+ ## Usage
57
 
58
  ```python
59
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
60
+ import torch
61
+
62
+ name = "katrohrb/de-setting-classifier"
63
+ tok = AutoTokenizer.from_pretrained(name)
64
+ model = AutoModelForSequenceClassification.from_pretrained(name).eval()
65
 
66
+ sentence = "Er trat durch die Tür und schloss sie hinter sich."
67
+ with torch.no_grad():
68
+ probs = model(**tok(sentence, return_tensors="pt")).logits.softmax(-1)[0]
69
+ print(model.config.id2label[int(probs.argmax())])
70
+ # → action_space
71
  ```
72
 
73
+ Or with a pipeline:
74
 
75
  ```python
76
+ from transformers import pipeline
77
 
78
+ clf = pipeline("text-classification", model="katrohrb/de-setting-classifier")
79
+ clf("Vom Hügel aus konnte sie das ganze Tal unter sich liegen sehen.")
80
+ # → [{'label': 'visual_space', 'score': 0.93}]
81
  ```
82
 
83
+ ## Citation
84
 
85
+ ⟨Bibliographic reference for the underlying study to be added.⟩