xuxiaoda commited on
Commit
006e0da
·
verified ·
1 Parent(s): 79c67f4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +51 -29
README.md CHANGED
@@ -1,29 +1,51 @@
1
- ---
2
- language: en
3
- license: apache-2.0
4
- library_name: transformers
5
- tags:
6
- - pharmacy
7
- - drug-classification
8
- - onnx
9
- ---
10
-
11
- # 药品分类模型(ONNX格式)
12
-
13
- ## 模型描述
14
- BERT-base微调的药品分类模型,转换为ONNX格式
15
-
16
- ## 使用方式
17
- ```python
18
- from transformers import AutoTokenizer, pipeline
19
- from onnxruntime import InferenceSession
20
-
21
- tokenizer = AutoTokenizer.from_pretrained("您的用户名/模型名")
22
- session = InferenceSession("model.onnx")
23
-
24
- # 预处理
25
- inputs = tokenizer("I have a headache", return_tensors="np")
26
-
27
- # 推理
28
- outputs = session.run(None, dict(inputs))
29
- predicted_id = outputs[0].argmax()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: apache-2.0
4
+ library_name: transformers
5
+ tags:
6
+ - pharmacy
7
+ - drug-classification
8
+ - onnx
9
+ ---
10
+
11
+ # 药品分类模型(ONNX格式)
12
+
13
+ ## 模型描述
14
+ BERT-base微调的药品分类模型,转换为ONNX格式
15
+
16
+ ## 使用方式
17
+ ```python
18
+ from transformers import AutoTokenizer, pipeline
19
+ from onnxruntime import InferenceSession
20
+
21
+ tokenizer = AutoTokenizer.from_pretrained("您的用户名/模型名")
22
+ session = InferenceSession("model.onnx")
23
+
24
+ # 预处理
25
+ inputs = tokenizer("I have a headache", return_tensors="np")
26
+
27
+ # 推理
28
+ outputs = session.run(None, dict(inputs))
29
+ predicted_id = outputs[0].argmax()
30
+
31
+
32
+ ##前端使用方式
33
+ <!DOCTYPE html>
34
+ <html lang="en">
35
+ <head>
36
+ <meta charset="UTF-8" />
37
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
38
+ <title>Transformers.js Example</title>
39
+ </head>
40
+ <body>
41
+ <h1>Transformers.js in Browser</h1>
42
+ <script type="module">
43
+ import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers';
44
+ // 创建一个情感分析的 pipeline
45
+ const classifier = await pipeline('text-classification','xuxiaoda/drug_classification');
46
+ // 执行情感分析
47
+ const result = await classifier('What are the drugs for treating high blood pressure?');
48
+ console.log(result[0].label);
49
+ </script>
50
+ </body>
51
+ </html>