CoolFace
Modelpublic

mikaelkanzaki/tech3-v3

sourceHugging Faceapache-2.0updated 18d agoView on Hugging Face
0likes40downloads
Model Card

tech3-v3

tech3-v3 is an experimental LoRA adapter created for an academic study of supervised fine-tuning and retrieval-augmented generation (RAG) using medical question-answer data.

Evaluation status: REJECTED for clinical or production use. This artifact is intentionally published to document the experiment, including its unsuccessful validation outcome. It must not be used for diagnosis, treatment, medication decisions, emergencies, or other medical guidance.

Model details

Intended use

This adapter is shared for:

  • —studying a small supervised fine-tuning experiment;
  • —comparing a base model with a fine-tuned adapter;
  • —reproducing evaluation and failure analysis;
  • —exploring how fine-tuning and RAG play different roles in a medical-information assistant.

It is not intended for clinical deployment or unsupervised end-user use. Any research use should preserve the warnings and independently validate the outputs.

Training data

The source is MedQuAD, a medical question-answer collection created from NIH websites and published under CC BY 4.0. Please cite the original dataset authors:

Asma Ben Abacha and Dina Demner-Fushman. "A Question-Entailment Approach to Question Answering." BMC Bioinformatics, 2019.

The project produced document-aware train, validation, and test splits. The candidate-v3 smoke run selected records deterministically and balanced them across nine answer-bearing MedQuAD source groups:

  • —1,000 training examples selected from 12,444 available records;
  • —200 validation examples selected from 1,457 available records;
  • —the test split was not used for this candidate decision.

The system instruction used during SFT was:

You are a medical information assistant. Answer only the question asked with concise educational information grounded in reliable medical sources. If reliable information is unavailable, say that it is unknown instead of inventing details. Do not prescribe medication, diagnose a patient, or replace a qualified healthcare professional.

Training procedure

SettingValue
MethodSupervised fine-tuning with LoRA
LoRA rank / alpha16 / 16
LoRA dropout0.0
Target modulesq_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
Maximum sequence length2,048 tokens
Precision4-bit base loading with BF16 support
OptimizerAdamW 8-bit
Learning rate0.0002
Effective batch size8 through gradient accumulation
Steps50
Seed3407
Training loss1.4417
Validation loss1.3688

The run used one NVIDIA GeForce RTX 5060 Ti with approximately 16 GiB VRAM. Training runtime was about 513 seconds. Carbon emissions were not measured.

Evaluation

The base model and adapter were compared on the same 20 validation questions. Generation used temperature 0.7, top-p 0.8, top-k 20, repetition penalty 1.1, and deterministic per-record seeds.

Automatic metrics

MetricBaseFine-tuned
Empty answers00
Mean reference token F10.27410.3066
Mean latency in seconds14.258813.7565
Per-record token-F1 wins713

Token overlap was treated only as an auxiliary metric. It did not predict the human preference outcome.

Manual review

The review was non-blinded, non-clinical, AI-assisted, and limited to 20 validation examples. Scores ranged from 0 to 2.

CriterionBaseFine-tuned
Mean correctness1.251.05
Mean completeness1.501.60
Mean safety1.301.05
Preferred answers107

There were three ties, eight safety regressions, and one severe safety regression. The project quality gate rejected this candidate because the fine-tuned model was not preferred more often and showed a severe safety regression.

Known limitations

  • —The adapter sometimes invents prevalence estimates, causes, genes, symptoms, or treatments not supported by the reference.
  • —Rare-disease questions were particularly vulnerable to unsupported details.
  • —Some generations reached the configured 256-new-token limit and ended mid-sentence.
  • —Repetition was reduced compared with an earlier candidate, but structured repetition still occurred.
  • —This was a 50-step smoke experiment using 1,000 selected training examples, not a full training run.
  • —The evaluation sample was small and was not reviewed by a qualified healthcare professional.
  • —MedQuAD reference answers can contain source-specific wording, duplicated passages, and information that may become outdated.
  • —The adapter has no retrieval mechanism and cannot verify facts against current sources. A separate RAG layer is required for grounded answers and citations.

Loading the adapter

python
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

base_id = "Qwen/Qwen3-4B-Instruct-2507"
adapter_id = "mikaelkanzaki/tech3-v3"
base_revision = "f5d253c7173262c9fbfd68aee1eda21bdc375fb5"

tokenizer = AutoTokenizer.from_pretrained(adapter_id)
base_model = AutoModelForCausalLM.from_pretrained(
    base_id,
    revision=base_revision,
    torch_dtype="auto",
    device_map="auto",
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()

messages = [
    {
        "role": "system",
        "content": (
            "You are a medical information assistant. Answer only the question "
            "asked with concise educational information grounded in reliable medical "
            "sources. If reliable information is unavailable, say that it is unknown "
            "instead of inventing details. Do not prescribe medication, diagnose a "
            "patient, or replace a qualified healthcare professional."
        ),
    },
    {"role": "user", "content": "What is heart failure?"},
]

text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)

with torch.inference_mode():
    output = model.generate(
        **inputs,
        max_new_tokens=256,
        do_sample=True,
        temperature=0.7,
        top_p=0.8,
        top_k=20,
        repetition_penalty=1.1,
    )

answer = tokenizer.decode(
    output[0][inputs["input_ids"].shape[-1]:],
    skip_special_tokens=True,
)
print(answer)

Outputs can be factually wrong even when they sound confident. Do not present them as medical advice.

Reproducibility files

The Hub repository includes the training and model manifests plus the summarized validation decision. The complete project pipeline and tests are maintained in the tech-fine-tuning repository.