Llama-3.1-EIRAI-8B-instruct: developed an 8-billion parameter model specifically tailored for Thai medical applications, with expertise in both Thai medical language and English medical terminology. The model has demonstrated its capabilities through key benchmarks such as MMLU, MedQA, PubMedQA, and MedMCQA, as well as Thai language assessments like ThaiExam, M3Exam, XNLI, and XCOPA. Additionally, we have created a Clinically Adapted Model Enhanced test using the Thai language to support clinical use in hospitals and to further improve the performance of Thai medical Retrieval-Augmented Generation (RAG).
Notice
While Eir AI Thai Medical LLM is designed to encode high-quality medical knowledge, it is not yet optimized for safe, practical use in real-world medical settings. The model is still in the research phase and should not be used for clinical decision-making without further validation, including randomized controlled trials. It is available for researchers to explore the potential of LLMs in medical contexts, but real-world deployment is not recommended in its current version.
Safety and Future Work
The current version of Eir AI Thai Medical LLM is under active development. We advise against using it for medical applications until further testing is completed. Our goal is to continue enhancing the model through rigorous testing and real-world evaluation, ensuring that it can be safely integrated into healthcare systems in the future.
<|begin_of_text|><|start_header_id|>system<|end_header_id|>
You are responsible for accurately assigning ICD-10 codes and to diagnose and document medical records.
Your expertise ensures that healthcare providers are properly reimbursed and that patient care is well-documented.
In this scenario, you will be presented with a series of medical records and your task is to provide the correct ICD-10 code(s)
and ICD-9 CM in procedures based on the information provided.
<|eot_id|>
<|start_header_id|>user<|end_header_id|>
"Chief Complaint :5วันก่อนมารพ.มีไข้ ไอ มีเสมหะ มีน้ำมูก เหนื่อย ปวดเมื่อยตามตัว \r\n
Present illness : 5วันก่อนมารพ.มีไข้ ไอ มีเสมหะ มีน้ำมูก เหนื่อย ปวดเมื่อยตามตัว มีน้ำมูก เลือดกำเดาจาากข้างขวา
ปฏิการกระทบกระแทก ไม่มีเจ็บคอ ไม่มีอาการอ่อนเพลีย มีอาการอ่อนเพลีย ไอมาก ไอตลอด มีอาการระคายคอ ปัสสาวะปกติ ไม่มีถ่ายเหลว
\r\n\r\nAllergy : |\r\n\r\nOther : no underlying disease\r\n\r\nPlan Treatment Day 1 of hospitalization : admit ward
\r\n\r\nReview of System { \r\n\r\n General :a thai adult female ,look sickness fatigue dry lip moderate dehydration
\r\n Skin :no MP rash \r\n Eyes :not pale ,no icteric sclera \r\n Chest :secretion sound in both lung ,no crepitation , no wheezing \r
\n }
VitalSign First : {\n
BP : 117.0/63.0 mmHg\n
Pulse : 62.0 BPm\n
Temperature : 37.0 Celsius\n
Respiratory rate : 20.0\n
Weight : 50.000 kgs.\n
Height : 165.0 cm.\n
Painscore: N/A\n
O2SAT : 100\n}\n
Lab Results: \n
Electrolyte:Sodium (Na), Result : 143 mmol/L\r\n
Electrolyte:Potassium (K),Result : 3.8 mmol/L\r\n
Electrolyte:Chloride (Cl), Result : 108 mmol/L\r\n
Electrolyte:Bicarbonate (CO2),Result : 27.0 mmol/L\r\n
Creatinine (Serum):Creatinine, Result : 0.69 mg/dL\r\n
Creatinine (Serum):eGFR,Result : 100.41 ml/min/1.73 m^2\r\n
AST/SGOT:AST/SGOT, Result : 48 U/L\r\n
ALT/SGPT:ALT/SGPT, Result : 42 U/L\r\n
CBC:WBC Count,Result : 3.2 10^3/uL\r\n
CBC:RBC Count, Result : 3.57 10^6/uL\r\n
CBC:Hemoglobin (Hb), Result : 10.7 g/dL\r\n
CBC:Hematocrit (HCT),Result : 32.4 %\r\n
CBC:MCV, Result : 91 fL\r\n
CBC:MCH, Result : 30.0 pg\r\n
CBC:MCHC, Result : 33.0 g/dL\r\n
CBC:RDW-CV,Result : 12.9 %\r\n
CBC:Platelet Count, Result : 226 10^3/uL\r\n
CBC:Platelet Estimates, Result : Adequate \r\n
CBC:Neutrophils,Result : 41 %\r\n
CBC:Lymphocytes, Result : 46 %\r\n
CBC:Monocytes, Result : 9 %\r\n
CBC:Eosinophils, Result : 4 %\r\n
CBC:Basophils,Result : 0 %\r\n
COVID-19 Antigen (Rapid Test) For Admit:COVID-19 Antigen (Rapid Test), Result : Positive \r\n
Influenza A/B screening:Flu A,Result : Negative \r\n
Influenza A/B screening:Flu B, Result : Negative \n
X-ray Results: 15-05-2567 12:56 CHEST (PA, UPRIGHT)\r\n
\r\nHISTORY: Fever with productive cough and dyspnea for 5 days. \r\nCOMPARISON: None.\r\n
\r\n
FINDINGS:\r\n
TUBES/LINES: None.\r\nLUNGS: Normal lung volumes. Band-like opacity at right apical lung. Clear left lung.\r\n
PLEURA: No pneumothorax or effusion. Mild bilateral apical pleural thickening. \r\n
HEART AND MEDIASTINUM: Normal cardiac silhouette. Normal mediastinal contour.\r\n
BONY STRUCTURES: Mild scoliosis of the thoracic spine. \r\n\r\n
IMPRESSION:\r\n
- Band-like opacity at right apical lung, probably plate atelectasis or fibrosis\r\n- Mild bilateral apical pleural thickening"
<|eot_id|>
<|start_header_id|>assistant<|end_header_id|>
Let's analyze the provided information and document the appropriate ICD-10 codes based on the patient's symptoms and diagnosis.
### Step-by-Step Analysis:
1. **Understand the Symptoms and Diagnosis**:
- The patient presents with a range of symptoms including fever, cough with sputum, fatigue, nasal discharge (including blood),
and dyspnea. The lab tests returned a positive COVID-19 antigen test, while the influenza test was negative.
2. **Identify Key Terms**:
- Primary key terms include 'COVID-19 positive', 'fever', 'productive cough', 'dyspnea', and pulmonary findings from the X-ray.
3. **Locate the Main Category**:
- The main categories for the conditions noted are:
- COVID-19: U07.1
- Possible acute bronchitis: J20 (based on the productive cough)
- Other symptoms such as dizziness: R42
- Evidence of acute respiratory infection: J06.9
4. **Identify Specific Codes**:
- Based on the diagnosis:
- COVID-19 confirmed case: U07.1
- Acute bronchitis: J20.9 (considering unspecified acute bronchitis)
- Dizziness (if noted as significant and problematic): R42
- Unspecified acute upper respiratory infection: J06.9
5. **Check for Additional Codes or Modifiers**:
- Considering the details provided, the primary diagnosis is the confirmed COVID-19 infection, while bronchiolitis
and dizziness might be secondary diagnoses.
6. **Validate the Code Selection**:
- Confirm that the selected codes reflect the patient's symptoms accurately, including acute bronchitis
and any other significant symptoms presented.
7. **Document the ICD-10 Code**:
- The ICD-10 codes are documented for all noted conditions accordingly."
```json
Answer: {
"Primary_Diagnosis": {
"Code": "U071",
"Description": "COVID-19, virus identified"
},
"Secondary_Diagnosis": [
{
"Code": "J20",
"Description": "Acute bronchitis due to unspecified organism"
},
{
"Code": "R42",
"Description": "Dizziness and giddiness"
},
{
"Code": "J069",
"Description": "Acute upper respiratory infection, unspecified"
}
],
"ICD9_Procedure": []
}
12from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
3import torch
45model_id ="EIRTHAIMED/Llama-3.1-EIRAI-8B"67nf4_config = BitsAndBytesConfig(8 load_in_4bit=True,9 bnb_4bit_quant_type="nf4",10 bnb_4bit_use_double_quant=True,11 bnb_4bit_compute_dtype=torch.bfloat16
12)1314# Load the base model15tokenizer = AutoTokenizer.from_pretrained(model_id)16model = AutoModelForCausalLM.from_pretrained(17 model_id,18 torch_dtype=torch.bfloat16,19# quantization_config=nf4_config, # uncomment this line for 4 bit loading20 device_map="auto",21 attn_implementation="flash_attention_2"22)2324messages =[25{"role":"system","content":"You are an expert medical assistant named EIR , developed by EIR Thai Medical LLM. You are to be a helpful, respectful, and honest assistant."},26{"role":"user","content":"การใช้ clinical tracer มีบทบาทอย่างไรในการพัฒนาคุณภาพการดูแลผู้ป่วย?"}27]2829input= tokenizer.apply_chat_template(30 messages,31 tokenize =True,32 add_generation_prompt =True,# Must add for generation33 return_tensors ="pt",34).to("cuda")353637from transformers import TextStreamer
38text_streamer = TextStreamer(tokenizer, skip_prompt =True)39_ = model.generate(input, streamer = text_streamer, max_new_tokens =1500, do_sample=True, temperature=0.01, top_k=100, top_p=0.95)4041
@article{EirAI,
title={Eir: Thai Medical Large Language Models},
author={Yutthakorn Thiprak and Rungtam Ngodngamthaweesuk and Songtam Ngodngamtaweesuk, MD},
year={2024},
journal={arXiv preprint arXiv:2409.08523},
url={https://arxiv.org/abs/2409.08523}
}
Thank you very much
Asst.Prof.Dr. Ekapol Chuangsuwanich and Praj Bhargava @Meta Research Engineer, for your valuable endorsement of our preprint paper on arXiv.