linjc16
commited on
Commit
·
c4fbb63
1
Parent(s):
bac03df
Update README.md with model details and usage instructions
Browse files
README.md
CHANGED
|
@@ -1,3 +1,104 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: meta-llama/Meta-Llama-3-8B
|
| 4 |
+
tags:
|
| 5 |
+
- trialpanorama
|
| 6 |
+
- clinical-trials
|
| 7 |
+
- sample-size-estimation
|
| 8 |
+
- rlvr
|
| 9 |
+
- reinforcement-learning
|
| 10 |
+
- llama-3
|
| 11 |
+
language:
|
| 12 |
+
- en
|
| 13 |
+
pipeline_tag: text-generation
|
| 14 |
---
|
| 15 |
+
|
| 16 |
+
# LLaMA-3-8B-TP
|
| 17 |
+
|
| 18 |
+
This model is fine-tuned from [Meta-Llama-3-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct) by using [TrialPanorama dataset](https://huggingface.co/datasets/TrialPanorama/Dataset) for clinical trials.
|
| 19 |
+
|
| 20 |
+
## Model Details
|
| 21 |
+
|
| 22 |
+
- **Base Model**: Meta-Llama-3-8B-Instruct
|
| 23 |
+
- **Fine-tuning Method**: Two-stage training
|
| 24 |
+
- Stage 1: Supervised Fine-Tuning (SFT) for knowledge injection
|
| 25 |
+
- Stage 2: RLVR (Reinforcement Learning with Verifiable Reward)
|
| 26 |
+
|
| 27 |
+
## Usage
|
| 28 |
+
|
| 29 |
+
### Basic Usage with Transformers
|
| 30 |
+
|
| 31 |
+
```python
|
| 32 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 33 |
+
import torch
|
| 34 |
+
|
| 35 |
+
# Load model and tokenizer
|
| 36 |
+
model_name = "TrialPanorama/LLaMA-3-8B-TP"
|
| 37 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 38 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 39 |
+
model_name,
|
| 40 |
+
torch_dtype=torch.bfloat16,
|
| 41 |
+
device_map="auto"
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
# Prepare input (a toy example)
|
| 45 |
+
prompt = """Given the following clinical trial information, estimate the required sample size:
|
| 46 |
+
|
| 47 |
+
[Input Information]
|
| 48 |
+
|
| 49 |
+
Please provide the estimated sample size and reasoning."""
|
| 50 |
+
|
| 51 |
+
# Generate response
|
| 52 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 53 |
+
outputs = model.generate(
|
| 54 |
+
**inputs,
|
| 55 |
+
max_new_tokens=512,
|
| 56 |
+
temperature=0.6,
|
| 57 |
+
top_p=0.95,
|
| 58 |
+
do_sample=True
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 62 |
+
print(response)
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
### Usage with vLLM (Recommended for Production)
|
| 66 |
+
|
| 67 |
+
```python
|
| 68 |
+
from vllm import LLM, SamplingParams
|
| 69 |
+
|
| 70 |
+
# Initialize vLLM
|
| 71 |
+
llm = LLM(
|
| 72 |
+
model="TrialPanorama/LLaMA-3-8B-TP",
|
| 73 |
+
tensor_parallel_size=1,
|
| 74 |
+
dtype="bfloat16"
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
# Set sampling parameters
|
| 78 |
+
sampling_params = SamplingParams(
|
| 79 |
+
temperature=0.6,
|
| 80 |
+
top_p=0.95,
|
| 81 |
+
max_tokens=512
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
# Generate
|
| 85 |
+
prompts = ["Your sample size estimation prompt here"]
|
| 86 |
+
outputs = llm.generate(prompts, sampling_params)
|
| 87 |
+
|
| 88 |
+
for output in outputs:
|
| 89 |
+
print(output.outputs[0].text)
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
## Citation
|
| 93 |
+
|
| 94 |
+
If you use this model in your research, please cite:
|
| 95 |
+
|
| 96 |
+
```bibtex
|
| 97 |
+
@article{wang2025trialpanorama,
|
| 98 |
+
title = {Developing Large Language Models for Clinical Research Using One Million Clinical Trials},
|
| 99 |
+
author = {Wang, Zifeng and Lin, Jiacheng and Jin, Qiao and Gao, Junyi and Pradeepkumar, Jathurshan and Jiang, Pengcheng and Lu, Zhiyong and Sun, Jimeng},
|
| 100 |
+
journal = {arXiv preprint arXiv:2505.16097},
|
| 101 |
+
year = {2025},
|
| 102 |
+
url = {https://arxiv.org/abs/2505.16097}
|
| 103 |
+
}
|
| 104 |
+
```
|