SinclairSchneider commited on
Commit
e704b8f
·
verified ·
1 Parent(s): 470b7ff

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +58 -190
README.md CHANGED
@@ -19,175 +19,6 @@ Precision: 0.79
19
 
20
  Recall: 0.74
21
 
22
- # Model Card for Model ID
23
-
24
- <!-- Provide a quick summary of what the model is/does. -->
25
-
26
-
27
-
28
- ## Model Details
29
-
30
- ### Model Description
31
-
32
- <!-- Provide a longer summary of what this model is. -->
33
-
34
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
35
-
36
- - **Developed by:** [More Information Needed]
37
- - **Funded by [optional]:** [More Information Needed]
38
- - **Shared by [optional]:** [More Information Needed]
39
- - **Model type:** [More Information Needed]
40
- - **Language(s) (NLP):** [More Information Needed]
41
- - **License:** [More Information Needed]
42
- - **Finetuned from model [optional]:** [More Information Needed]
43
-
44
- ### Model Sources [optional]
45
-
46
- <!-- Provide the basic links for the model. -->
47
-
48
- - **Repository:** [More Information Needed]
49
- - **Paper [optional]:** [More Information Needed]
50
- - **Demo [optional]:** [More Information Needed]
51
-
52
- ## Uses
53
-
54
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
55
-
56
- ### Direct Use
57
-
58
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
59
-
60
- [More Information Needed]
61
-
62
- ### Downstream Use [optional]
63
-
64
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
65
-
66
- [More Information Needed]
67
-
68
- ### Out-of-Scope Use
69
-
70
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
71
-
72
- [More Information Needed]
73
-
74
- ## Bias, Risks, and Limitations
75
-
76
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
77
-
78
- [More Information Needed]
79
-
80
- ### Recommendations
81
-
82
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
83
-
84
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
85
-
86
- ## How to Get Started with the Model
87
-
88
- Use the code below to get started with the model.
89
-
90
- [More Information Needed]
91
-
92
- ## Training Details
93
-
94
- ### Training Data
95
-
96
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
97
-
98
- [More Information Needed]
99
-
100
- ### Training Procedure
101
-
102
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
103
-
104
- #### Preprocessing [optional]
105
-
106
- [More Information Needed]
107
-
108
-
109
- #### Training Hyperparameters
110
-
111
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
112
-
113
- #### Speeds, Sizes, Times [optional]
114
-
115
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
116
-
117
- [More Information Needed]
118
-
119
- ## Evaluation
120
-
121
- <!-- This section describes the evaluation protocols and provides the results. -->
122
-
123
- ### Testing Data, Factors & Metrics
124
-
125
- #### Testing Data
126
-
127
- <!-- This should link to a Dataset Card if possible. -->
128
-
129
- [More Information Needed]
130
-
131
- #### Factors
132
-
133
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
134
-
135
- [More Information Needed]
136
-
137
- #### Metrics
138
-
139
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
140
-
141
- [More Information Needed]
142
-
143
- ### Results
144
-
145
- [More Information Needed]
146
-
147
- #### Summary
148
-
149
-
150
-
151
- ## Model Examination [optional]
152
-
153
- <!-- Relevant interpretability work for the model goes here -->
154
-
155
- [More Information Needed]
156
-
157
- ## Environmental Impact
158
-
159
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
160
-
161
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
162
-
163
- - **Hardware Type:** [More Information Needed]
164
- - **Hours used:** [More Information Needed]
165
- - **Cloud Provider:** [More Information Needed]
166
- - **Compute Region:** [More Information Needed]
167
- - **Carbon Emitted:** [More Information Needed]
168
-
169
- ## Technical Specifications [optional]
170
-
171
- ### Model Architecture and Objective
172
-
173
- [More Information Needed]
174
-
175
- ### Compute Infrastructure
176
-
177
- [More Information Needed]
178
-
179
- #### Hardware
180
-
181
- [More Information Needed]
182
-
183
- #### Software
184
-
185
- [More Information Needed]
186
-
187
- ## Citation [optional]
188
-
189
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
190
-
191
  **BibTeX:**
