File size: 829 Bytes
5fa1a76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Train
Before you start training your model, create a map of the expected ids to their labels with id2label and label2id:

id2label = {
     0: "O",
     1: "B-corporation",
     2: "I-corporation",
     3: "B-creative-work",
     4: "I-creative-work",
     5: "B-group",
     6: "I-group",
     7: "B-location",
     8: "I-location",
     9: "B-person",
     10: "I-person",
     11: "B-product",
     12: "I-product",
 }
label2id = {
     "O": 0,
     "B-corporation": 1,
     "I-corporation": 2,
     "B-creative-work": 3,
     "I-creative-work": 4,
     "B-group": 5,
     "I-group": 6,
     "B-location": 7,
     "I-location": 8,
     "B-person": 9,
     "I-person": 10,
     "B-product": 11,
     "I-product": 12,
 }

If you aren't familiar with finetuning a model with the [Trainer], take a look at the basic tutorial here!