Views
No views yet
1from vllm import LLM, SamplingParams
2
3prompt_input = (
4 '### Instruction:\n{instruction}\n\n### Input:\n{input}\n\n### Response:'
5)
6
7examples = [
8 {
9 "instruction": "You're a doctor, kindly address the medical queries according to the patient's account. Answer the question.",
10 "input": "What is the mechanism of action of antibiotics?"
11 },
12 {
13 "instruction": "You're a doctor, kindly address the medical queries according to the patient's account. Answer the question.",
14 "input": "How do statins work to lower cholesterol levels?"
15 },
16 {
17 "instruction": "You're a doctor, kindly address the medical queries according to the patient's account. Answer the question.",
18 "input": "Tell me about Paracetamol"
19 }
20]
21
22prompt_batch = [prompt_input.format_map(example) for example in examples]
23
24sampling_params = SamplingParams(temperature=0.8, max_tokens=512)
25
26llm = LLM(model="disi-unibo-nlp/pmc-llama-13b-awq", quantization="awq", dtype="half")
27
28outputs = llm.generate(prompt_batch, sampling_params)
29
30# Print the outputs.
31for output in outputs:
32 prompt = output.prompt
33 generated_text = output.outputs[0].text
34 print(f"Prompt: {prompt}")
35 print(generated_text)