Multimodal RAG (Retrieval-Augmented Generation) combines text and images or other data types to answer questions or generate content. The key metrics are Recall and F1 score. Recall is important because the model must find the right information from many sources. F1 balances recall with precision, showing how accurate and complete the answers are. For generation quality, BLEU or ROUGE scores help measure how close the output is to good answers.
Multimodal RAG in Prompt Engineering / GenAI - Model Metrics & Evaluation
Start learning this pattern below
Jump into concepts and practice - no test required
| Predicted Relevant | Predicted Irrelevant |
|--------------------|----------------------|
| True Positive (TP): 80 | False Negative (FN): 20 |
| False Positive (FP): 15 | True Negative (TN): 85 |
Total samples = 80 + 20 + 15 + 85 = 200
Precision = TP / (TP + FP) = 80 / (80 + 15) = 0.842
Recall = TP / (TP + FN) = 80 / (80 + 20) = 0.8
F1 Score = 2 * (Precision * Recall) / (Precision + Recall) ≈ 0.82
In Multimodal RAG, high recall means the model finds most relevant info, which is good for thorough answers. But this can lower precision, causing some wrong info to appear.
Example 1: A medical assistant using RAG must have high recall to not miss any important symptoms, even if some extra info is included.
Example 2: A customer support bot should have high precision to avoid giving wrong answers, even if it misses some less common questions.
Good: Precision and recall both above 0.8, F1 score near 0.8 or higher, BLEU/ROUGE scores showing close match to expected answers.
Bad: Precision or recall below 0.5, meaning many wrong or missed answers. Low F1 score below 0.6 shows imbalance. BLEU/ROUGE scores near zero mean poor generation quality.
- Accuracy paradox: High accuracy can be misleading if data is imbalanced (e.g., many irrelevant items).
- Data leakage: If retrieval uses future info, metrics look better but model fails in real use.
- Overfitting: Very high training scores but low test scores mean model memorizes data, not generalizes.
- Ignoring multimodal balance: Metrics only on text or images separately miss how well the model combines both.
Your Multimodal RAG model has 98% accuracy but only 12% recall on relevant info. Is it good for production? Why or why not?
Answer: No, it is not good. The very low recall means the model misses most relevant information, which is critical for retrieval tasks. High accuracy here is misleading because most data is irrelevant, so the model guesses irrelevant too often. You need to improve recall to ensure the model finds the right info.
Practice
Solution
Step 1: Understand the components of Multimodal RAG
Multimodal RAG uses both text and image data to improve retrieval and generation tasks.Step 2: Identify the main goal
The goal is to combine these data types to find and generate better answers than using text or images alone.Final Answer:
To combine text and images for better information retrieval and generation -> Option CQuick Check:
Multimodal RAG = combine text + images [OK]
- Thinking it only works with text
- Confusing it with image-only models
- Assuming it only generates images
Solution
Step 1: Recall the architecture of Multimodal RAG
It uses separate encoders for text and images to handle each data type properly.Step 2: Understand the role of retriever and generator
The retriever finds relevant data, and the generator creates the final output combining both modalities.Final Answer:
Separate encoders for text and images, plus a retriever and a generator -> Option BQuick Check:
Separate encoders + retriever + generator = B [OK]
- Assuming one encoder handles both text and images
- Ignoring the retriever component
- Thinking image processing is optional
text_embedding = text_encoder(text_input) image_embedding = image_encoder(image_input) combined_embedding = concatenate(text_embedding, image_embedding) retrieved_docs = retriever.retrieve(combined_embedding) print(type(retrieved_docs))
Solution
Step 1: Understand the retriever output
The retriever typically returns a list of documents or data items relevant to the query embedding.Step 2: Identify the output type printed
Since retrieved_docs holds multiple documents, its type is a list.Final Answer:
<class 'list'> -> Option DQuick Check:
Retriever output = list of documents [OK]
- Assuming output is a string or dictionary
- Confusing embedding types with retrieval output
- Expecting a single document instead of a list
def generate_answer(text, image):
text_emb = text_encoder(text)
image_emb = image_encoder(image)
combined = text_emb + image_emb
docs = retriever.retrieve(combined)
answer = generator.generate(docs)
return answer
What is the main error in this code?Solution
Step 1: Check how embeddings are combined
Embeddings from different modalities should be concatenated, not added, to preserve information.Step 2: Understand the impact of using '+' operator
Adding embeddings sums values element-wise, which can lose modality-specific features.Final Answer:
Using '+' to combine embeddings instead of concatenation -> Option AQuick Check:
Combine embeddings = concatenate, not add [OK]
- Thinking '+' merges embeddings correctly
- Ignoring the need for separate encoders
- Assuming retriever or generator order is wrong
Solution
Step 1: Identify the cause of missing relevant images
Low-quality image embeddings can cause the retriever to miss relevant images.Step 2: Choose the best fix
Training the image encoder with more diverse data improves embedding quality and retrieval accuracy.Final Answer:
Train the image encoder with more diverse image-text pairs to improve embedding quality -> Option AQuick Check:
Better image encoder training = better retrieval [OK]
- Removing retriever loses retrieval benefits
- Ignoring images reduces multimodal power
- Simplifying text encoder won't fix image retrieval
