julian-schelb
commited on
Commit
•
5b91a3b
1
Parent(s):
b3f9993
Update README.md
Browse files
README.md
CHANGED
@@ -23,4 +23,30 @@ datasets:
|
|
23 |
#### Limitations and bias
|
24 |
This model is limited by its training dataset of entity-annotated news articles from a specific span of time. This may not generalize well for all use cases in different domains.
|
25 |
|
26 |
-
## Training data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
#### Limitations and bias
|
24 |
This model is limited by its training dataset of entity-annotated news articles from a specific span of time. This may not generalize well for all use cases in different domains.
|
25 |
|
26 |
+
## Training data
|
27 |
+
|
28 |
+
|
29 |
+
## Usage
|
30 |
+
|
31 |
+
```python
|
32 |
+
|
33 |
+
model_tuned = RobertaForTokenClassification.from_pretrained("./results/checkpoint-final/")
|
34 |
+
|
35 |
+
text = "Für Richard Phillips Feynman war es immer wichtig in New York, die unanschaulichen Gesetzmäßigkeiten der Quantenphysik Laien und Studenten nahezubringen und verständlich zu machen."
|
36 |
+
|
37 |
+
inputs = tokenizer(
|
38 |
+
text,
|
39 |
+
add_special_tokens=False, return_tensors="pt"
|
40 |
+
)
|
41 |
+
|
42 |
+
with torch.no_grad():
|
43 |
+
logits = model_tuned(**inputs).logits
|
44 |
+
|
45 |
+
predicted_token_class_ids = logits.argmax(-1)
|
46 |
+
|
47 |
+
# Note that tokens are classified rather then input words which means that
|
48 |
+
# there might be more predicted token classes than words.
|
49 |
+
# Multiple token classes might account for the same word
|
50 |
+
predicted_tokens_classes = [model_tuned.config.id2label[t.item()] for t in predicted_token_class_ids[0]]
|
51 |
+
predicted_tokens_classes
|
52 |
+
```
|