Downloads · 30 days
6
14% of all-time downloads
ThakrePranjal/pharma-tinyllama-instruct-lora
pharma-tinyllama-instruct-lora is a machine learning model from ThakrePranjal. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft.
This is the Stage 2 instruction-tuning LoRA adapter for TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T.
Downloads · 30 days
6
14% of all-time downloads
All-time downloads
42
Public
Repo size
50.5 MB
Likes
0
Public
Click a slice to open those files.
.safetensors50.5 MB · 93%
From the Hugging Face model README
This is the Stage 2 instruction-tuning LoRA adapter for
TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T.
This adapter was trained on top of the Stage 1 domain-adapted merged model (ThakrePranjal/pharma-tinyllama-instruct-merged), following a 2-stage pipeline:
TinyLlama (base)
→ Stage 1: Domain Adaptive Pretraining [ThakrePranjal/pharma-tinyllama-domain-lora]
→ Stage 1 Merged Model
→ Stage 2: Instruction Fine-Tuning [THIS ADAPTER]
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_model_name = "TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T"
adapter_repo = "ThakrePranjal/pharma-tinyllama-instruct-lora"
base_model = AutoModelForCausalLM.from_pretrained(base_model_name)
model = PeftModel.from_pretrained(base_model, adapter_repo)
tokenizer = AutoTokenizer.from_pretrained(adapter_repo)
model.eval()
import torch
def generate(instruction, input_text="", max_new_tokens=150):
if input_text.strip():
prompt = (
f"### Instruction:\n{instruction}\n\n"
f"### Input:\n{input_text}\n\n"
f"### Response:\n"
)
else:
prompt = (
f"### Instruction:\n{instruction}\n\n"
f"### Response:\n"
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(
**inputs,
max_new_tokens=max_new_tokens,
do_sample=True,
temperature=0.7,
top_p=0.9,
repetition_penalty=1.1,
pad_token_id=tokenizer.eos_token_id,
)
return tokenizer.decode(out[0], skip_special_tokens=True)
print(generate("Explain the primary mechanism of action of metformin."))
ThakrePranjal/pharma-instruction-dataset
Trained on a small pharma corpus. Not validated for clinical or production use. Outputs must be reviewed against authoritative sources.