wilsontam commited on
Commit
3847186
1 Parent(s): b1db8b3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -0
README.md CHANGED
@@ -20,4 +20,27 @@ Label map:
20
  "B-attraction": 5
21
  "I-attraction": 6
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  Credit: Jia-Chen Jason Gu, Wilson Tam
 
20
  "B-attraction": 5
21
  "I-attraction": 6
22
 
23
+ from transformers import AutoConfig, AutoModelForTokenClassification, BertTokenizer
24
+ from transformers import TokenClassificationPipeline
25
+ import json
26
+
27
+ model_path = "wilsontam/dstc9_ner"
28
+
29
+ config = AutoConfig.from_pretrained(
30
+ model_path,
31
+ num_labels=7,
32
+ )
33
+ model = AutoModelForTokenClassification.from_pretrained(
34
+ model_path,
35
+ from_tf=False,
36
+ config=config,
37
+ )
38
+ tokenizer = BertTokenizer.from_pretrained(
39
+ model_path,
40
+ )
41
+
42
+ pipeline = TokenClassificationPipeline(model, tokenizer, device=-1)
43
+
44
+ tokens = pipeline(["i want to book the hilton hotel near china town.", "can you reserve A & B restaurant for me?"])
45
+
46
  Credit: Jia-Chen Jason Gu, Wilson Tam