Upload 6 files
Browse files- README.md +26 -0
- config.json +51 -0
- drug_classifier.onnx +3 -0
- special_tokens_map.json +7 -0
- tokenizer_config.json +58 -0
- vocab.txt +0 -0
README.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|
config.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "bert-base-uncased",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"BertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"classifier_dropout": null,
|
| 8 |
+
"gradient_checkpointing": false,
|
| 9 |
+
"hidden_act": "gelu",
|
| 10 |
+
"hidden_dropout_prob": 0.1,
|
| 11 |
+
"hidden_size": 768,
|
| 12 |
+
"id2label": {
|
| 13 |
+
"0": "Albuterol",
|
| 14 |
+
"1": "Amoxicillin",
|
| 15 |
+
"2": "Fluoxetine",
|
| 16 |
+
"3": "Ibuprofen",
|
| 17 |
+
"4": "Levothyroxine",
|
| 18 |
+
"5": "Loratadine",
|
| 19 |
+
"6": "Losartan",
|
| 20 |
+
"7": "Metformin",
|
| 21 |
+
"8": "Omeprazole",
|
| 22 |
+
"9": "Simvastatin"
|
| 23 |
+
},
|
| 24 |
+
"initializer_range": 0.02,
|
| 25 |
+
"intermediate_size": 3072,
|
| 26 |
+
"label2id": {
|
| 27 |
+
"Albuterol": 0,
|
| 28 |
+
"Amoxicillin": 1,
|
| 29 |
+
"Fluoxetine": 2,
|
| 30 |
+
"Ibuprofen": 3,
|
| 31 |
+
"Levothyroxine": 4,
|
| 32 |
+
"Loratadine": 5,
|
| 33 |
+
"Losartan": 6,
|
| 34 |
+
"Metformin": 7,
|
| 35 |
+
"Omeprazole": 8,
|
| 36 |
+
"Simvastatin": 9
|
| 37 |
+
},
|
| 38 |
+
"layer_norm_eps": 1e-12,
|
| 39 |
+
"max_position_embeddings": 512,
|
| 40 |
+
"model_type": "bert",
|
| 41 |
+
"num_attention_heads": 12,
|
| 42 |
+
"num_hidden_layers": 12,
|
| 43 |
+
"pad_token_id": 0,
|
| 44 |
+
"position_embedding_type": "absolute",
|
| 45 |
+
"problem_type": "single_label_classification",
|
| 46 |
+
"torch_dtype": "float32",
|
| 47 |
+
"transformers_version": "4.49.0",
|
| 48 |
+
"type_vocab_size": 2,
|
| 49 |
+
"use_cache": true,
|
| 50 |
+
"vocab_size": 30522
|
| 51 |
+
}
|
drug_classifier.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:174ae9c49049970cebb33214d2062d41251ecf549c1148412f0082d1319cedb4
|
| 3 |
+
size 442940830
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cls_token": "[CLS]",
|
| 3 |
+
"mask_token": "[MASK]",
|
| 4 |
+
"pad_token": "[PAD]",
|
| 5 |
+
"sep_token": "[SEP]",
|
| 6 |
+
"unk_token": "[UNK]"
|
| 7 |
+
}
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"100": {
|
| 12 |
+
"content": "[UNK]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"101": {
|
| 20 |
+
"content": "[CLS]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"102": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"103": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"clean_up_tokenization_spaces": true,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"do_basic_tokenize": true,
|
| 47 |
+
"do_lower_case": true,
|
| 48 |
+
"extra_special_tokens": {},
|
| 49 |
+
"mask_token": "[MASK]",
|
| 50 |
+
"model_max_length": 512,
|
| 51 |
+
"never_split": null,
|
| 52 |
+
"pad_token": "[PAD]",
|
| 53 |
+
"sep_token": "[SEP]",
|
| 54 |
+
"strip_accents": null,
|
| 55 |
+
"tokenize_chinese_chars": true,
|
| 56 |
+
"tokenizer_class": "BertTokenizer",
|
| 57 |
+
"unk_token": "[UNK]"
|
| 58 |
+
}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|