Views
No views yet
예) C3843080 || 고혈압 질환
C3843080 || Hypertension
C3843080 || High Blood Pressure
C3843080 || HTN
C3843080 || HBP예) 한국어 병명: 고혈압
영어 병명: Hypertenstion
질의 (원본): 아버지가 고혈압인데 그게 뭔지 모르겠어. 고혈압이 뭔지 설명좀 해줘.
질의 (증강): 아버지가 Hypertenstion 인데 그게 뭔지 모르겠어. Hypertenstion 이 뭔지 설명좀 해줘.1import numpy as np
2from transformers import AutoModel, AutoTokenizer
3
4# Question Model
5q_model_path = 'snumin44/medical-biencoder-ko-bert-question'
6q_model = AutoModel.from_pretrained(q_model_path)
7q_tokenizer = AutoTokenizer.from_pretrained(q_model_path)
8
9# Context Model
10c_model_path = 'snumin44/medical-biencoder-ko-bert-context'
11c_model = AutoModel.from_pretrained(c_model_path)
12c_tokenizer = AutoTokenizer.from_pretrained(c_model_path)
13
14
15query = 'high blood pressure 처방 사례'
16
17targets = [
18 """고혈압 진단.
19 환자 상담 및 생활습관 교정 권고. 저염식, 규칙적인 운동, 금연, 금주 지시.
20 환자 재방문. 혈압: 150/95mmHg. 약물치료 시작. Amlodipine 5mg 1일 1회 처방.""",
21
22 """응급실 도착 후 위 내시경 진행.
23 소견: Gastric ulcer에서 Forrest IIb 관찰됨. 출혈은 소량의 삼출성 출혈 형태.
24 처치: 에피네프린 주사로 출혈 감소 확인. Hemoclip 2개로 출혈 부위 클리핑하여 지혈 완료.""",
25
26 """혈중 높은 지방 수치 및 지방간 소견.
27 다발성 gallstones 확인. 증상 없을 경우 경과 관찰 권장.
28 우측 renal cyst, 양성 가능성 높으며 추가적인 처치 불필요 함."""
29]
30
31query_feature = q_tokenizer(query, return_tensors='pt')
32query_outputs = q_model(**query_feature, return_dict=True)
33query_embeddings = query_outputs.pooler_output.detach().numpy().squeeze()
34
35def cos_sim(A, B):
36 return np.dot(A, B) / (np.linalg.norm(A) * np.linalg.norm(B))
37
38for idx, target in enumerate(targets):
39 target_feature = c_tokenizer(target, return_tensors='pt')
40 target_outputs = c_model(**target_feature, return_dict=True)
41 target_embeddings = target_outputs.pooler_output.detach().numpy().squeeze()
42 similarity = cos_sim(query_embeddings, target_embeddings)
43 print(f"Similarity between query and target {idx}: {similarity:.4f}")Similarity between query and target 0: 0.2674
Similarity between query and target 1: 0.0416
Similarity between query and target 2: 0.0476@inproceedings{liu2021self,
title={Self-Alignment Pretraining for Biomedical Entity Representations},
author={Liu, Fangyu and Shareghi, Ehsan and Meng, Zaiqiao and Basaldella, Marco and Collier, Nigel},
booktitle={Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies},
pages={4228--4238},
month = jun,
year={2021}
}
@article{karpukhin2020dense,
title={Dense Passage Retrieval for Open-Domain Question Answering},
author={Vladimir Karpukhin, Barlas Oğuz, Sewon Min, Patrick Lewis, Ledell Wu, Sergey Edunov, Danqi Chen, Wen-tau Yih},
journal={Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP)},
year={2020}
}