Views
No views yet
1from vllm import LLM, SamplingParams
2
3# Initialize the model
4llm = LLM(
5 model="YOUR_USERNAME/medgemma-27b-it-fp8-static",
6 tensor_parallel_size=1, # Adjust based on your GPU setup
7 quantization="fp8"
8)
9
10# Set sampling parameters
11sampling_params = SamplingParams(
12 temperature=0.7,
13 top_p=0.95,
14 max_tokens=512
15)
16
17# Run inference
18prompts = ["Explain the symptoms of diabetes mellitus."]
19outputs = llm.generate(prompts, sampling_params)
20
21for output in outputs:
22 print(output.outputs[0].text)1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model = AutoModelForCausalLM.from_pretrained(
5 "YOUR_USERNAME/medgemma-27b-it-fp8-static",
6 device_map="auto",
7 torch_dtype=torch.float16,
8 trust_remote_code=True
9)
10tokenizer = AutoTokenizer.from_pretrained("YOUR_USERNAME/medgemma-27b-it-fp8-static")
11
12# Generate text
13input_text = "What are the treatment options for hypertension?"
14inputs = tokenizer(input_text, return_tensors="pt")
15outputs = model.generate(**inputs, max_length=200)
16print(tokenizer.decode(outputs[0]))1@article{medgemma2024,
2 title={MedGemma: Medical AI Models from Google DeepMind},
3 author={Google DeepMind Team},
4 year={2024}
5}