LLaVA-Med turns a general picture-chatting model into a biomedical assistant in under 15 hours on eight GPUs, by letting text-only GPT-4 write the lessons from figure captions.
Ask the same chest X-ray two questions and switch between three assistants. See who guesses like a layperson and who reads the film. Then we build, piece by piece, the data, the two training stages and the scores behind the difference.
You need a rough idea of what a neural network is (a stack of adjustable number tables) and a feel for what a chatbot does. We build the rest from zero.
Paper: LLaVA-Med: Training a Large Language-and-Vision Assistant for Biomedicine in One Day, by Chunyuan Li, Cliff Wong, Sheng Zhang, Naoto Usuyama, Haotian Liu, Jianwei Yang, Tristan Naumann, Hoifung Poon and Jianfeng Gao (Microsoft, 2023). An assigned reading for the MIT MMAI course (Multimodal AI, Spring 2026); it belongs to Lecture 14, Cross-Modal Transfer. Every idea is re-taught here in our own words and devices.
The three answers are quoted from Table 2 of the paper. The chest X-ray is a schematic drawn for this page, not the paper’s image. The bars are Table 1, the overall score on 193 questions as a percentage of the language-only GPT-4 reference, which reads the caption and the inline mentions and never sees the pixels.
Chapter 0
See why a model that chats well about holiday photos guesses wrong about a chest X-ray
A medical student is studying a case report. It shows a chest X-ray, and she wants help reading it. She uploads the picture to a popular picture-chatting assistant and types: “What is shown in this image?”
The assistant answers in a calm, helpful tone. It says the picture shows “a ribcage with wires coming out of it” and is probably “a medical illustration or diagram”. The student knows that is wrong. But a person new to medicine would not know. The tone sounds sure, and the answer is a guess.
That small scene is the whole reason for this paper. The paper is LLaVA-Med, from a Microsoft team led by Chunyuan Li, Cliff Wong and Sheng Zhang. Its name reads as “Large Language and Vision Assistant for BioMedicine”. It asks one question: can we turn a general picture-chatting assistant into a biomedical one cheaply, in a day or so, without paying doctors to write thousands of conversations?
A large multimodal model (LMM) is a language model that can also take in pictures. You give it an image and a question in words. It writes an answer in words. “Multimodal” means more than one kind of input, here pixels and text.
General LMMs learned from billions of image and caption pairs taken from the public web. Holiday photos, product shots and memes fill that web. A chest X-ray with the caption “bilateral patchy infiltrates” is rare there. The paper says biomedical pairs are “drastically different from general web content”. So the assistant behaves like a layperson: someone clever who never trained in medicine. A layperson either refuses to answer or makes something up. The paper calls the second case hallucination: fluent text that the picture does not support.
Medical visual question answering (VQA) is the task of answering a written question about a picture. Before this paper, most methods treated it as classification. The model gets a fixed list of possible answers, taken from the answers in the training set. It scores every item on the list and returns the best one. We call this a closed-set method, because the answer must come from a closed list.
Closed-set methods work well for “yes or no” and for short labels. They fail in two ways. If the right answer is not on the list, they cannot say it. And they cannot hold a conversation, because a conversation needs sentences that nobody put on a list in advance.
The other earlier route was a pipeline. The paper describes Visual Med-Alpaca, which connects several image-captioning models to a language model, with a classifier that picks which captioner to use. It was trained on 54K samples from limited biomedical subjects. LLaVA-Med differs in two ways. It is one end-to-end network. And its instruction data covers a wider set of subjects.
Try the difference yourself. Pick a question about the paper’s own example, a chest CT with a cavitating lesion (a hollow space inside a lump). See what a closed list can say, and what a writer can say.
Bars are a classifier’s scores for each item on its answer list. Green marks the right answer when it is on the list. The box shows what a generative model writes. Choose each question in turn.
The three questions and the generated answers are from the paper’s Figure 1. The seven-item answer list and its scores are illustrative, made up to show how a closed list behaves. They are not measured from any model.
The first two questions fit a list. “Right upper lobe” is on it, and so is “yes”. The third does not fit at all. A good answer is a paragraph, and the classifier must still return one of seven items. It returns the nearest wrong one. That is the gap a general-purpose biomedical assistant has to close.
The authors had no budget to hire clinicians to write conversations about figures. So they used what already exists for free. Here is the plan, and the chapter where each move is built.
First, they use PMC-15M, a public set of 15 million figures with their captions, taken from papers in PubMed Central (Chapter 2). Second, they ask text-only GPT-4 to write multi-turn conversations from the captions (Chapter 3). Third, they train in two stages, like a student who learns the vocabulary first and the conversation second (Chapters 4 and 5). Fourth, they test the result two ways: a GPT-4-graded chat test and three standard question sets (Chapters 6 and 7).
The cost figure in the title is real. The paper trains the whole model in less than 15 hours on eight A100 GPUs (an A100 is a data-centre graphics chip). Chapter 8 shows where those hours go.
Chapter 1
Follow one image through the vision encoder and the projection into the language model
Imagine you read a picture book aloud to a child who only understands spoken words. You cannot hand over the picture and hope. First you must turn what you see into words the child already knows. Then the child can think about it, answer, and ask questions back.
A picture-chatting model has the same problem. Its brain is a language model, a network trained to predict the next word piece in a text. It only understands numbers that look like word pieces. A picture is a grid of colour values. Something must translate the grid into the language of the brain. LLaVA-Med does not invent this translator. It inherits it from LLaVA, the general model it starts from, and keeps the design unchanged.
The vision encoder is the eyes. It is a network that cuts the picture into small square patches and turns each patch into a list of numbers, a feature vector, that describes what the patch contains. LLaVA uses the image encoder of CLIP, a model trained earlier on web pictures and captions. The paper also tests a biomedical encoder, BiomedCLIP, in Chapter 7.
The projection is the translator. It is one table of numbers, a matrix W. It multiplies every patch vector and produces a new vector of the right length to sit beside word pieces. This is called a linear projection because it only multiplies and adds. The paper contrasts this with an earlier medical model that used a three-layer network here.
The language model is the brain. In LLaVA-Med it is a 7B model from the LLaMA and Vicuna family (7B means seven billion adjustable numbers). It reads the translated patches and the question, and writes the answer one word piece at a time.
Step through one image below. The sizes shown assume the original LLaVA setup, a 224-pixel picture and patches 14 pixels wide, so the shapes are easy to follow.
Each row is one stage. The bracket on the right is the shape of the numbers leaving that stage. Move the slider, or press Play, to light up the path.
Illustrative shapes. The paper states only that a linear projection joins the vision encoder to a 7B language model. The numbers 224 × 224, 14-pixel patches, 1,024 features, a 4,096-wide language model and a 32,000-piece vocabulary are those of the original LLaVA with LLaMA, and the 30-token question is made up.
Let the vision encoder output a table Zv with one row per patch. The projection turns it into image tokens Hv of the same width as word embeddings.
Count the cost of W with the sizes above. It maps 1,024 numbers to 4,096, so it holds 1,024 × 4,096 = 4,194,304 weights. A 7B model holds about 7,000,000,000. The translator is therefore about 0.06% of the brain. It is small, and that matters in Chapter 4.
Training examples are short chats in a fixed text format. The paper writes the single-turn form as: Human: Xq Xv <STOP> Assistant: Xc <STOP>. Here Xq is the question, Xv is the image, and Xc is the answer to be written. The image tokens sit in the sequence like extra words.
The learning signal is the same one every language model uses. At each position of the answer, the model gives a probability to the correct next word piece. Training raises that probability. The loss is the sum of the negative logs of those probabilities, over the answer pieces only. The paper does not print this loss; it is the standard one that LLaVA uses.
A worked count. Say the question holds 30 word pieces, and the image gives 256 tokens. The language model sees 286 positions before it writes a single word. If the true answer has 20 pieces, the loss adds up 20 terms, one for each piece. The model never receives a reward for repeating the question.
The symptom is the assistant in Chapter 0, which calls a chest film “a ribcage with wires”. The measurement is Table 1: general LLaVA scores 36.1 on the biomedical chat test, where the reference is 100. The cause is a mismatch. The eyes have seen few such images, and the translator has never mapped medical patterns to medical words. The fix is two training stages, and each one trains a different part of this picture.
Chapter 2
Turn 15 million paper figures into 600,000 caption-writing exercises
Walk into any research hospital library and open a journal. Almost every paper has figures: a scan, a stained slice of tissue, a chart. Under each figure is a caption, written by the authors, who are experts. “Contrast-enhanced CT scan of the chest. A large cavitating lesion was identified in the right upper lobe.” Nobody paid a labeller to write that line. It already exists, millions of times over.
This is the free teacher the paper uses. A figure-caption pair is a picture together with the text its authors wrote about it. If a model reads enough of them, it can learn which patterns in pixels go with which medical words. That is the plain idea. The rest of the chapter is how the team turns the pile into training examples.
PubMed Central (PMC) is a public archive of biomedical papers. LLaVA-Med draws on PMC-15M, a set of figure-caption pairs pulled from it. The set was built for a companion paper, BiomedCLIP (arXiv 2303.00915), by an overlapping team. That paper reports 15,282,336 image-caption pairs, taken from the 4.4 million open-access articles available on 15 June 2022.
The builders parsed each article’s XML file, found each figure and its caption, and kept the paper’s ID for provenance. They dropped articles with no figure references or with broken XML. They report that the set is about two orders of magnitude larger than MIMIC-CXR (377,110 pairs), the biggest earlier public set, and that it spans thirty major image types. Chest X-rays, microscope slides, charts and diagrams all appear.
Two facts matter later. Half of the figures are composite, meaning several panels in one image. And the captions are long, far past the 77-token limit of the original CLIP. So a caption is often a paragraph, not a label.
A chat model trains on chats. So each pair is wrapped in a tiny conversation. The human turn holds a question Xq that asks for a description, plus the image Xv. The assistant turn is the caption Xc, as it stands. The paper writes the template like this:
one alignment exampleHuman: Xq Xv <STOP>\n Assistant: Xc <STOP>\n # Xq: a sampled "describe the image" question # Xv: the figure, as image tokens (Chapter 1) # Xc: the author's caption, used as the answer, unchanged
The question is sampled from one of two lists. One list asks for a short description. The other asks for a detailed one. The team picks the list by the caption’s length. If the caption has fewer than 30 words, the model is asked to describe the image concisely. If it has 30 or more, the question asks for detail. The paper reports that 25% of captions in PMC-15M are shorter than 30 words. The paper’s Appendix A holds the two lists. We do not copy them here.
Why pick the question by length? A short caption would be a strange answer to “describe in detail”. A long one would be a strange answer to “describe briefly”. Matching the two keeps the pair consistent, so the model is not taught that a request and an answer can disagree.
Try it with the caption from the paper’s Figure 1. Cut it to any length and watch which list the example draws from.
The top bars show how many pairs each set holds, on a log scale. Below, slide the caption length. The example shows the rule at 30 words.
Pair counts are the paper’s (15,282,336 from the BiomedCLIP paper, 600K and 60K from LLaVA-Med). The caption is the one in the paper’s Figure 1 and the length cut is mine; the two question lists are in the paper’s Appendix A, so the box shows only which list is used.
Now the numbers. The team samples 600,000 pairs out of about 15.3 million. That is 600,000 ÷ 15,282,336, or 3.9% of the pile. The paper says the choice “balances concept coverage and training efficiency”. Fewer pairs train faster, and 600K is still a large, varied sample of biomedical concepts. A separate 60K conversation set, built in Chapter 3, is only 0.39% of PMC-15M.
Follow the paper’s Figure 1 record through the pipeline. Step 1: the parser finds the figure file and its caption, about 48 words long. Step 2: the length is over 30 words, so the question comes from the detailed list. Step 3: the caption text is placed in the assistant turn. Step 4: the image is cut into 256 patches and projected into 256 image tokens (Chapter 1).
Step 5: the model reads about 256 image tokens, plus a short question, plus the answer so far. At each answer position it gives a probability to the true next word piece. A caption of 48 words is roughly 60 word pieces, so the loss adds up about 60 terms. Nothing here needs a human. The cost is only compute.
One failure shows up in this data. Many captions use the authors’ private context: “for patient #1”, “as in panel B”. Half the figures are composite, with several panels in one image, and a caption that describes panel B makes little sense for the whole picture. The symptom is a model that writes “patient #1” into answers about a stranger. The paper does not measure this, and it does not fix it in this stage. The companion BiomedCLIP paper notes the issue and builds a finer set that splits compound figures into panels, for future work.
Every example in this set has the same task: look at the image, write the caption. The paper admits this. It says the set “only presents one-single task instructions, i.e., image captioning”. Yet it holds a diverse, representative set of biomedical concepts. So it is good for one job and bad for another.
The good job is vocabulary. After training on these pairs, a patch pattern that means “lung opacity” lands near the words “lung opacity”. The bad job is conversation. A model that has only ever written captions will answer every question with a caption. The symptom shows up in Chapter 6: after this data alone, the chat score falls to 23.3, below the 36.1 of the general LLaVA it started from. The fix is the second data set, which is the next chapter.
Chapter 3
Watch a text-only model invent a clinic conversation about a picture it never sees
A teacher wants to quiz her class on a figure from a textbook, but the figure is missing from her copy. She still has the caption, and the paragraph in the chapter that says “see Figure 4”. From those two texts she writes five good questions, and the answers. She writes them as if she were looking at the picture.
That is the trick at the centre of LLaVA-Med. The picture is missing for the question writer, so the words about the picture stand in for it. The paper calls the method self-instruct: a strong model writes the instruction data that a weaker model then learns from. Here the question writer is language-only GPT-4, a version of GPT-4 that reads and writes text and never receives an image.
The paper filters PMC-15M down to figures that contain a single plot. From these it samples 60,000 pairs across the five most common imaging types: chest X-ray (CXR), computed tomography (CT), magnetic resonance imaging (MRI), histopathology (tissue under a microscope) and gross pathology (tissue seen with the naked eye).
For each pair GPT-4 receives the caption. The prompt asks it to write a multi-round conversation of questions and answers, “in a tone as if it could see the image”. The authors hand-write a few example conversations and put them in the prompt. This is few-shot prompting: showing the model the format by example rather than by rule. The full prompt is in the paper’s Appendix B. This is why the paper calls the process machine-human co-curation: the machine writes the data, and humans write the prompt and the examples.
Each finished conversation is then joined to its figure. Now the data holds triples of the form (image, instruction, output). The instruction and the output come from text alone. No person labelled a single image, and GPT-4 never looked at one.
how one example is made (paraphrased)record = {"caption": cap, "mentions": [sent1, sent2]} # from PMC-15M and the paper's text messages = [ system("Write a multi-round Q&A about a figure, as if you could see it."), *few_shot_examples, # hand-written, Appendix B user(cap + "\n" + "\n".join(mentions)), # text only, no pixels ] chat = gpt4(messages) # User/Assistant turns example = (figure_pixels, chat) # the image is attached afterwards
Some captions are short. A one-line caption gives GPT-4 too little to write a good conversation. So the team adds inline mentions: the sentences in the original paper that refer to the figure, also called citances. They give context that the caption leaves out. The authors cite earlier work showing that outside knowledge helps models generalise.
The paper’s Figure 1 shows the effect. The caption says a large cavitating lesion sits in the right upper lobe. The mention in the text adds one more fact: the lesion is in the posterior aspect of that lobe. When GPT-4 answers “Where is the lesion located?”, it says “the posterior aspect of the right upper lobe”. Without the mention, that word has no source.
Use the toggle below. For each question in the example, see where each fact in GPT-4’s answer could come from.
Pick a question. Each row is one fact in the answer GPT-4 wrote. The marker shows where the text GPT-4 read could supply it. Then switch the inline mentions off.
The caption, the two mentions and the three answers are from the paper’s Figure 1. Sorting each fact into a source is my reading of that figure, not a measurement by the authors.
The third question shows the limit. The explanation of a cavity and its causes comes from what GPT-4 already knows, not from the caption. That is useful, because it teaches the student model medical background. It is also risky, because nothing in the figure checks it.
Because GPT-4 writes from text, every answer is only as good as that text and GPT-4’s own memory. Suppose a caption says only “a mass in the right lung”. GPT-4 might write “the mass has irregular margins”, which sounds right and matches nothing the caption says. The symptom is a student model that learns to describe features in the figure’s style whether or not they are present. We cannot measure this from the paper’s tables. The paper itself lists hallucination as a remaining weakness (Chapter 8). The partial fix in the data is the inline mention, because more real text means less room to invent.
The paper’s Figure 2 charts what the finished data looks like: the verbs and nouns in the questions and the answers, and how many images and question-answer pairs fall in each of the five image types. We do not copy the counts here, since the paper gives them only in the chart. The point is that the data covers all five types, so one model has to handle chest films, slices of the body and tissue under a microscope.
The team builds three sets and compares them later. 60K-IM uses inline mentions. 60K has the same size but no mentions. 10K is a smaller set without mentions. The three let them ask two questions: does more data help, and do mentions help? Chapter 6 gives the answer in the chat score, and Chapter 8 in the benchmark scores.
Here is a first number. On the 193-question chat test, the model trained on 60K-IM scores 50.2 and the model trained on 60K scores 49.4. The mentions add 0.8 points. That is small. The paper calls the improvement “slight”. It grows larger in some benchmark settings, as Chapter 8 shows.
Chapter 4
Train only the projection so new image features land on the right medical words
A new nurse starts on a cardiac ward. In week one nobody asks her to give advice. She learns the names: which line on the monitor is the heart rhythm, what a stent looks like on a film, what each abbreviation on a chart means. She already knows how to talk and how to think. She only needs the words for the new things she sees.
Stage 1 of LLaVA-Med is that first week. The model already sees (the vision encoder) and already talks (the language model). What it lacks is a link between biomedical sights and biomedical words. The paper calls this biomedical concept feature alignment. To align two things is to make the vector for a picture pattern land near the vector for the matching word.
To freeze a part of a network is to fix its weights so training cannot change them. The paper freezes both the vision encoder and the language model in Stage 1. It trains one thing only, the projection matrix W from Chapter 1.
The data is the 600K figure-caption set from Chapter 2. For each example, the model gets the image and a “describe the image” request, and must predict the original caption. The loss is the one from Chapter 1, over the caption pieces.
One point confuses many readers. Frozen does not mean the gradient stops. The gradient is the signal that says how to change each weight to lower the loss. It flows backward from the loss, through the frozen language model, and on to W. The frozen layers pass it along unchanged and keep their own weights. Only W takes a step.
Use the device to freeze and thaw each part. See where the gradient arrows stop, and how many weights would be trained.
Pink parts are trained. Grey parts are frozen. Arrows show the gradient flowing back from the loss. The starting setting is the paper’s Stage 1. Try the other settings.
Weight counts are illustrative round numbers: about 300 million for a CLIP image encoder, 4.2 million for W (Chapter 1) and 7 billion for the language model. The paper states only which parts are frozen in each stage: Stage 1 trains the projection, Stage 2 trains the projection and the language model.
A toy step makes the update rule concrete. Suppose one weight in W is 0.50, the gradient says the loss rises by 0.8 for each unit increase in that weight, and η is 0.1. The new weight is 0.50 − 0.1 × 0.8 = 0.42. The real W holds 4.2 million such numbers, and every one takes a step like this at the same time. The numbers in this toy are made up. Only the rule is the paper’s.
What does a good W look like after training? Picture a map of word meanings, in which “opacity”, “nodule” and “effusion” each have a location. A patch of an X-ray with a cloudy lung should land near “opacity”. Before Stage 1, the translator sends it somewhere vague, and the language model reads it as “wires”. After Stage 1, it lands close to the right medical words. The paper describes this as expanding the “vocabulary of aligned image-text tokens” to the biomedical domain.
Training only W touches about 4.2 million of roughly 7.3 billion weights, or 0.06%. The optimizer needs memory for far fewer numbers. Each step is faster. And the encoder and language model keep everything they learned before. The BiomedCLIP paper warns about the opposite risk, catastrophic forgetting: a model trained further on a narrow set can lose its old skills.
The paper gives the cost. One epoch over the 600K pairs takes 6.8 hours on eight A100 GPUs at batch size 128 (the paper rounds this to 7 hours). Do the arithmetic. One epoch holds 600,000 ÷ 128 = 4,688 steps (rounded up). That is 6.8 × 3,600 = 24,480 seconds, or about 5.2 seconds per step. The paper’s Table 5 also lists three epochs at 19.4 hours. The main model uses one.
After Stage 1 the model knows more medical vocabulary. But it can only caption. It has been shown one request, “describe the image”, 600,000 times. The symptom is a model that answers every question with a caption. The measurement is Table 1: the Stage 1 model scores 23.3 on the chat test, below the 36.1 of the general LLaVA. The paper says Stage 1 alone “loses its ability to follow diverse instructions, though biomedical concept coverage is improved”. The fix is Stage 2.
Stage 1 still earns its place in the recipe. In the paper’s ablation (Table 4b), models trained with Stage 1 only and no instruction data score an average of 13.26 after one epoch and 15.14 after three. Longer Stage 1 helps there. Be careful with the claim, though. When 10K instruction conversations follow, three Stage 1 epochs give a lower average (35.45) than one (39.08). More alignment is not always better once Stage 2 comes after it.
Chapter 5
Unfreeze the language model and teach it to follow open-ended instructions
The nurse from Chapter 4 now knows the names on the ward. In week two her supervisor stops quizzing her on vocabulary. Instead, patients and junior doctors ask her open questions. “What does this shadow mean?” “Could it spread?” “Why do we need a biopsy?” She must answer in full sentences, use what she knows, and stay on topic across a whole conversation.
That is Stage 2. The paper calls it end-to-end instruction tuning. To instruction-tune a model is to train it on examples of requests paired with good answers, so it learns to follow requests it has never seen. Stage 1 gave the model words. Stage 2 gives it manners and reasoning.
In Stage 2 the vision encoder stays frozen. Everything else trains. The paper says the team “continue[s] to update both the pre-trained weights of the projection layer and LM”. So the language model finally changes. This is needed. In Stage 1 the only trainable part was the translator, and a translator cannot change how the brain writes. To answer in the style of a careful explainer, the brain itself must adapt.
The data is the 60K conversations from Chapter 3. Each one is a multi-turn chat. The image enters at the first turn. The model reads the whole history, and learns to write each assistant turn. The paper’s Figure 1 shows the turns; the exact token layout follows LLaVA. As in Chapter 1, the loss scores only the assistant’s words. The training runs for three epochs, which means three full passes over the 60K conversations.
Here is the data flow for one conversation with three turns. The question and the image are input. Only the assistant’s words are scored. Say the first user turn has 12 word pieces, the first answer 25, the second user turn 10, the second answer 30, the third user turn 9 and the third answer 130 (the long explanation of Figure 1). These lengths are made up. The model reads 256 image tokens plus all 216 text pieces. The loss counts 25 + 30 + 130 = 185 terms, and the 31 user pieces teach nothing directly. So a long, careful answer carries more of the learning signal than a short one.
Where does the failure show if you skip this? A model trained only on captions answers “Can you explain more?” with another caption. That is the symptom. Chapter 6 gives the measurement, and Stage 2 is the fix.
Compare the two stages side by side.
| Stage | Data | Trained | Passes | Hours (8 A100s) |
|---|---|---|---|---|
| 1: concept alignment | 600K captions as answers | projection W | 1 epoch | 6.8 |
| 2: instruction tuning | 60K GPT-4 conversations | W and the language model | 3 epochs | 8.0 |
The hours come from the paper’s Table 5. Add them: 6.8 + 8.0 = 14.8 hours. That is the reason for “in less than 15 hours” in the title and the abstract.
A curriculum is a teaching order, easy and basic things first. The paper says the order “broadly mimic[s] how a layperson gradually acquires biomedical knowledge”. First learn what the terms mean. Then learn to use them in a conversation. There is also a practical reason. If you thaw the whole language model on day one, while the translator is still random, the brain would receive noisy image tokens and could twist its own weights to cope. Aligning first gives it clean, meaningful inputs before it is allowed to change.
Slide through the curriculum below. Each stop is a model the paper reports in Table 1.
Each bar is a model from the paper’s Table 1. Move the slider to a stop and read the score and the clock. The yellow line is the title’s 15-hour limit.
Scores are the paper’s Table 1 (overall, relative to GPT-4 = 100). Hours are Table 5: 6.8 for one Stage 1 epoch, 1.8 for 3 epochs on 10K and 8.0 for 3 epochs on 60K. The paper lists no separate time for 60K-IM; I use the 60K time because the two sets are the same size.
Look at stop 1. Training Stage 1 alone makes the chat score fall, from 36.1 to 23.3. That is the cost of a narrow skill. Stop 2 recovers with only 10K conversations and 1.8 more hours (39.9). Stops 3 and 4 show that more conversations, and then mentions, lift the score to 49.4 and 50.2.
The paper draws three lessons from the discussion section. First, the cost is low: about 15 hours rather than a huge pretraining run. Second, the recipe is not limited to medicine. The authors argue it fits any vertical domain with new concepts, such as gaming or education, and they extend the phrase “don’t stop pretraining” from earlier work into “don’t stop instruction-tuning”. Third, a small specialist model is cheap to serve compared with a giant general one. The team also starts from LLaVA, not from a plain language model, so the behaviour “transits from layperson to professional assistant” smoothly. They note that you could start from Vicuna for the language model or from BiomedCLIP for the vision encoder, and Chapter 7 tests that.
After the two stages, an optional third step fits the model to one dataset. The paper fine-tunes on each of three medical question sets. That step belongs to Chapter 7.
Chapter 6
Read the 193-question test and the relative score that comes out of it
The chatbot is trained. Now a hard question appears: is it any good? You cannot ask a doctor to read ten thousand answers for every version of the model. And there is no list of right answers, because a good reply to “explain this lesion” can be written in many ways.
The paper solves this with a judge that never gets tired. It asks GPT-4 to grade each answer on a scale of 1 to 10. A model that grades other models is called an LLM judge. This chapter shows how the test is built, how the score is computed, and what the numbers in Table 1 do and do not tell us.
The team picks 50 image-caption pairs from PMC-15M that were not used in training. From these they make 193 new questions of two types. There are 143 conversation questions, made by the same self-instruct pipeline as the Stage 2 data. And there are 50 detailed description questions, drawn at random from a fixed set that LLaVA used, which ask for a long description of the image.
The questions also cover the five image types from Chapter 3. The paper’s Table 1 breaks down the counts: 37 chest X-ray, 38 MRI, 44 histology, 34 gross pathology and 40 CT questions. Add them: 37 + 38 + 44 + 34 + 40 = 193.
For each question, three things happen. First, language-only GPT-4 writes a reference answer. It reads the true caption and the inline mentions, so it knows more than any image model. The paper calls it the upper bound. Second, the model under test answers the same question from the image. Third, GPT-4 reads the question, the caption, the context and both answers. It rates each answer for helpfulness, relevance, accuracy and level of detail, gives an overall score from 1 to 10, and explains its choice in words.
one judged question (paraphrased)ref = gpt4_text_only(question, caption, mentions) # the upper bound cand = model(image, question) # LLaVA / LLaVA-Med variant score = gpt4_judge(question, caption, mentions, ref, cand) # -> ref_score, cand_score in 1..10, plus a written explanation relative = cand_score / ref_score # then averaged over questions, x100
The relative score divides the candidate’s score by the reference’s. If the reference earns 8 and the candidate earns 4, the candidate gets 50%. The paper says it normalises by the GPT-4 reference score, but does not spell out the exact averaging, so treat 50% as the idea, not a formula to copy. The reference itself is 100 by definition.
A worked example, with made-up numbers. Three questions get reference scores 8, 9 and 7, and a candidate scores 4, 5 and 3. The ratios are 0.50, 0.56 and 0.43. Their mean is 0.495, so the relative score is 49.5. The judge also writes an explanation for each rating. The authors read these to understand why a model scored as it did, for instance whether it gave a vague answer or a wrong one.
Table 1 has five rows: general LLaVA, the Stage 1 model, and three Stage 2 models trained on 10K, 60K and 60K-IM. It has eight columns: two question types, five image types and an overall score. Explore it below.
Pick a column. The bars are the five models’ relative scores there. Compare each bar with general LLaVA at the top.
All numbers are the paper’s Table 1, a relative score against language-only GPT-4 on the 193-question test. The counts under each label are the number of questions in that column.
Three patterns stand out. First, every Stage 2 model beats general LLaVA in every column. Second, more conversations help: going from 10K to 60K lifts the overall score from 39.9 to 49.4. Third, Stage 1 alone is below general LLaVA in every column. It comes closest on description questions, where it scores 25.2 against 26.2. That fits the story of Chapter 4: a caption-trained model can still describe a picture. The paper sums it up: the best LLaVA-Med “matches the 50.2% performance of GPT-4”. Read this carefully. It means the relative score is 50.2, half of the reference, not that it equals GPT-4 in skill.
The paper adds a worked example (its Table 2). Asked what is shown in a chest X-ray, LLaVA says it is a ribcage with wires, a medical illustration. LLaVA-Med names a chest X-ray with bilateral patchy infiltrates. The GPT-4 reference, which reads the caption, adds that the film was taken on day 2 after intubation. The hero at the top of the page lets you replay this.
The paper is open that the comparison with GPT-4 is “not a fair comparison”, since the reference reads the true caption and never has to understand the pixels. It still calls GPT-4 “a consistent and reliable evaluation tool”. Add two cautions of our own. The questions come from the same pipeline that made the training data. And the judge is the same family of model that wrote the training answers. A model trained on GPT-4’s style could earn a higher score from GPT-4 because it sounds familiar. The paper does not test for this. A clinician’s review would be a different, stronger check.
Chapter 7
Compare fine-tuned LLaVA-Med with the supervised state of the art on three datasets
The chat test of Chapter 6 is invented by the authors and graded by GPT-4. A sceptical reader wants an exam set by someone else, with an answer key. Medical visual question answering has three such exams, and the paper takes all three.
This chapter shows what the exams contain, how a free-writing model is scored on them, and where LLaVA-Med does and does not beat the methods built for that exact test.
Each dataset holds medical images with questions that a clinician wrote or checked. VQA-RAD has 315 radiology images and 3,515 question-answer pairs, spread over head, chest and abdomen. SLAKE has 642 radiology images and over 7,000 pairs (the paper uses the English half), with extra medical knowledge attached. PathVQA has 4,998 pathology images and 32,799 pairs, about microscope slides.
Table 3 of the paper gives the splits the team trains and tests on: VQA-RAD has 1,797 training and 451 test pairs, SLAKE has 4,919 and 1,061, and PathVQA has 19,755 and 6,761. Half the questions are closed, with a short fixed set of answers such as yes or no. The rest are open, with a one-word or short-phrase answer.
After Stages 1 and 2, the team fine-tunes LLaVA-Med on each dataset in turn. Fine-tuning means continuing to train a finished model on a narrow task. In this step the assistant answers every question as free text. For a closed question, the prompt lists the candidate answers. For an open question, nothing constrains the reply.
fine-tuning prompts (illustrative; the exact wording is in the paper's code)# closed question: the candidates go in the prompt Human: <image> Is there a pleural effusion? Options: yes, no Assistant: no # open question: no options, the model writes the answer Human: <image> Which organ is shown? Assistant: the liver
The three sets differ in one way that matters for fairness. In VQA-RAD the test images also appear in the training set, though the question-answer pairs do not overlap (a point made in the companion BiomedCLIP paper). In SLAKE the training and test sets share no images. A model that has seen the picture before can answer some questions by recognition. This is one more reason to read each dataset on its own, and not to average the three.
For closed questions the score is accuracy: the share of questions where the answer is right. For open questions the paper reports recall: the share of the true answer’s words that appear in the text the model wrote.
A worked example, with made-up text. The true answer is “right upper lobe”, three words. The model writes “the lesion is in the right lung”. Only “right” appears, so recall is 1 ÷ 3 = 33%. If the model had written “in the right upper lobe of the lung”, recall would be 3 ÷ 3 = 100%.
Recall has a weak spot. A long answer that mentions many words has more chances to hit the true ones, so it can earn a high score without being precise. The paper does not discuss this; it is a point to keep in mind when you read the open-set columns.
Here is a tiny scoring run, with made-up data. Ten closed questions: the model gets 8 right, so accuracy is 80%. Five open questions have true answers of 1, 2, 3, 1 and 3 words. The model’s text contains 1, 1, 1, 1 and 3 of those words. Recall for each is 1, 0.5, 0.33, 1 and 1. The mean is 0.77, so open recall is 77%. The two numbers measure different things, so they are reported in different columns.
Earlier systems were built for these datasets and, for open questions, score by picking among the answers seen in training. The paper warns that this “may overestimate their generalizability”, because these datasets are unusual: the test answers almost always appear in training. LLaVA-Med writes free text, which the paper calls “intrinsically harder”.
Choose a dataset and a question type below. The bars show LLaVA-Med’s three fine-tuned variants, general LLaVA with the same fine-tuning, and every earlier method for which the paper reports a number.
Warm bars are LLaVA-Med (three starting points). Grey bars are earlier methods. The dashed line is the best earlier number. A green mark means LLaVA-Med passes it.
Numbers are the paper’s Table 4(a): LLaVA-Med and LLaVA are the authors’ own fine-tuned runs, and earlier methods are numbers reported in the literature, so training budgets and answer formats differ. Missing bars mean the paper reports no number for that method on that dataset.
The picture is mixed, and the paper says so. On closed questions LLaVA-Med passes the earlier best on VQA-RAD (84.19 against 83.50) and on PathVQA (91.65 against 88.85). It stays behind on SLAKE, where the best earlier number is 91.10 and LLaVA-Med’s best is 86.78. On open questions it sets a new best on SLAKE, 87.11 against 84.30, and falls short on the other two. The authors blame ambiguity: open questions “can be ambiguous without constraining their expected answer options”.
The encoder swap matters little. Starting the vision side from BiomedCLIP instead of general CLIP gives slightly better results on most columns. Starting the language side from Vicuna instead of LLaVA changes things by a small amount. The recipe is stable under these choices, which is good news for a team that wants to reuse it.
Chapter 8
Find which ingredient moved the score, what it cost in hours, and where the model still fails
A cook tries a new soup. It tastes good, but she does not know why. Was it the stock, the herbs or the longer simmer? To find out, she makes the soup again and changes one thing at a time. That is an ablation: remove or vary one ingredient and measure what changes.
The paper’s Table 4(b) is a large ablation. It crosses the instruction data, the number of epochs in each stage, the language model size, the vision encoder and the number of fine-tuning epochs. It scores each model on all six benchmark columns from Chapter 7 and gives the average. This chapter reads that table, adds up the cost, and lists what the model still gets wrong.
Every row of Table 4(b) is one trained model. The “FT” column is the number of fine-tuning epochs on the three target datasets. Zero means the model is tested zero-shot: straight after Stage 2, with no training on the benchmark. The rows on this dial all use one Stage 1 epoch and three Stage 2 epochs. The full table also tries other epoch counts.
Choose an instruction set and the number of fine-tuning epochs below. A grey bar means the paper did not train that combination.
Each bar is the average of the six benchmark scores. Move the slider to change the fine-tuning epochs. Bars that are missing were not run. The dashed line is general LLaVA with no training on the benchmark (35.23).
Averages are the paper’s Table 4(b), with Stage 1 at 1 epoch and Stage 2 at 3 epochs (the no-instruction row has no Stage 2). The slider stops are the epoch counts the table lists: 0, 1, 3, 9, 15 and 18.
Start with the slider at zero. Without any benchmark training, instruction data does help a little: 39.08 for 10K, 40.72 for 60K and 41.22 for 60K-IM, against 35.23 for general LLaVA. Now drag the slider to 3 epochs. The gaps open up. The average becomes 56.19, 58.60 and 65.30 for the three sets, so more data and inline mentions both help once the model is adapted to the test.
The biggest jump is fine-tuning itself. For 60K-IM the average goes from 41.22 at zero epochs to 65.30 at three, and to 73.90 at nine. After that it flattens: 73.88 at 15 epochs and 73.22 at 18. The paper concludes that longer fine-tuning helps until about nine epochs, and that Stage 2 should run for three epochs before it.
How should you read a table like this? Compare two rows that differ in only one column. 60K against 60K-IM isolates the mentions. Zero against nine fine-tuning epochs isolates fine-tuning. Rows that differ in two ways cannot be read, because you cannot say which change moved the score. The paper’s table is built so that most useful comparisons are one-column changes. Notice also that a single column can mislead: the 10K model scores 54.79 on average after one fine-tuning epoch and 56.19 after three, yet its PathVQA open score is 25.50 and then 34.02. Averages hide such swings.
Model size has a small effect. With 60K-IM and nine fine-tuning epochs, a 13B language model averages 74.05 against 73.90 for 7B. In the zero-shot setting the table shows 40.25 for 13B and 41.22 for 7B, so the paper’s sentence that 13B improves both settings holds only for the fine-tuned one. The paper tells practitioners to weigh the quality gain against the running time.
The vision encoder has a bigger effect than the size. Swapping CLIP for BiomedCLIP, with 7B and nine epochs, lifts the average from 73.90 to 75.40. That is the best in the table. The domain-specific eyes help a little, even though the Stage 1 data was already medical.
Add the hours from Table 5. Stage 1 takes 6.8 and Stage 2 on 60K takes 8.0, a total of 14.8 hours on eight A100s. That is the headline figure. Fine-tuning is extra: three epochs take 0.6 hours on VQA-RAD, 1.0 on SLAKE and 2.5 on PathVQA, 4.1 hours for all three. Table 5 lists only one and three epochs. The best fine-tuned rows use nine or more epochs, so the true extra cost is higher, and the paper does not add it up. Even so, the whole recipe stays small beside a pretraining run.
The paper’s own conclusion names two limits: LLaVA-Med “is limited by hallucinations and weak in-depth reasoning common to many LMMs”. The symptom is a fluent answer that the picture does not support. In the paper’s own example (the hero at the top of this page), asked about implanted devices, LLaVA-Med lists several kinds of tubes and catheters that “may” be present, while the caption-reading reference names one tube. The measurement is the gap between 50.2 and 100 in Chapter 6. The paper offers no fix beyond future work on “quality and reliability”.
Other limits, from our reading. The training answers were written by a model that never saw an image. The chat test uses the same kind of data and the same judge family. The paper is marked “work in progress”, and promises to release the data and code. The model is a research tool, not a medical device.
One bright spot is a case study (Table 6). Given a Chinese question about a SLAKE scan, LLaVA-Med answers in English that it is an abdominal CT. The training data held no Chinese. The authors suggest the multilingual knowledge came from the LLaMA and Vicuna language models, which shows the language model carries skills the medical stages never touched.
Chapter 9
Keep the numbers, the checklist and the core code in one place
You can now rebuild LLaVA-Med from the page alone. The paper takes LLaVA, a picture-chatting model made of a vision encoder, a linear projection and a language model. It builds two data sets from free PubMed Central figures and captions: 600K caption exercises, and 60K conversations that text-only GPT-4 writes from captions and inline mentions. It trains in two stages, first the projection alone, then the projection and the language model. Fourteen point eight hours on eight A100s later, it matches half of GPT-4’s reference on a 193-question chat test, and with fine-tuning it beats earlier methods on some medical question sets and not on others.
| What | Number | Why it matters |
|---|---|---|
| PMC-15M | 15,282,336 pairs, from 4.4 million articles | The free source of figures and captions (BiomedCLIP paper) |
| Alignment set | 600K pairs, 3.9% of PMC-15M | Stage 1 data: caption as the answer |
| Instruction set | 60K conversations, five image types | Stage 2 data, written by text-only GPT-4 |
| Training time | 6.8 h + 8.0 h = 14.8 h, eight A100s | The “one day” of the title |
| Chat test, overall | LLaVA 36.1; Stage 1 only 23.3; 60K 49.4; 60K-IM 50.2 | Stage 1 alone hurts chat; Stage 2 repairs it |
| Closed questions | VQA-RAD 84.19 vs 83.50; PathVQA 91.65 vs 88.85 | Fine-tuned LLaVA-Med passes earlier methods |
| Open questions | SLAKE 87.11 vs 84.30; others behind | Free-text recall vs picking from a list |
| Ablation, 60K-IM average | 41.22 (no FT), 65.30 (3 epochs), 73.90 (9) | Fine-tuning moves the score most |
| BiomedCLIP encoder, 9 epochs | 75.40 vs 73.90 for CLIP | Best average in the table |
python# 1. data: free figures and captions in, two training sets out align = [(img, ask_describe(cap), cap) # Xv, Xq, Xc for img, cap in sample(PMC15M, 600_000)] # Xq list chosen by caption length: < 30 words instruct = [] for img, cap, mentions in sample(single_plot(PMC15M, five_types), 60_000): chat = gpt4_text_only(prompt(cap, mentions, few_shot)) # never sees img instruct.append((img, chat)) # 2. model: start from LLaVA (encoder, projection W, language model) enc, W, lm = load_llava_7b() # 3. stage 1: concept alignment, train W only (6.8 h) freeze(enc); freeze(lm) fit([W], align, epochs=1, batch=128) # 4. stage 2: instruction tuning, train W and the language model (8.0 h) freeze(enc) fit([W, lm], instruct, epochs=3, batch=128) # 5. optional: fine-tune on one VQA set, answers as free text fit([W, lm], vqa_train, epochs=9) # closed questions list options in the prompt def fit(params, data, epochs, batch): for x in batches(data, epochs, batch): tokens = concat(project(enc(x.img), W), embed(x.text)) # [256 + T, 4096] (illustrative) logits = lm(tokens) loss = cross_entropy(logits, x.text, only="assistant tokens") step(params, grad(loss)) # only the listed weights change
Lecture 14 of the course, Cross-Modal Transfer, is about moving what a model knows from one modality or domain to another. This recipe moves knowledge in three places. A web-trained encoder and language model carry general skill into biomedicine. Text-only GPT-4 passes its medical knowledge to an image model through captions, which act as a bridge. And English training lets the model answer a Chinese question in a case study. In each place the transfer works through a small connector (the projection) or a text stand-in (the caption).
The base model is LLaVA (visual instruction tuning, arXiv 2304.08485), and this paper applies its method to one vertical. A companion paper, BiomedCLIP (arXiv 2303.00915), built PMC-15M and the biomedical encoder. Both are from Microsoft.
Now press Present or Teach and explain, from memory, how a figure and its caption become a training example, why Stage 1 trains only the projection, and what the 50.2 does and does not mean. Then go back to the chest film at the top and ask each assistant the second question again.