0
0
Agentic AIml~12 mins

Retrieval strategies (similarity, MMR, hybrid) in Agentic AI - Model Pipeline Trace

Choose your learning style9 modes available
Model Pipeline - Retrieval strategies (similarity, MMR, hybrid)

This pipeline shows how different retrieval strategies find the best information from a large set. It uses similarity, Maximal Marginal Relevance (MMR), and a hybrid of both to pick relevant and diverse results.

Data Flow - 7 Stages
1Input Query
1 query stringReceive user question or search phrase1 query string
"What are the benefits of exercise?"
2Document Collection
1000 documents (text)Load all documents to search from1000 documents (text)
Articles about health, fitness, nutrition, etc.
3Embedding Generation
1 query string, 1000 documentsConvert query and documents into vector embeddings1 query vector (512 dims), 1000 document vectors (512 dims)
Query vector: [0.12, -0.03, ..., 0.45], Document vector: [0.05, 0.10, ..., -0.02]
4Similarity Calculation
1 query vector, 1000 document vectorsCalculate cosine similarity scores between query and each document1000 similarity scores (float -1 to 1)
Scores like 0.85, 0.60, 0.45 for documents
5MMR Re-ranking
Top 100 documents with similarity scoresRe-rank documents balancing relevance and diversity using MMRTop 10 documents re-ranked
Selected documents that are relevant but not too similar to each other
6Hybrid Strategy
Similarity scores and MMR scoresCombine similarity and MMR scores to select final documentsFinal 5 documents
Documents that are both highly relevant and diverse
7Output Results
Final 5 documentsReturn selected documents as search results5 documents (text)
Articles explaining exercise benefits with different focuses
Training Trace - Epoch by Epoch

Loss
0.7 | *
0.6 |  *
0.5 |   *
0.4 |    *
0.3 |     *
0.2 |      *
    +----------------
     1 2 3 4 5 Epochs
EpochLoss ↓Accuracy ↑Observation
10.650.55Initial training with random weights, loss high, accuracy low
20.480.68Model starts learning to rank documents better
30.350.78Loss decreases steadily, accuracy improves
40.280.83Model converging, better relevance and diversity balance
50.240.87Final epoch shows good performance on validation data
Prediction Trace - 5 Layers
Layer 1: Embedding Generation
Layer 2: Similarity Calculation
Layer 3: MMR Re-ranking
Layer 4: Hybrid Strategy
Layer 5: Output Results
Model Quiz - 3 Questions
Test your understanding
What does the similarity calculation stage do?
AConverts text into numbers
BRemoves duplicate documents
CMeasures how close the query and documents are in meaning
DCombines relevance and diversity scores
Key Insight
This visualization shows how combining similarity and MMR retrieval strategies helps find documents that are both relevant and diverse, improving the quality of search results.