Views
No views yet
1from transformers import pipeline
2import torch
3
4# Initiate the pipeline
5device = 0 if torch.cuda.is_available() else 'cpu'
6ner = pipeline("token-classification", "arnabdhar/bert-tiny-ontonotes", device=device)
7
8# use the pipeline
9input_text = "My name is Clara and I live in Berkeley, California."
10results = ner(input_text)train, validation and test, all the 3 partitions were combined and then a 80:20 train-test split was made for finet uning process. The following ID2LABEL mapping was used.1{
2 "0": "O",
3 "1": "B-CARDINAL",
4 "2": "B-DATE",
5 "3": "I-DATE",
6 "4": "B-PERSON",
7 "5": "I-PERSON",
8 "6": "B-NORP",
9 "7": "B-GPE",
10 "8": "I-GPE",
11 "9": "B-LAW",
12 "10": "I-LAW",
13 "11": "B-ORG",
14 "12": "I-ORG",
15 "13": "B-PERCENT",
16 "14": "I-PERCENT",
17 "15": "B-ORDINAL",
18 "16": "B-MONEY",
19 "17": "I-MONEY",
20 "18": "B-WORK_OF_ART",
21 "19": "I-WORK_OF_ART",
22 "20": "B-FAC",
23 "21": "B-TIME",
24 "22": "I-CARDINAL",
25 "23": "B-LOC",
26 "24": "B-QUANTITY",
27 "25": "I-QUANTITY",
28 "26": "I-NORP",
29 "27": "I-LOC",
30 "28": "B-PRODUCT",
31 "29": "I-TIME",
32 "30": "B-EVENT",
33 "31": "I-EVENT",
34 "32": "I-FAC",
35 "33": "B-LANGUAGE",
36 "34": "I-PRODUCT",
37 "35": "I-ORDINAL",
38 "36": "I-LANGUAGE"
39 }| Training Loss | Epoch | Step | Validation Loss | Recall | Precision | F1 | Accuracy |
|---|---|---|---|---|---|---|---|
| 0.4283 | 0.31 | 600 | 0.3864 | 0.4561 | 0.4260 | 0.4405 | 0.9058 |
| 0.3214 | 0.63 | 1200 | 0.2865 | 0.5865 | 0.5485 | 0.5669 | 0.9265 |
| 0.2886 | 0.94 | 1800 | 0.2439 | 0.6432 | 0.6165 | 0.6295 | 0.9354 |
| 0.2511 | 1.25 | 2400 | 0.2233 | 0.6765 | 0.6250 | 0.6497 | 0.9389 |
| 0.2224 | 1.56 | 3000 | 0.2088 | 0.6878 | 0.6642 | 0.6758 | 0.9433 |
| 0.2181 | 1.88 | 3600 | 0.2001 | 0.7105 | 0.6684 | 0.6888 | 0.9451 |
| 0.215 | 2.19 | 4200 | 0.1954 | 0.7140 | 0.6795 | 0.6963 | 0.9469 |
| 0.1907 | 2.5 | 4800 | 0.1934 | 0.7169 | 0.6776 | 0.6967 | 0.9470 |
| 0.209 | 2.82 | 5400 | 0.1918 | 0.7185 | 0.6812 | 0.6994 | 0.9475 |
| 0.2073 | 3.13 | 6000 | 0.1917 | 0.7193 | 0.6817 | 0.7000 | 0.9476 |