This model is a fine-tuned version of
microsoft/BioGPT-Large on a formatted version of the MedQuad-MedicalQnADataset dataset.
It achieves the following results on the evaluation set:
The base model used is Microsoft's BioGPT, it was fine-tuned with a custom prompt for a conversational chatbot between a patient and a doctor.
The prompt used is as follows:
1"""You are a Doctor. Below is a question from a patient. Write a response to the patient that answers their question\n\n"
2
3### Patient: {question}"
4
5### Doctor: {answer}
6"""
1model_config = GenerationConfig.from_pretrained(
2 DoctorGPT
3)
1diversebeamConfig = GenerationConfig(
2 min_length=20,
3 max_length=256,
4 do_sample=False,
5 num_beams=4,
6 num_beam_groups=4,
7 diversity_penalty=1.0,
8 repetition_penalty=3.0,
9 eos_token_id=model.config.eos_token_id,
10 pad_token_id=model.config.pad_token_id,
11 bos_token_id=model.config.bos_token_id,
12)
1def generate(query):
2 sys = "You are a Doctor. Below is a question from a patient. Write a response to the patient that answers their question\n\n"
3 patient = f"### Patient:\n{query}\n\n"
4 doctor = f"### Doctor:\n "
5
6 prompt = sys+patient+doctor
7
8 inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
9 generated_ids = model.generate(
10 **inputs,
11 generation_config=generation_config,
12 )
13 outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
14 answer = '.'.join(answer.split('.')[:-1])
15 torch.cuda.empty_cache()
16 return answer + "."
This is a private project for fine-tuning a medical language model, it is not intended to be used as a source of medical advice.