[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-116531":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":12,"openIssues":13,"contributorsCount":13,"subscribersCount":13,"size":13,"stars1d":14,"stars7d":15,"stars30d":15,"stars90d":13,"forks30d":13,"starsTrendScore":16,"compositeScore":17,"rankGlobal":9,"rankLanguage":9,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":9,"pushedAt":23,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":13,"starSnapshotCount":13,"syncStatus":27,"lastSyncTime":28,"discoverSource":29},116531,"MedJev","zfkarl\u002FMedJev","zfkarl","MedJev: A System One Vision-Language Decision Model for Fast and Effective Medical Image Understanding",null,"Python",254,11,0,23,135,148,92.86,"MIT License",false,"main",true,[],"2026-11-14 21:49:27","2026-11-23 08:17:11","# MedJev: A System One Vision-Language Decision Model for Fast and Effective Medical Image Understanding\n\nOfficial repository for the paper *MedJev: A System One Vision-Language Decision Model for Fast and\nEffective Medical Image Understanding*.\n\nMedJev-4B reads the images, the question and all candidate answers in one prompt and returns a score\nfor every candidate in a single forward pass. It generates no token, so there is no decoding loop and\nno answer parser, and the cost of a request no longer grows with the length of a response nobody\nreads.\n\n## 🏗️ Overview\n\n\u003Cp align=\"center\">\u003Cimg src=\"figs\u002Foverview.png\" width=\"100%\">\u003C\u002Fp>\n\nMedJev-4B is built on Qwen3.5-4B with two changes and nothing else.\n\n**Language-side depth reduction.** The first 23 of the 32 language layers are kept complete, layers 24\nto 31 are deleted, and from layer 32 only the query and key projections are kept. The vision encoder,\nthe merger topology and the language forward are untouched, and every visual token the merger produces\nis kept, so a small lesion cannot be pruned away.\n\n**Residual decision head.** A candidate is scored by the pretrained query--key geometry of the\nbackbone: the decision marker supplies the query, each option marker supplies a key, and the score is\ntheir scaled dot product averaged over heads. A shared per-candidate MLP adds a residual whose output\nlayer is initialized to zero, so training starts from exactly the pretrained matching score and learns\nonly the correction.\n\n## 📊 Main Results\n\nAccuracy (%) and mean end-to-end latency (ms) on the four benchmarks, at batch size one on one H20,\nagainst 20 off-the-shelf general and medical vision-language models at the 4B to 9B scale.\n\n\u003Cp align=\"center\">\u003Cimg src=\"figs\u002Fmain_results.png\" width=\"100%\">\u003C\u002Fp>\n\n\u003Cp align=\"center\">\u003Cimg src=\"figs\u002Fteaser.png\" width=\"46%\">\u003C\u002Fp>\n\nMedJev-4B is the only model in the top-left region: more accurate than every baseline and faster than\nall but the smallest, and it improves the average accuracy of its own backbone by 7.93 points while\nanswering 6.04 times faster.\n\n## 📦 Checkpoints\n\n| Model | Backbone | Link |\n| --- | --- | --- |\n| MedJev-4B | Qwen3.5-4B | [🤗 Karl28\u002FMedJev-4B](https:\u002F\u002Fhuggingface.co\u002FKarl28\u002FMedJev-4B) |\n\n```bash\nhf download Karl28\u002FMedJev-4B --local-dir checkpoints\u002Fmedjev-4b\nbash scripts\u002Fevaluate.sh checkpoints\u002Fmedjev-4b\n```\n\nA checkpoint is a LoRA adapter plus the marker embeddings, the residual head and the three readout\nnorms, which is 25,768,961 trained parameters in total. The backbone is not redistributed, so\n`Qwen\u002FQwen3.5-4B` is downloaded at load time. `medjev.evaluate` merges the adapter before timing, so\nthe reported latency is not inflated by adapter arithmetic.\n\n## 📁 Repository Layout\n\n| Path | Content |\n| --- | --- |\n| `medjev\u002Freadout.py` | The query--key decision readout and the zero-initialized residual head |\n| `medjev\u002Fmodel.py` | Markers, depth reduction, LoRA attachment, and the model builder |\n| `medjev\u002Fdata.py` | The closed-set record format, the prompt with its markers, and the encoder |\n| `medjev\u002Fdataset.py` | Manifest reading, with images opened lazily |\n| `medjev\u002Ftrain.py` | One epoch over the pooled training split with the weighted candidate loss |\n| `medjev\u002Fevaluate.py` | One forward pass per request over the four test splits |\n| `scripts\u002Fprepare_data.py` | Builds the manifests from the four public datasets |\n| `scripts\u002Ftrain.sh`, `scripts\u002Fevaluate.sh` | Launchers that read `.env` |\n\nThe ablations, the analyses and the baselines of the paper are not part of this repository.\n\n## 🚀 Installation\n\nWe trained with Python 3.10, CUDA 12.9, PyTorch 2.10.0, Transformers 4.60.0, PEFT 0.17.1 and\nFlashAttention 2.8.3.\n\n```bash\nconda create -n medjev python=3.10 -y\nconda activate medjev\npip install torch==2.10.0 --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu129\npip install -e .\npip install flash-attn==2.8.3 --no-build-isolation\n```\n\nCopy `.env.example` to `.env` and fill in the four paths. All scripts assume the repository root as the\nworking directory.\n\n## 🗂️ Data\n\nThe four benchmarks are public. Download them into `$MEDJEV_SOURCE`, then build the manifests. Every\ncommand below was run end to end; none of the sources is gated, and none needs registration.\n\n**HAM10000.** The dermoscopy images are the training pool and the ISIC 2018 Task 3 test set is the\nlabelled test split of 1,512 images. The test archive on Dataverse is missing one image, so take the\ntest images from ISIC.\n\n```bash\ncd $MEDJEV_SOURCE\ncurl -L -o HAM10000_images_part_1.zip https:\u002F\u002Fdataverse.harvard.edu\u002Fapi\u002Faccess\u002Fdatafile\u002F3172585\ncurl -L -o HAM10000_images_part_2.zip https:\u002F\u002Fdataverse.harvard.edu\u002Fapi\u002Faccess\u002Fdatafile\u002F3172584\ncurl -L -o HAM10000_metadata.csv \"https:\u002F\u002Fdataverse.harvard.edu\u002Fapi\u002Faccess\u002Fdatafile\u002F4338392?format=original\"\ncurl -LO https:\u002F\u002Fisic-archive.s3.amazonaws.com\u002Fchallenges\u002F2018\u002FISIC2018_Task3_Test_Input.zip\ncurl -LO https:\u002F\u002Fisic-archive.s3.amazonaws.com\u002Fchallenges\u002F2018\u002FISIC2018_Task3_Test_GroundTruth.zip\nunzip -q 'HAM10000_images_part_*.zip' -d $MEDJEV_DATA\u002Fham10000\u002Fimages\nunzip -qj ISIC2018_Task3_Test_Input.zip -d $MEDJEV_DATA\u002Fham10000\u002Ftest_images\nunzip -qj ISIC2018_Task3_Test_GroundTruth.zip -d .\n```\n\n**PneumoniaMNIST.** The 224 x 224 variant lives only in the MedMNIST+ record on Zenodo, not in the\nv2.x records.\n\n```bash\ncurl -L -o $MEDJEV_SOURCE\u002Fpneumoniamnist_224.npz \\\n  \"https:\u002F\u002Fzenodo.org\u002Frecords\u002F10519652\u002Ffiles\u002Fpneumoniamnist_224.npz?download=1\"\n```\n\n**MedThinkVQA.** A case carries 2 to 47 images and MedJev reads all of them.\n\n```bash\nhf download bio-nlp-umass\u002FMedThinkVQA --repo-type dataset --local-dir $MEDJEV_SOURCE\u002Fmedthinkvqa\nunzip -q $MEDJEV_SOURCE\u002Fmedthinkvqa\u002Fimages.zip -d $MEDJEV_DATA\u002Fmedthinkvqa\n```\n\n**PMC-VQA.** Use version 2, whose test split holds the 33,430 questions the paper reports.\n\n```bash\nhf download RadGenome\u002FPMC-VQA train_2.csv test_2.csv images_2.zip \\\n  --repo-type dataset --local-dir $MEDJEV_SOURCE\u002Fpmcvqa\nunzip -q $MEDJEV_SOURCE\u002Fpmcvqa\u002Fimages_2.zip -d $MEDJEV_DATA\u002Fpmcvqa\n```\n\n**Build the manifests.**\n\n```bash\npython scripts\u002Fprepare_data.py --dataset all --source $MEDJEV_SOURCE --out $MEDJEV_DATA\npython -c \"from medjev.dataset import describe; describe('$MEDJEV_DATA')\"\n```\n\n`prepare_data.py` keeps an example only when every image of it decodes, when it offers two to seven\ncandidates, and when the reference answer binds to exactly one of them. It prints how many examples\neach filter removed. Our runs used 174,360 training and 36,286 test examples: 9,951 \u002F 1,512 for\nHAM10000, 4,698 \u002F 624 for PneumoniaMNIST, 7,307 \u002F 720 for MedThinkVQA and 152,404 \u002F 33,430 for PMC-VQA.\nThe test counts are the official splits and should reproduce exactly; the training counts can differ by\na few examples if a source has been revised since.\n\n## 🏋️ Training\n\nOne epoch over the pooled training split, one optimizer, no curriculum and no second stage. The loss is\na cross-entropy over the candidates of each example, weighted so that no benchmark dominates and,\ninside a classification benchmark, so that no diagnosis dominates. Our run used one H20 and took about\na day.\n\n```bash\nbash scripts\u002Ftrain.sh\n```\n\nThe defaults are the paper's: seed 42, one epoch, global batch size 32 for 5,449 updates, learning rate\n1e-4, weight decay 0.01, gradient clipping 1.0, LoRA rank 16 with scaling 32 on the backbone and the\nmerger, and the residual head trained at full weight with hidden width 256. Checkpoints, logs and the\nfinal model go to `$MEDJEV_WORK\u002Fruns\u002Fmedjev-4b\u002F`.\n\n## 🧪 Evaluation\n\n```bash\nbash scripts\u002Fevaluate.sh $MEDJEV_WORK\u002Fruns\u002Fmedjev-4b\u002Ffinal\n```\n\nEach request is one forward pass: no token is generated and no answer is parsed, so a prediction is a\ncandidate index and can never fail to match a candidate. The script writes one JSONL of per-example\nrecords per benchmark, with the probability of every candidate and the end-to-end latency, and a\n`summary.json` with the accuracy, the mean and median latency, and the unweighted average. Use\n`DATASETS=\"ham10000 pmcvqa\"` to score a subset.\n\nThe timed region starts when the request arrives and ends when the decision is on the CPU, so it covers\nreading and decoding the image, the processor, the host-to-device copy, the forward pass and the final\nsynchronisation. Run it on an idle GPU at batch size one to compare against the paper.\n\n## 📚 Citation\n\nComing soon.\n\n## 🙏 Acknowledgement\n\nThis work builds on [Qwen3.5](https:\u002F\u002Fhuggingface.co\u002FQwen\u002FQwen3.5-4B) and on the decision-model\ninterface introduced by [Jev](https:\u002F\u002Ftypesafe.ai\u002Fblog\u002Fintroducing-system-one-models-and-jev). The\nbenchmarks are [HAM10000](https:\u002F\u002Fdoi.org\u002F10.7910\u002FDVN\u002FDBW86T),\n[MedMNIST](https:\u002F\u002Fgithub.com\u002FMedMNIST\u002FMedMNIST),\n[MedThinkVQA](https:\u002F\u002Fgithub.com\u002Fbenluwang\u002FMedThinkVQA) and\n[PMC-VQA](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002FRadGenome\u002FPMC-VQA). We thank their authors for releasing them.\n\n## 📄 License\n\nMIT, see [LICENSE](LICENSE). The datasets keep their own licences: HAM10000 is CC BY-NC 4.0, MedMNIST is\nCC BY 4.0, MedThinkVQA is CC BY-NC-SA 4.0 and PMC-VQA is CC BY-SA.\n","MedJev 是一个面向医学影像理解的视觉-语言决策模型，专为快速、准确的多选题式临床推理设计。其核心采用单次前向传播架构：输入图像、问题及全部候选答案后，直接输出各选项的置信度分数，无需文本生成或解码循环；技术上基于 Qwen3.5-4B 进行语言侧深度裁剪与残差决策头设计，兼顾轻量低延迟（比基线快6倍）与高精度（提升7.93个百分点）。适用于放射科\u002F病理科等需实时辅助判读的闭合集医学问答场景，如影像诊断选择题评估、教学测验与自动化报告校验。",2,"2026-11-24 04:53:46","CREATED_QUERY"]