Update README.md
Browse files
README.md
CHANGED
|
@@ -123,18 +123,24 @@ The following hyperparameters were used during training:
|
|
| 123 |
|
| 124 |
```python
|
| 125 |
import torch
|
| 126 |
-
from transformers import AutoTokenizer,
|
| 127 |
-
from transformers import pipeline
|
| 128 |
|
| 129 |
# Create NER pipeline
|
| 130 |
-
ner_pipeline = pipeline(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
# Example usage
|
| 133 |
text = "Apple Inc. was founded by Steve Jobs in Cupertino, California."
|
| 134 |
entities = ner_pipeline(text)
|
| 135 |
|
| 136 |
for entity in entities:
|
| 137 |
-
print(
|
|
|
|
|
|
|
| 138 |
```
|
| 139 |
|
| 140 |
## Ethical Considerations
|
|
|
|
| 123 |
|
| 124 |
```python
|
| 125 |
import torch
|
| 126 |
+
from transformers import AutoModelForTokenClassification, AutoTokenizer, pipeline
|
|
|
|
| 127 |
|
| 128 |
# Create NER pipeline
|
| 129 |
+
ner_pipeline = pipeline(
|
| 130 |
+
"token-classification",
|
| 131 |
+
model="MatteoFasulo/ModernBERT-base-NER",
|
| 132 |
+
aggregation_strategy="simple",
|
| 133 |
+
dtype=torch.bfloat16,
|
| 134 |
+
)
|
| 135 |
|
| 136 |
# Example usage
|
| 137 |
text = "Apple Inc. was founded by Steve Jobs in Cupertino, California."
|
| 138 |
entities = ner_pipeline(text)
|
| 139 |
|
| 140 |
for entity in entities:
|
| 141 |
+
print(
|
| 142 |
+
f"{entity['word']}: {entity['entity_group']} (confidence: {entity['score']:.4f})"
|
| 143 |
+
)
|
| 144 |
```
|
| 145 |
|
| 146 |
## Ethical Considerations
|