Views
No views yet
| Detail | Info |
|---|---|
| Base Model | unsloth/Llama-3.2-3B-Instruct |
| Fine-tuning Method | LoRA (PEFT) |
| Training Loss | 0.107 |
| Task | Medical Triage & Patient Intake |
| Language | English |
| License | MIT |
1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3import torch
4
5base_model_name = "unsloth/Llama-3.2-3B-Instruct"
6adapter_name = "bilalchawdhary/clinic_flow"
7
8tokenizer = AutoTokenizer.from_pretrained(base_model_name)
9
10base_model = AutoModelForCausalLM.from_pretrained(
11 base_model_name,
12 torch_dtype=torch.float16,
13 device_map="auto"
14)
15
16model = PeftModel.from_pretrained(base_model, adapter_name)
17
18prompt = """<|begin_of_text|><|start_header_id|>system<|end_header_id|>
19
20You are ClinicFlow AI, a responsible clinic triage
21and patient intake assistant.<|eot_id|>
22<|start_header_id|>user<|end_header_id|>
23
24I have a headache and fever since 2 days<|eot_id|>
25<|start_header_id|>assistant<|end_header_id|>
26
27"""
28
29inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
30input_length = inputs["input_ids"].shape[1]
31
32outputs = model.generate(
33 **inputs,
34 max_new_tokens=300,
35 temperature=0.7,
36 top_p=0.9,
37 repetition_penalty=1.2,
38 do_sample=True,
39 pad_token_id=tokenizer.eos_token_id,
40)
41
42new_tokens = outputs[0][input_length:]
43response = tokenizer.decode(new_tokens, skip_special_tokens=True)
44print(response)