Instructions to use roberthsu2003/models_for_ner with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use roberthsu2003/models_for_ner with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="roberthsu2003/models_for_ner")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("roberthsu2003/models_for_ner") model = AutoModelForTokenClassification.from_pretrained("roberthsu2003/models_for_ner", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -40,7 +40,16 @@ It achieves the following results on the evaluation set:
|
|
| 40 |
### 使用方法(how to use)
|
| 41 |
|
| 42 |
```python
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
```
|
| 45 |
|
| 46 |
## Intended uses & limitations
|
|
|
|
| 40 |
### 使用方法(how to use)
|
| 41 |
|
| 42 |
```python
|
| 43 |
+
ner_pipe = pipeline("token-classification", model='roberthsu2003/models_for_ner',aggregation_strategy="simple")
|
| 44 |
+
inputs = "徐國堂在台北上班"
|
| 45 |
+
res = ner_pipe(inputs)
|
| 46 |
+
|
| 47 |
+
ner_result = {}
|
| 48 |
+
for r in res:
|
| 49 |
+
if r["entity_group"] not in ner_datasets:
|
| 50 |
+
ner_result[r['entity_group']] = []
|
| 51 |
+
ner_result[r['entity_group']].append(inputs[r['start']:r['end']])
|
| 52 |
+
ner_result
|
| 53 |
```
|
| 54 |
|
| 55 |
## Intended uses & limitations
|