Views
No views yet
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 + "."| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| No log | 0.25 | 51 | 1.2418 |
| 1.3267 | 0.5 | 102 | 1.1900 |
| 1.3267 | 0.75 | 153 | 1.1348 |
| 1.1237 | 0.99 | 204 | 1.0887 |
| 1.1237 | 1.24 | 255 | 1.1018 |
| 0.7527 | 1.49 | 306 | 1.0770 |
| 0.7527 | 1.74 | 357 | 1.0464 |
| 0.7281 | 1.99 | 408 | 1.0233 |
| 0.7281 | 2.24 | 459 | 1.1212 |
| 0.4262 | 2.49 | 510 | 1.1177 |
| 0.4262 | 2.73 | 561 | 1.1125 |
| 0.4124 | 2.98 | 612 | 1.1114 |