Dataset Viewer
Full Screen Viewer
Full Screen
The dataset could not be loaded because the splits use different data file formats, which is not supported. Read more about the splits configuration. Click for more details.
Couldn't infer the same data file format for all splits. Got {NamedSplit('train'): ('text', {}), NamedSplit('test'): ('json', {})}
Error code: FileFormatMismatchBetweenSplitsError
Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
TCMChat: A Generative Large Language Model for Traditional Chinese Medicine
News
[2024-11-1] We have fully open-sourced the model weights and training dataset on Huggingface.
[2024-5-17] Open source model weight on HuggingFace.
Application
Install
git clone https://github.com/ZJUFanLab/TCMChat
cd TCMChat
Create a conda environment
conda create -n baichuan2 python=3.10 -y
First install the dependency package. python environment 3.10+ is recommended.
pip install -r requirements.txt
Weights download
- TCMChat: QA and recommendation of TCM knowledge based on baichuan2-7B-Chat.
Inference
Command line
python cli_infer.py \
--model_name_or_path /your/model/path \
--model_type chat
Web demo
python gradio_demo.py
We provide an online tool:https://xomics.com.cn/tcmchat
Retrain
Dataset Download
Note: Before performing pre-training, fine-tuning, and inference, please modify the relevant paths for your model, data, and other related files.
Pre-training
## Slurm cluster
sbatch scripts/pretrain/baichuan2_7b_chat.slurm
## or
bash scripts/pretrain/baichuan2_7b_chat.sh
Fine-tuning
## Slurm cluster
sbatch scripts/sft/baichuan2_7b_chat.slurm
## or
bash scripts/sft/baichuan2_7b_chat.sh
Training details
Please refer to the experimental section of the paper for instructions.
Benchmark evaluation
Choice Question
python evaluation/choices_evaluate/eval.py --model_path_or_name /your/model/path --model_name baichuan2-7b-chat --few_shot -sz herb --dev_file_path evaluation/resources/choice/single/tcm-herb_dev.csv --val_file_path evaluation/resources/choice/single/choice_herb_500.csv --log_dir logs/choices
Reading Comprehension
python infers/baichuan_infer.py \
--model_name_or_path /your/model/path / \
--model_type chat \
--save_path /your/save/data/path \
--data_path /your/data/path
##BertScore
python evaluation/question_rouge_bleu.py/question_bert_score.py
## BLEU METEOR
python evaluation/question_rouge_bleu.py/open_question_bleu.py
## ROUGE-x
python evaluation/question_rouge_bleu.py/open_question_rouge.py
Entity Extraction
python infers/baichuan_infer.py \
--model_name_or_path /your/model/path / \
--model_type chat \
--save_path /your/save/data/path \
--data_path /your/data/path
python evaluation/ner_evaluate/tcm_entity_recognition.py
Medical Case Diagnosis
python infers/baichuan_infer.py \
--model_name_or_path /your/model/path / \
--model_type chat \
--save_path /your/save/data/path \
--data_path /your/data/path
python evaluation/acc_evaluate/extract_syndrome.py
Herb or Formula Recommendation
python infers/baichuan_infer.py \
--model_name_or_path /your/model/path / \
--model_type chat \
--save_path /your/save/data/path \
--data_path /your/data/path
python evaluation/recommend_evaluate/mrr_ndcg_p_r.py
ADMET Prediction
Regression
python infers/baichuan_infer.py \
--model_name_or_path /your/model/path / \
--model_type chat \
--save_path /your/save/data/path \
--data_path /your/data/path
python evaluation/admet_evaluate/rmse_mae_mse.py
Classification
python infers/baichuan_infer.py \
--model_name_or_path /your/model/path / \
--model_type chat \
--save_path /your/save/data/path \
--data_path /your/data/path
python evaluation/admet_evaluate/acc_recall_f1.py
- Downloads last month
- 128