192
 
193
  @misc {schneider2024GerPolClass,
@@ -200,24 +31,61 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
200
  note = { DeBERTa transformer model }
201
  }
202
 
203
- **APA:**
204
-
205
- [More Information Needed]
206
-
207
- ## Glossary [optional]
208
-
209
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
210
-
211
- [More Information Needed]
212
-
213
- ## More Information [optional]
214
-
215
- [More Information Needed]
216
-
217
- ## Model Card Authors [optional]
218
-
219
- [More Information Needed]
220
-
221
- ## Model Card Contact
222
-
223
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  Recall: 0.74
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  **BibTeX:**
23
 
24
  @misc {schneider2024GerPolClass,
 
31
  note = { DeBERTa transformer model }
32
  }
33
 
34
+ # Ideology Prediction of German Political Texts based on DeBERTa-large (highly experimental)
35
+
36
+ Predicts the ideology of German texts on a scale from -1 (left-wing) over 0 (liberal) to 1 (right wing)
37
+
38
+ Simple example
39
+
40
+ ```python
41
+ from transformers import pipeline, DebertaV2ForSequenceClassification, AutoTokenizer
42
+ import numpy as np
43
+ import pandas as pd
44
+ import torch
45
+
46
+ model_name = "SinclairSchneider/german_politic_direction_DeBERTa-large"
47
+ model = DebertaV2ForSequenceClassification.from_pretrained(model_name, dtype=torch.bfloat16)
48
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
49
+ pipe = pipeline("text-classification", model=model, tokenizer=tokenizer, top_k=None)
50
+
51
+ vectors = np.array([[-1, 0],
52
+ [-9.99193435e-01, 4.01556900e-02],
53
+ [-9.18323655e-01, 3.95830349e-01],
54
+ [ 3.82683432e-01, 9.23879533e-01],
55
+ [ 8.69790824e-01, 4.93420634e-01],
56
+ [1, 0]])
57
+
58
+ def classify(text):
59
+ classification_result = np.array(pd.DataFrame(pipe(text)[0]).sort_values(by=['label'], key=lambda x: x.map({'DIE LINKE':0,
60
+ 'BÜNDNIS 90/DIE GRÜNEN':1,
61
+ 'SPD':2,
62
+ 'FDP':3,
63
+ 'CDU/CSU':4,
64
+ 'AfD':5}))['score'])
65
+ return float(np.arctan2(*classification_result@vectors)/(np.pi/2))
66
+
67
+ #Links
68
+ print(classify("Wir brauchen eine Vermögensteuer, um den Sozialstaat nachhaltig zu finanzieren."))
69
+ #-0.8840736055794486
70
+ print(classify("Mietendeckel und mehr gemeinnütziger Wohnungsbau sollen Wohnen bezahlbar machen."))
71
+ #-0.9584728540548622
72
+ print(classify("Die Energiewende muss mit massiven öffentlichen Investitionen beschleunigt werden."))
73
+ #-0.8996415250285207
74
+
75
+
76
+ #Mitte
77
+ print(classify("Die soziale Marktwirtschaft braucht moderne Regeln und weniger Bürokratie."))
78
+ #0.2951027133966755
79
+ print(classify("Gezielte Entlastungen für kleine und mittlere Einkommen stärken die Mitte."))
80
+ #-0.5463382000342903
81
+ print(classify("Bildungsoffensive: Basiskompetenzen sichern, Weiterbildung im Beruf fördern."))
82
+ #0.16923175427437903
83
+
84
+ #Rechts
85
+ print(classify("Deutsche Leitkultur und Sprache stärker in öffentlichen Einrichtungen betonen."))
86
+ #0.9907646874287308
87
+ print(classify("Grenzschutz an EU-Außengrenzen verstärken, Sekundärmigration begrenzen."))
88
+ #0.7533596283240895
89
+ print(classify("Identitätspolitik an Schulen und Behörden zurückfahren, Fokus auf Leistungsprinzip."))
90
+ #0.9748775694774731
91
+ ```