Hello! Welcome to the huggingface repository for Diabetica.
Our study introduced a reproducible framework for developing a specialized LLM capable of handling various diabetes tasks. We present three key contributions:
High-performance domain-specific model: Compared with previous generic LLMs, our model Diabetica, showed superior performance across a broad range of diabetes-related tasks, including diagnosis, treatment recommendations, medication management, lifestyle advice, patient education, and so on.
Reproducible framework: We offered a detailed method for creating specialized medical LLMs using open-source models, curated disease-specific datasets, and fine-tuning techniques. This approach can be adapted to other medical fields, potentially accelerating AI-assisted care development.
Comprehensive evaluation: We designed comprehensive benchmarks and conducted clinical trials to validate the model's effectiveness in clinical applications. This ensured our model's practical utility and sets a new standard for evaluating AI tools in diabetes care.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
34device ="cuda"# the device to load the model onto5model_path ='WaltonFuture/Diabetica-7B'67model = AutoModelForCausalLM.from_pretrained(8 model_path,
9torch_dtype="auto",
10device_map="auto"11)12tokenizer = AutoTokenizer.from_pretrained(model_path)1314def model_output(content):
15 messages =[16{"role":"system", "content":"You are a helpful assistant."},
17{"role":"user", "content": content}18]19 text = tokenizer.apply_chat_template(20 messages,
21tokenize=False,
22add_generation_prompt=True
23)24 model_inputs = tokenizer([text], return_tensors="pt").to(device)25 generated_ids = model.generate(26 model_inputs.input_ids,
27max_new_tokens=2048,
28do_sample=True,
29)30 generated_ids =[31 output_ids[len(input_ids):]for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)32]33 response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]34return response
3536prompt ="Hello! Please tell me something about diabetes."3738response = model_output(prompt)39print(response)
Citation
@article{wei2024adapted,
title={An adapted large language model facilitates multiple medical tasks in diabetes care},
author={Wei, Lai and Ying, Zhen and He, Muyang and Chen, Yutong and Yang, Qian and Hong, Yanzhe and Lu, Jiaping and Li, Xiaoying and Huang, Weiran and Chen, Ying},
journal={arXiv preprint arXiv:2409.13191},
year={2024}
}