Qwen3-4B Back-Pain Coaching (LoRA fine-tune)

A LoRA fine-tune of Qwen/Qwen3-4B-Instruct-2507, specialized for back-pain coaching conversations: it asks structured intake questions, screens for red-flag symptoms, and otherwise suggests general exercises, stretches, and lifestyle/diet guidance.

This is not a diagnostic tool and is not a substitute for professional medical advice.

Intended use

  • General exercise, stretch, and lifestyle/diet suggestions for common, non-red-flag back pain
  • Structured intake before any recommendation: pain location, duration, and what aggravates or relieves it
  • Recognizing red-flag symptoms (groin/inner-thigh numbness, loss of bowel or bladder control, fever, unexplained weight loss, recent significant trauma, progressive leg weakness) and directing the user to urgent care instead of answering the question itself

Not intended for

  • Diagnosing any medical condition
  • Prescribing specific diets, supplements, or dosages
  • Emergency medical guidance, or as the sole safety mechanism in a deployed system

This model was trained and evaluated alongside an independent, rules-based red-flag safety check (inference/safety.py in the project repo below) that runs before the model is ever called and does not depend on model behavior. Deploying this model without an equivalent independent safety layer is not the intended or recommended use.

Files in this repo

  • adapter_config.json + adapters.safetensors โ€” the trained LoRA adapter (29MB), applied on top of the base model at load time (MLX) or used to fuse/convert to another format
  • qwen3-4b-instruct-2507-backpain-f16.gguf โ€” full-precision GGUF (~8GB)
  • qwen3-4b-instruct-2507-backpain-q4_k_m.gguf โ€” quantized GGUF (~2.5GB), the one this project actually serves via llama-cpp-python

No full fused HF-transformers-format safetensors checkpoint is hosted here โ€” the adapter was fused directly into an MLX checkpoint and converted straight to GGUF, skipping an intermediate HF-format export.

hf download ameowra/qwen3-4b-backpain-fused \
  qwen3-4b-instruct-2507-backpain-q4_k_m.gguf --local-dir models/

Training

  • Base model: Qwen/Qwen3-4B-Instruct-2507
  • Method: LoRA fine-tuning via mlx_lm.lora (MLX, Apple Silicon) โ€” rank 8, dropout 0.0, scale 20.0, 16 of 36 layers tuned (7.34M / 4022M trainable params, 0.182%); adam optimizer, lr 1e-5 constant, batch size 4, max sequence length 2048; fused into the base weights and converted to GGUF via llama.cpp
  • Data: 136 hand-authored chat-format examples (110 train / 26 valid, ~27,470 tokens/epoch) across 6 categories โ€” structured intake, exercise/stretch recommendation, diet/lifestyle guidance, red-flag referral, medical-term explanation, and back-muscle anatomy โ€” grounded in real sources (Mayo Clinic, NHS Inform, Kaiser, Arthritis UK, Spine Health's glossary, NCBI StatPearls, TeachMeAnatomy) collected via Firecrawl and paraphrased rather than copied verbatim
  • Checkpoint selection: trained for 430 of a nominal 1000 iterations on an Apple M5 Max (~1.7 it/s, ~6 minutes wall clock); validation loss bottomed out at iteration 100 (0.441) and rose steadily after while train loss kept falling โ€” plain overfitting on a small dataset, so iteration 100 was selected rather than the final checkpoint. At this dataset size, ~100-150 iterations is the useful range; a longer run needs more data, not more patience.

System prompt

This model was fine-tuned against a fixed system prompt and expects to be served with it verbatim (see inference/config.yaml in the project repo):

You are a back-pain coaching assistant based in Australia but you have
globally sourced knowledge. Ask about pain location, duration, and what
aggravates or relieves it before recommending anything. Screen for
red-flag symptoms (numbness in the groin/inner thighs, loss of bowel or
bladder control, fever, unexplained weight loss, recent significant
trauma, progressive leg weakness) and tell the user to call 000 and seek
medical care immediately if any are present. Otherwise, suggest general
exercises, stretches, and lifestyle/diet guidance only. Avoid diagnosing
a condition, never prescribe a specific diet or supplement dosage, and
always recommend seeing a doctor or physiotherapist for anything beyond
general advice.

Limitations

  • Small base model (4B parameters) and a small fine-tuning set (136 examples) โ€” expect narrower conversational range than a frontier model
  • Style transfer more than knowledge transfer: the adapter mainly changes how the model responds (ask first, screen, defer, stay non-prescriptive) rather than adding back-pain knowledge the base model lacked
  • Single-turn training data โ€” multi-turn conversations work if prior turns are replayed as history, but every training example was one user turn and one reply
  • English only
  • "Call 000" guidance is Australia-specific; adapt for other regions
  • General lifestyle advice only, not personalized clinical guidance

Usage

Recommended: run via the project's own inference server, which wires in the independent red-flag safety check ahead of every model call:

git clone https://gitlab.com/assignments6633205/mai602/chatbot.git
cd chatbot
uv sync --extra inference
uv run inference/serve.py

Direct usage via MLX, applying the adapter on top of the base model:

from mlx_lm import load, generate
from mlx_lm.sample_utils import make_sampler

model, tokenizer = load(
    "Qwen/Qwen3-4B-Instruct-2507",
    adapter_path="path/to/downloaded/adapter_config.json's directory",
)

messages = [
    {"role": "system", "content": "<see System prompt section above>"},
    {"role": "user", "content": "My lower back has been aching for about a week."},
]
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
print(generate(model, tokenizer, prompt=prompt, max_tokens=512,
               sampler=make_sampler(temp=0.7, top_p=0.9)))

There is no full fused HF-transformers-format checkpoint hosted in this repo (see "Files in this repo" above) โ€” direct transformers usage would require fusing the adapter into the base weights yourself first (e.g. via mlx_lm.fuse then a HF-format export), or using one of the GGUF builds via llama.cpp/llama-cpp-python as shown above, which is what this project's own inference server actually does. See the project repo for the full training-to-serving pipeline and the ProjectScope.md design rationale (structured intake, hardcoded safety layer, planned RAG grounding, fully local/offline deployment).

Downloads last month
28
GGUF
Model size
4B params
Architecture
qwen3
Hardware compatibility
Log In to add your hardware

4-bit

16-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for ameowra/qwen3-4b-backpain-fused

Adapter
(5661)
this model