AquilaMed-RL / README.md
MonteXiaofeng's picture
Upload README.md
d0bff7c verified
|
raw
history blame
2.91 kB
metadata
license: apache-2.0

Introduction

Aquila is a large language model trained by BAAI, and AquilaMed-RL is an industry model from Aquila language model. Based on the Aquila general pre-trained model, we continued pre-training , SFT and RL in the medical domain and obtained our AquilaMed-RL model.

Model Details

The pipeline of the training procedure is bellow, for more details you can read our technical report: https://github.com/FlagAI-Open/industry-application/blob/main/Aquila_med_tech-report.pdf

pipeline

Evaluation

pipeline

usage

when you have downloaded the model, you can use the bellow code to run the model


import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig


model_dir = "xxx"

tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True)

config = AutoConfig.from_pretrained(model_dir, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_dir, config=config, trust_remote_code=True
)
model.cuda()
model.eval()

template = "<|im_start|>system\nYou are a helpful assistant in medical domain.<|im_end|>\n<|im_start|>user\n{question}<|im_end|>\n<|im_start|>assistant\n"

text = "我肚子疼怎么办?"

item_instruction = template.format(question=text)

inputs = tokenizer(item_instruction, return_tensors="pt").to("cuda")
input_ids = inputs["input_ids"]
prompt_length = len(input_ids[0])
generate_output = model.generate(
    input_ids=input_ids, do_sample=False, max_length=1024, return_dict_in_generate=True
)

response_ids = generate_output.sequences[0][prompt_length:]
predicts = tokenizer.decode(
    response_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True
)

print("predict:", predicts)


"""
predict: 肚子疼可能是多种原因引起的,例如消化不良、胃炎、胃溃疡、胆囊炎、胰腺炎、肠道感染等。如果疼痛持续或加重,或者伴随有呕吐、腹泻、发热等症状,建议尽快就医。如果疼痛轻微,可以尝试以下方法缓解:

1. 饮食调整:避免油腻、辛辣、刺激性食物,多喝水,多吃易消化的食物,如米粥、面条、饼干等。

2. 休息:避免剧烈运动,保持充足的睡眠。

3. 热敷:用热水袋或毛巾敷在肚子上,可以缓解疼痛。

4. 药物:可以尝试一些非处方药,如布洛芬、阿司匹林等,但请务必在医生的指导下使用。

如果疼痛持续或加重,或者伴随有其他症状,建议尽快就医。

希望我的回答对您有所帮助。如果您还有其他问题,欢迎随时向我提问。 
"""

Citation

If you find our work helpful, feel free to give us a cite.

@article{AquilaMed,
  title={AquilaMed Technical Report},
  year={2024}
}