Fine-tuned vision–language models for
Visual Question Answering (VQA) in
gastrointestinal (GI) endoscopy, trained on the
Kvasir-VQA-x1 benchmark.
Traditional n-gram metrics (BLEU, ROUGE) fail to capture clinical correctness, so these models are evaluated using an LLM-based structured adjudicator (Qwen/Qwen3-30B-A3B). Each model prediction is graded per clinical aspect (polyp_type, instrument_presence, etc.) with binary scores and textual justifications:
1{
2 "eval_json": {
3 "polyp_type": {"score": 1, "reason": "Model correctly identified a sessile polyp."},
4 "instrument_presence": {"score": 0, "reason": "Failed to mention visible biopsy forceps."}
5 }
6}
This yields fine-grained, reproducible category-wise accuracy metrics reflecting true clinical reasoning performance. See details in the paper.
1!pip install ms-swift==3.8.0 bitsandbytes qwen_vl_utils==0.0.11
2
3import torch
4from swift.llm import PtEngine, RequestConfig, InferRequest
5from transformers import BitsAndBytesConfig
6
7bnb_config = BitsAndBytesConfig(
8 load_in_4bit=True,
9 bnb_4bit_quant_type="nf4",
10 bnb_4bit_use_double_quant=True,
11 bnb_4bit_compute_dtype=torch.float16
12)
13
14engine = PtEngine(
15 adapters=["SimulaMet/Qwen2.5-VL-KvasirVQA-x1-ft"], # or use other fine-tuned model IDs
16 model_id_or_path="Qwen/Qwen2.5-VL-7B-Instruct", # or use other base model IDs
17 quantization_config=bnb_config,
18 attn_impl="sdpa",
19 use_hf=True,
20)
21
22req_cfg = RequestConfig(max_tokens=512, temperature=0.3, top_k=20, top_p=0.7, repetition_penalty=1.05)
23
24infer_requests = [
25 InferRequest(messages=[{
26 "role": "user",
27 "content": [
28 {"type": "image", "image": "https://huggingface.co/datasets/SimulaMet/Kvasir-VQA-x1/resolve/main/images/clb0kvxvm90y4074yf50vf5nq.jpg"},
29 {"type": "text", "text": "What is shown in the image?"}
30 ],
31 }])
32]
33
34resp = engine.infer(infer_requests, req_cfg)
35print(resp[0].choices[0].message.content)
👉 See detailed examples in the
Colab usage notebook.
See base model-specific LICENSEs.
1@incollection{Gautam2025Oct,
2 author = {Gautam, Sushant and Riegler, Michael and Halvorsen, P{\aa}l},
3 title = {{Kvasir-VQA-x1:A Multimodal Dataset for Medical Reasoning and Robust MedVQA in Gastrointestinal Endoscopy}},
4 booktitle = {{Data Engineering in Medical Imaging}},
5 journal = {SpringerLink},
6 pages = {53--63},
7 year = {2025},
8 month = oct,
9 isbn = {978-3-032-08009-7},
10 publisher = {Springer},
11 address = {Cham, Switzerland},
12 doi = {10.1007/978-3-032-08009-7_6}
13}