Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load model and tokenizer
5model_name = "TrialPanorama/LLaMA-3-8B-TP"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 torch_dtype=torch.bfloat16,
10 device_map="auto"
11)
12
13# Prepare input (a toy example)
14prompt = """Given the following clinical trial information, estimate the required sample size:
15
16[Input Information]
17
18Please provide the estimated sample size and reasoning."""
19
20# Generate response
21inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
22outputs = model.generate(
23 **inputs,
24 max_new_tokens=512,
25 temperature=0.6,
26 top_p=0.95,
27 do_sample=True
28)
29
30response = tokenizer.decode(outputs[0], skip_special_tokens=True)
31print(response)1from vllm import LLM, SamplingParams
2
3# Initialize vLLM
4llm = LLM(
5 model="TrialPanorama/LLaMA-3-8B-TP",
6 tensor_parallel_size=1,
7 dtype="bfloat16"
8)
9
10# Set sampling parameters
11sampling_params = SamplingParams(
12 temperature=0.6,
13 top_p=0.95,
14 max_tokens=512
15)
16
17# Generate
18prompts = ["Your sample size estimation prompt here"]
19outputs = llm.generate(prompts, sampling_params)
20
21for output in outputs:
22 print(output.outputs[0].text)1@article{wang2025trialpanorama,
2 title = {Developing Large Language Models for Clinical Research Using One Million Clinical Trials},
3 author = {Wang, Zifeng and Lin, Jiacheng and Jin, Qiao and Gao, Junyi and Pradeepkumar, Jathurshan and Jiang, Pengcheng and Lu, Zhiyong and Sun, Jimeng},
4 journal = {arXiv preprint arXiv:2505.16097},
5 year = {2025},
6 url = {https://arxiv.org/abs/2505.16097}
7}