Democratizing Medical LLMs For Much More Languages
Covering 12 Major Languages including English, Chinese, French, Hindi, Spanish, Arabic, Russian, Japanese, Korean, German, Italian, Portuguese and 38 Minor Languages So far.
1from huggingface_hub import snapshot_download
2import os
34local_model_dir=os.path.join('/path/to/models/dir','Apollo-MoE-0.5B')5snapshot_download(repo_id="FreedomIntelligence/Apollo-MoE-0.5B", local_dir=local_model_dir)
Inference Example
python
1from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
2import os
34local_model_dir=os.path.join('/path/to/models/dir','Apollo-MoE-0.5B')56model=AutoModelForCausalLM.from_pretrained(local_model_dir,trust_remote_code=True)7tokenizer = AutoTokenizer.from_pretrained(local_model_dir,trust_remote_code=True)8generation_config = GenerationConfig.from_pretrained(local_model_dir, pad_token_id=tokenizer.pad_token_id, num_return_sequences=1, max_new_tokens=7, min_new_tokens=2, do_sample=False, temperature=1.0, top_k=50, top_p=1.0)910inputs = tokenizer('Answer direclty.\nThe capital of Mongolia is Ulaanbaatar.\nThe capital of Iceland is Reykjavik.\nThe capital of Australia is', return_tensors='pt')11inputs = inputs.to(model.device)12pred = model.generate(**inputs,generation_config=generation_config)13print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))
Results reproduction
Click to expand
We take Apollo2-7B or Apollo-MoE-0.5B as example
Download Dataset for project:
bash 0.download_data.sh
Prepare test and dev data for specific model:
Create test data for with special token
bash 1.data_process_test&dev.sh
Prepare train data for specific model (Create tokenized data in advance):
You can adjust data Training order and Training Epoch in this step
bash 2.data_process_train.sh
Train the model
If you want to train in Multi Nodes please refer to ./src/sft/training_config/zero_multi.yaml
bash 3.single_node_train.sh
Evaluate your model: Generate score for benchmark
bash 4.eval.sh
Citation
Please use the following citation if you intend to use our dataset for training or evaluation:
@misc{zheng2024efficientlydemocratizingmedicalllms,
title={Efficiently Democratizing Medical LLMs for 50 Languages via a Mixture of Language Family Experts},
author={Guorui Zheng and Xidong Wang and Juhao Liang and Nuo Chen and Yuping Zheng and Benyou Wang},
year={2024},
eprint={2410.10626},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2410.10626},
}