Downloads · 30 days
0
BJyotibrat/Llama-3-8B-Instruct-BotMed-v1-adapter
Llama-3-8B-Instruct-BotMed-v1-adapter is a question answering model from BJyotibrat. Use it when the input is a question plus a passage. It is set up for transformers. The card lists the license as llama3.
BotMed-v1-adapter is the LoRA adapter weights for a fine-tuned version of Llama 3 8B Instruct, adapted for medical chatbot use cases. This repository contains only the adapter weights, not the merged model — see Llama…
Downloads · 30 days
0
Access
Public
Updated Aug 8, 2026
Repo size
43.4 MB
Likes
1
Public
Click a slice to open those files.
.safetensors26.2 MB · 60%
From the Hugging Face model README
BotMed-v1-adapter is the LoRA adapter weights for a fine-tuned version of Llama 3 8B Instruct, adapted for medical chatbot use cases. This repository contains only the adapter weights, not the merged model — see Llama-3-8B-Instruct-BotMed-v1 for the full merged model.
BotMed-v1-adapter contains the LoRA (Low-Rank Adaptation) adapter weights fine-tuned on top of Meta's Llama 3 8B Instruct, specialized for medical chatbot and question-answering use cases. It was trained on the ruslanmv/ai-medical-chatbot dataset, with the base model loaded in 4-bit NF4 quantization to enable efficient fine-tuning on Kaggle GPUs.
The LoRA adapters (rank 8, alpha 16) target the attention and MLP projection layers (q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj), allowing the model to adapt to medical dialogue patterns while preserving the general instruction-following capabilities of the base Llama 3 model. Training was run for 2 configured epochs with early stopping, using a cosine learning rate schedule and the paged AdamW 8-bit optimizer.
This adapter is the LoRA-only counterpart of Llama-3-8B-Instruct-BotMed-v1, released as a lightweight alternative for anyone who wants to apply the fine-tune on top of the official base model themselves rather than downloading the full merged weights. It is not a certified diagnostic tool and should not be used as a substitute for professional medical advice.
Intended to be loaded on top of meta-llama/Meta-Llama-3-8B-Instruct via PEFT for medical chatbot / medical question-answering conversational use cases.
As the adapter-only counterpart of the first fine-tuning run in the BotMed project, this repo is best suited to exploratory and internal downstream uses rather than production deployment. Potential applications include:
(1) lightweight distribution — applying the fine-tune on top of the base model without redownloading the full ~16GB merged weights,
(2) baseline comparison, serving as a reference point against later BotMed adapter versions (e.g. v2) to evaluate the impact of changes in LoRA configuration, epochs, or dataset handling,
(3) further fine-tuning or continued LoRA training as a starting checkpoint for downstream medical NLP experiments, and
(4) merging into custom quantization/precision setups, since adapter-only repos give more flexibility over how the base model is loaded than a pre-merged model.
(Note: This adapter is built for Llama and distributed under the Llama 3 Community License. Any downstream applications, derivative models, or software integrating this adapter must comply with Meta's Acceptable Use Policy and include the required "Built with Llama" attribution.)
Given the lack of formal evaluation for this version (see Bias, Risks, and Limitations), it is not recommended for downstream use cases that reach real end-users without further validation — prefer v2 for those.
Not a certified medical diagnostic tool. Unsafe and inappropriate for end-users seeking actual medical advice, diagnosis, or treatment — a licensed human medical professional should be the only resource used for that. Not intended to be used standalone; requires the base model meta-llama/Meta-Llama-3-8B-Instruct to function. Any use must comply with the Llama 3 Acceptable Use Policy.
meta-llama/Meta-Llama-3-8B-Instruct as the base — using a different base model or precision setup than the one used in training may degrade output quality.Users (both direct and downstream) should be made aware of the risks, biases, and limitations of the model. In particular:
meta-llama/Meta-Llama-3-8B-Instruct) is loaded before applying this adapter.Use the code below to get started with the model.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
base_model_id = "meta-llama/Meta-Llama-3-8B-Instruct"
adapter_id = "BJyotibrat/Llama-3-8B-Instruct-BotMed-v1-adapter"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True,
)
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
quantization_config=bnb_config,
device_map="auto",
dtype=torch.float16,
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()
prompts = [
"I have frequent fever and pain in chest"
]
for idx, t in enumerate(prompts, start=1):
print(f"\nPrompt {idx}: {t}\n")
messages = [{"role": "user", "content": t}]
prompt = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
inputs = tokenizer(
prompt,
return_tensors="pt",
truncation=True,
max_length=2048
).to("cuda")
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=512,
do_sample=True,
temperature=0.7,
top_p=0.9,
repetition_penalty=1.2,
pad_token_id=tokenizer.eos_token_id
)
input_length = inputs["input_ids"].shape[1]
answer = tokenizer.decode(
outputs[0][input_length:],
skip_special_tokens=True,
clean_up_tokenization_spaces=False
).strip()
print(f"Answer {idx}: {answer}\n")
Fine-tuned on the ruslanmv/ai-medical-chatbot dataset.
Fine-tuned using LoRA (Low-Rank Adaptation) on Kaggle GPUs, with the base model loaded in 4-bit quantization via BitsAndBytes. This adapter is the raw output of the LoRA fine-tuning run before merging into the base model (see Llama-3-8B-Instruct-BotMed-v1 for the merged version).
Quantization (BitsAndBytes):
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True,
)
model = AutoModelForCausalLM.from_pretrained(
base_model,
quantization_config=bnb_config,
device_map="auto",
attn_implementation=attn_implementation,
dtype=torch.float16,
)
model = prepare_model_for_kbit_training(model)
LoRA Configuration:
peft_config = LoraConfig(
r=8,
lora_alpha=16,
lora_dropout=0.1,
bias="none",
task_type="CAUSAL_LM",
target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"],
)
model = get_peft_model(model, peft_config)
model.print_trainable_parameters()
save_total_limit=2)training_arguments = SFTConfig(
output_dir=new_model,
per_device_train_batch_size=2,
per_device_eval_batch_size=2,
gradient_accumulation_steps=4,
optim="paged_adamw_8bit",
num_train_epochs=2,
eval_strategy="steps",
eval_steps=200,
save_strategy="steps",
save_steps=200,
logging_steps=50,
warmup_steps=36,
learning_rate=1e-4,
lr_scheduler_type="cosine",
fp16=False,
bf16=False,
report_to="wandb",
gradient_checkpointing=True,
load_best_model_at_end=True,
metric_for_best_model="eval_loss",
greater_is_better=False,
save_total_limit=2,
)
Final logged Weights & Biases metrics (last recorded checkpoint, global step 1800):
| Metric | Value |
|---|---|
| eval/loss | 2.271549 |
| eval/entropy | 2.144395 |
| eval/mean_token_accuracy | 0.509577 |
| eval/num_tokens | 376,339 |
| eval/runtime (s) | 267.4897 |
| eval/samples_per_second | 1.869 |
| eval/steps_per_second | 0.935 |
| train/epoch | 1.515368 |
Full run history is available as a CSV export: wandb_run_history - BotMed v1.csv.
No formal held-out evaluation set has been scored for this version.
No formal evaluation metrics (F1, ROUGE, Cosine Similarity, BERTScore) have been computed for this version.
Prompt: I have frequent fever and pain in chest
Answer: Hello, I have gone through your query. From what you have mentioned, it seems that you are having a dry cough. I would suggest you to use some cough syrups like Tab Robitussin or Tab Mucodyne for 3-5 days. Also, you can use some expectorant like Tab Mucopain for 3-5 days. If you have a fever, then you can use some antipyretic like Tab Paracetamol for 3-5 days.
(Note: raw model outputs include fabricated sign-offs such as doctor names and specialties)
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
LoRA adapter (rank 8, alpha 16) for the Llama 3 8B Instruct architecture, targeting the q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, and down_proj modules, for medical chatbot dialogue generation. Trained with the base model loaded in 4-bit NF4 quantization.
Kaggle GPUs
Kaggle GPU instance(s).
🤗 Transformers, PEFT (LoRA), TRL (SFTConfig/SFTTrainer), BitsAndBytes, Weights & Biases and Kaggle.
Bindupautra Jyotibrat (BJyotibrat)
Email: [email protected]