ulvxa/DeepSeek-R1-Distill-Qwen-7B-Lora-Thesis
06
DeepSeek-R1-7B Wellness Assistant — QLoRA Adapter
A QLoRA fine-tuned LoRA adapter for `deepseek-ai/DeepSeek-R1-Distill-Qwen-7B`, trained as part of a Bachelor's thesis on generative AI-based wellness assistance.
This adapter specialises the base model across three wellness domains:
- Pharmaceutical information — drug composition, indications, side effects, dosage, manufacturer
- Emotional support — empathetic responses, emotional validation, therapeutic dialogue
- Nutritional information — calorie and macronutrient queries based on the USDA nutrient database
Model Details
Training Details
Training Dataset
All samples were converted to the Alpaca instruction-tuning format (instruction, input, output) and shuffled before training.
Usage
Install dependencies:
pip install transformers peft bitsandbytes accelerateLoad and run inference:
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
import torch
BASE_MODEL = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B"
ADAPTER = "ulvxa/deepseek-r1-7b-wellness-assistant"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_use_double_quant=True,
)
tokenizer = AutoTokenizer.from_pretrained(ADAPTER)
base = AutoModelForCausalLM.from_pretrained(
BASE_MODEL, quantization_config=bnb_config, device_map="auto"
)
model = PeftModel.from_pretrained(base, ADAPTER)
model.eval()
def ask(instruction: str, input_text: str = "") -> str:
if input_text.strip():
prompt = (
"Below is an instruction that describes a task, paired with an input "
"that provides further context. Write a response that appropriately "
f"completes the request.\n\n### Instruction:\n{instruction}\n\n"
f"### Input:\n{input_text}\n\n### Response:\n"
)
else:
prompt = (
"Below is an instruction that describes a task. Write a response that "
f"appropriately completes the request.\n\n### Instruction:\n{instruction}"
"\n\n### Response:\n"
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(
**inputs,
max_new_tokens=256,
do_sample=False,
repetition_penalty=1.1,
pad_token_id=tokenizer.eos_token_id,
)
return tokenizer.decode(
out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True
).strip()
# Pharmaceutical
print(ask("What is Prulastin-M Tablet and what is it used for?"))
# Emotional support
print(ask("Respond empathetically to this message.", "i feel so alone lately"))
# Nutrition
print(ask("How many calories are in 100g of cooked brown rice?"))Tip — concise therapy responses
Therapy outputs can be verbose. Limit to 128 tokens for tighter replies:
out = model.generate(**inputs, max_new_tokens=128, ...)Limitations
- Not a substitute for professional advice. Medical and pharmaceutical information comes from training data and must not replace a licensed physician or pharmacist.
- Therapy verbosity. Emotional support responses tend to be long; cap
max_new_tokensif brevity matters. - Multilingual noise. Occasional Spanish or Chinese fragments may appear in emotional support responses due to multilingual noise in the therapy training split.
- Nutritional approximation. Primary calorie figures are accurate; full macronutrient profiles may drift slightly from USDA ground truth for edge cases.
- English only. The model was trained on English instruction pairs and performs best in English.
- Hallucination risk. Like all instruction-tuned LLMs, the model can generate plausible-sounding but incorrect information. Always verify medical and pharmaceutical output against authoritative sources.
Citation
@misc{aliyev2026wellness,
author = {Ulvi Aliyev},
title = {Evaluation and Implementation of a Generative AI-Based Wellness Assistant},
year = {2026},
note = {Bachelor's Thesis}
}