File size: 2,713 Bytes
566cb74
 
 
8d78f45
 
 
 
 
 
 
 
566cb74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8d78f45
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
num rows: 3206606
file size: 2.09 GB
license: apache-2.0
task_categories:
- question-answering
- text-generation
language:
- zh
size_categories:
- 1M<n<10M
---

## describe

非常navie的场景对话,但可能出现真实场景信息,比如XX医院,XX医生

对纯指令数据质量要求较高的需要进一步清洗,只用来健康场景finetune maybe enough

## from
[[Medical-Dialogue-System]](https://github.com/UCSD-AI4H/Medical-Dialogue-System)

*[[medical_dialog]](https://huggingface.co/datasets/medical_dialog)

## format

```json
{
    "instruction": null,
    "input": "不知道,我是在09年8月份,白天出了很多的汗,晚上睡觉突然醒来,看房子天晕地转,过了大约也就一分钟的样子,就不转了.但头向左转动就又转,左边头皮还发麻.第二天起来,人没有精神,过了段时间.病情时轻时重,好像是躺在床上向右人就一上晕了.但时间不长.有一天开了一天的车,晚上先是有点头晕,走路不稳,上床休息,但突然后脑根部特别疼,到了第二天也不疼了.到现在也没有疼过.现在就是躺下和起床特别晕(头向右和头向上或向下),走路不稳.特别是站久了,就要倒了感觉.另外平常,脑袋感觉昏沉沉的,有时眼睛看东西跟不上速度,要晕的,晕的时候是脑袋里跟一片去飘过的。",
    "output": "你得的是颈椎间盘突出,可以先做保守治疗。",
    "history": [
        [
            "但,很多医生看了片子,说是张口位片枢椎似乎有些旋转移位 ,不知有没有啊。",
            "枢椎旋转移位不太可能,你的片子不是很清楚。请咨询我院骨科。"
        ],
        [
            "好的,谢谢大夫,祝您新春愉快。",
            "不客气!"
        ]
    ]
}
```

## usage

```pyth
from datasets import load_dataset
ds = load_dataset("ticoAg/Medical-Dialogue-System")
```

## process script

```python
data_dir = Path("medical_dialog\data\processed-chinese")
raw_train_ds = loadJS(data_dir.joinpath("train_data.json"))
raw_test_ds = loadJS(data_dir.joinpath("test_data.json"))
raw_valid_ds = loadJS(data_dir.joinpath("validate_data.json"))
raw_ds = raw_train_ds + raw_test_ds + raw_valid_ds
_ds = []
for i in tqdm(raw_ds):
    _diag = [{"role": dialog[:2], "content": dialog[3:]} for dialog in i]
    meta_data = sft_meta(input=_diag[0]['content'], output=_diag[1]['content'])
    if len(_diag[1]['content']) <= 6: continue  # 过滤掉太短的单次回复
    if len(_diag) > 2:
        meta_data['history'] = [[_diag[2*idx]['content'], _diag[2*idx+1]['content']] for idx in range(len(_diag)//2)][1:]
    meta_data = sortDict(meta_data)
    _ds += [meta_data]
```