added re-ranking visualization

This commit is contained in:
nird
2024-08-30 13:21:32 +03:00
parent 13453c1458
commit 0f95f187a0
2 changed files with 87 additions and 0 deletions

View File

@@ -48,6 +48,16 @@
"The choice between LLM-based and Cross-Encoder reranking methods depends on factors such as required accuracy, available computational resources, and specific application needs. Both approaches offer substantial improvements over basic retrieval methods and contribute to the overall effectiveness of RAG systems."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div style=\"text-align: center;\">\n",
"\n",
"<img src=\"../images/reranking-visualization.svg\" alt=\"rerank llm\" style=\"width:100%; height:auto;\">\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {},

View File

@@ -0,0 +1,77 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 400">
<defs>
<filter id="shadow" x="-20%" y="-20%" width="140%" height="140%">
<feDropShadow dx="2" dy="2" stdDeviation="2" flood-color="#000000" flood-opacity="0.3"/>
</filter>
</defs>
<!-- Background -->
<rect x="0" y="0" width="800" height="400" fill="#f0f9ff" rx="20" ry="20" />
<!-- Title -->
<text x="400" y="40" text-anchor="middle" font-size="24" font-weight="bold" fill="#333">Re-ranking Process</text>
<!-- Initial Retrieval -->
<rect x="20" y="70" width="220" height="310" fill="#e6f3ff" rx="10" ry="10" filter="url(#shadow)" />
<text x="130" y="100" text-anchor="middle" font-size="18" font-weight="bold" fill="#333">Initial Retrieval</text>
<rect x="40" y="120" width="180" height="40" fill="#4e79a7" rx="5" ry="5" />
<text x="130" y="145" text-anchor="middle" font-size="14" fill="white">Vector Store</text>
<rect x="40" y="180" width="180" height="30" fill="#f28e2b" rx="5" ry="5" />
<text x="130" y="200" text-anchor="middle" font-size="12" fill="white">Document 1</text>
<rect x="40" y="220" width="180" height="30" fill="#e15759" rx="5" ry="5" />
<text x="130" y="240" text-anchor="middle" font-size="12" fill="white">Document 2</text>
<rect x="40" y="260" width="180" height="30" fill="#76b7b2" rx="5" ry="5" />
<text x="130" y="280" text-anchor="middle" font-size="12" fill="white">Document 3</text>
<rect x="40" y="300" width="180" height="30" fill="#59a14f" rx="5" ry="5" />
<text x="130" y="320" text-anchor="middle" font-size="12" fill="white">Document 4</text>
<!-- Re-ranking Process -->
<rect x="290" y="70" width="220" height="310" fill="#e6f3ff" rx="10" ry="10" filter="url(#shadow)" />
<text x="400" y="100" text-anchor="middle" font-size="18" font-weight="bold" fill="#333">Re-ranking Process</text>
<rect x="310" y="120" width="180" height="60" fill="#4e79a7" rx="5" ry="5" />
<text x="400" y="145" text-anchor="middle" font-size="14" fill="white">Re-ranking Model</text>
<text x="400" y="165" text-anchor="middle" font-size="12" fill="white">(LLM or Cross-Encoder)</text>
<rect x="310" y="200" width="180" height="60" fill="#f28e2b" rx="5" ry="5" />
<text x="400" y="225" text-anchor="middle" font-size="14" fill="white">Relevance Scoring</text>
<text x="400" y="245" text-anchor="middle" font-size="12" fill="white">Based on query context</text>
<rect x="310" y="280" width="180" height="60" fill="#e15759" rx="5" ry="5" />
<text x="400" y="305" text-anchor="middle" font-size="14" fill="white">Re-ordering</text>
<text x="400" y="325" text-anchor="middle" font-size="12" fill="white">Based on relevance scores</text>
<!-- Final Results -->
<rect x="560" y="70" width="220" height="310" fill="#e6f3ff" rx="10" ry="10" filter="url(#shadow)" />
<text x="670" y="100" text-anchor="middle" font-size="18" font-weight="bold" fill="#333">Re-ranked Results</text>
<rect x="580" y="120" width="180" height="30" fill="#76b7b2" rx="5" ry="5" />
<text x="670" y="140" text-anchor="middle" font-size="12" fill="white">Most Relevant Document</text>
<rect x="580" y="160" width="180" height="30" fill="#f28e2b" rx="5" ry="5" />
<text x="670" y="180" text-anchor="middle" font-size="12" fill="white">Second Most Relevant</text>
<rect x="580" y="200" width="180" height="30" fill="#e15759" rx="5" ry="5" />
<text x="670" y="220" text-anchor="middle" font-size="12" fill="white">Third Most Relevant</text>
<rect x="580" y="240" width="180" height="30" fill="#59a14f" opacity="0.5" rx="5" ry="5" />
<text x="670" y="260" text-anchor="middle" font-size="12" fill="white">Less Relevant Document</text>
<!-- Arrows -->
<path d="M 250 220 L 280 220" stroke="#333" stroke-width="2" marker-end="url(#arrowhead)" />
<path d="M 520 220 L 550 220" stroke="#333" stroke-width="2" marker-end="url(#arrowhead)" />
<defs>
<marker id="arrowhead" markerWidth="10" markerHeight="7" refX="0" refY="3.5" orient="auto">
<polygon points="0 0, 10 3.5, 0 7" fill="#333" />
</marker>
</defs>
<!-- Explanatory Text -->
<text x="400" y="390" text-anchor="middle" font-size="14" fill="#333">Re-ranking improves relevance by considering context and query intent</text>
</svg>

After

Width:  |  Height:  |  Size: 4.2 KiB