Downloads · 30 days
8
9% of all-time downloads
DUTIR-BioNLP/RexDrug-adapter
RexDrug-adapter is a text generation model from DUTIR-BioNLP. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as llama3.1.
This is the LoRA adapter for RexDrug, trained via GRPO (Group Relative Policy Optimization) on top of RexDrug-base for biomedical drug combination relation extraction with chain-of-thought reasoning.
Downloads · 30 days
8
9% of all-time downloads
All-time downloads
90
Public
Repo size
2 GB
Likes
0
Public
Click a slice to open those files.
.pt1.3 GB · 66%
From the Hugging Face model README
This is the LoRA adapter for RexDrug, trained via GRPO (Group Relative Policy Optimization) on top of RexDrug-base for biomedical drug combination relation extraction with chain-of-thought reasoning.
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
# 1. Load model
tokenizer = AutoTokenizer.from_pretrained("DUTIR-BioNLP/RexDrug-base", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
"dlutIR/RexDrug-base",
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
model = PeftModel.from_pretrained(model, "DUTIR-BioNLP/RexDrug-adapter")
model.eval()
# 2. Prepare input
messages = [
{"role": "system", "content": "You are an expert in biomedical drug-drug relation extraction. ..."},
{"role": "user", "content": "Target sentence: ... \nContext paragraph: ..."},
]
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
# 3. Generate
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=1024, do_sample=False)
response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True)
print(response)
See the full example in the GitHub repository.
This model is built upon Llama 3.1 and is subject to the Llama 3.1 Community License Agreement.