Update README.md
Browse files
README.md
CHANGED
@@ -70,18 +70,9 @@ By Language:
|
|
70 |
## Usage example
|
71 |
|
72 |
```python
|
73 |
-
from transformers import
|
74 |
-
import torch
|
75 |
|
76 |
-
|
77 |
-
model = AutoModelForSequenceClassification.from_pretrained('LenDigLearn/formality-classifier-mdeberta-v3-base')
|
78 |
-
|
79 |
-
def get_result(text):
|
80 |
-
inputs = tokenizer(text, return_tensors="pt")
|
81 |
-
with torch.no_grad():
|
82 |
-
logits = model(**inputs).logits
|
83 |
-
predicted_class_id = logits.argmax().item()
|
84 |
-
return model.config.id2label[predicted_class_id]
|
85 |
|
86 |
|
87 |
print("DE:")
|
@@ -91,7 +82,7 @@ texts_de = [
|
|
91 |
"Man muss schon wissen, was dann passiert.", "Als nächstes kommen 4g Champignons und 500g Mehl dazu.", "Bananen sind krumm.", "Das ist eine Tatsache, die unumstößlich ist.", "Hilfestellungen sind unter \"Hilfe\" zu finden."
|
92 |
]
|
93 |
for text in texts_de:
|
94 |
-
print(
|
95 |
|
96 |
print("-----------\nEN:")
|
97 |
texts_en = [
|
@@ -100,43 +91,5 @@ texts_en = [
|
|
100 |
"One would have to know what happens then.", "Then, we add 4g Mushrooms and 500g flour.", "Bananas are usually curved.", "That is an irrefutable fact.", "You can find helpful tutorials under \"help\"."
|
101 |
]
|
102 |
for text in texts_en:
|
103 |
-
print(
|
104 |
```
|
105 |
-
|
106 |
-
**Outputs:**
|
107 |
-
|
108 |
-
```bash
|
109 |
-
DE:
|
110 |
-
informal
|
111 |
-
informal
|
112 |
-
informal
|
113 |
-
informal
|
114 |
-
informal
|
115 |
-
formal
|
116 |
-
formal
|
117 |
-
formal
|
118 |
-
formal
|
119 |
-
formal
|
120 |
-
neutral
|
121 |
-
neutral
|
122 |
-
neutral
|
123 |
-
neutral
|
124 |
-
neutral
|
125 |
-
-----------
|
126 |
-
EN:
|
127 |
-
informal
|
128 |
-
informal
|
129 |
-
informal
|
130 |
-
informal
|
131 |
-
informal
|
132 |
-
formal
|
133 |
-
formal
|
134 |
-
formal
|
135 |
-
formal
|
136 |
-
formal
|
137 |
-
neutral
|
138 |
-
neutral
|
139 |
-
neutral
|
140 |
-
neutral
|
141 |
-
neutral
|
142 |
-
```
|
|
|
70 |
## Usage example
|
71 |
|
72 |
```python
|
73 |
+
from transformers import pipeline
|
|
|
74 |
|
75 |
+
pipe = pipeline("text-classification", model="LenDigLearn/formality-classifier-mdeberta-v3-base")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
|
78 |
print("DE:")
|
|
|
82 |
"Man muss schon wissen, was dann passiert.", "Als nächstes kommen 4g Champignons und 500g Mehl dazu.", "Bananen sind krumm.", "Das ist eine Tatsache, die unumstößlich ist.", "Hilfestellungen sind unter \"Hilfe\" zu finden."
|
83 |
]
|
84 |
for text in texts_de:
|
85 |
+
print(pipe(text))
|
86 |
|
87 |
print("-----------\nEN:")
|
88 |
texts_en = [
|
|
|
91 |
"One would have to know what happens then.", "Then, we add 4g Mushrooms and 500g flour.", "Bananas are usually curved.", "That is an irrefutable fact.", "You can find helpful tutorials under \"help\"."
|
92 |
]
|
93 |
for text in texts_en:
|
94 |
+
print(pipe(text))
|
95 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|