commit before WORKED, changing graph
Browse files- src/fragments/d3-graph.html +7 -144
- src/transformers-custom.css +24 -13
src/fragments/d3-graph.html
CHANGED
|
@@ -1,149 +1,12 @@
|
|
| 1 |
-
<div
|
| 2 |
-
<div
|
| 3 |
-
<
|
| 4 |
-
<p style="margin: 0.5rem 0 0 0; font-size: 0.9em; color: #6c757d;">
|
| 5 |
-
Explore how transformers models inherit from each other using the modular system. Click and drag nodes to interact!
|
| 6 |
-
</p>
|
| 7 |
</div>
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<div id="loading-message" style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #6c757d; font-style: italic;">
|
| 11 |
-
Loading D3 visualization...
|
| 12 |
-
</div>
|
| 13 |
</div>
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
<strong>Legend:</strong>
|
| 17 |
-
• <span style="color: #3182ce;">Blue nodes</span>: Base models (e.g., Llama, BERT)
|
| 18 |
-
• <span style="color: #38a169;">Green nodes</span>: Derived models
|
| 19 |
-
• <span style="color: #e53e3e;">Red nodes</span>: Standalone models
|
| 20 |
-
• <strong>Lines</strong>: Inheritance relationships
|
| 21 |
</div>
|
| 22 |
</div>
|
| 23 |
|
| 24 |
-
<script>
|
| 25 |
-
document.addEventListener('DOMContentLoaded', function() {
|
| 26 |
-
const container = document.getElementById('d3-graph-container');
|
| 27 |
-
const loadingMessage = document.getElementById('loading-message');
|
| 28 |
-
|
| 29 |
-
// Check if D3 is available
|
| 30 |
-
if (typeof d3 === 'undefined') {
|
| 31 |
-
loadingMessage.textContent = 'D3.js library not loaded. Install D3 to see the interactive graph.';
|
| 32 |
-
return;
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
// Sample data - in the real app this would come from your static/d3_dependency_graph.html
|
| 36 |
-
const nodes = [
|
| 37 |
-
{ id: 'llama', group: 1, name: 'Llama' },
|
| 38 |
-
{ id: 'mixtral', group: 2, name: 'Mixtral' },
|
| 39 |
-
{ id: 'gemma', group: 2, name: 'Gemma' },
|
| 40 |
-
{ id: 'qwen', group: 2, name: 'Qwen' },
|
| 41 |
-
{ id: 'bert', group: 1, name: 'BERT' },
|
| 42 |
-
{ id: 'roberta', group: 2, name: 'RoBERTa' },
|
| 43 |
-
{ id: 'distilbert', group: 2, name: 'DistilBERT' },
|
| 44 |
-
{ id: 'gpt2', group: 1, name: 'GPT-2' },
|
| 45 |
-
{ id: 'mamba', group: 3, name: 'Mamba' }
|
| 46 |
-
];
|
| 47 |
-
|
| 48 |
-
const links = [
|
| 49 |
-
{ source: 'llama', target: 'mixtral' },
|
| 50 |
-
{ source: 'llama', target: 'gemma' },
|
| 51 |
-
{ source: 'llama', target: 'qwen' },
|
| 52 |
-
{ source: 'bert', target: 'roberta' },
|
| 53 |
-
{ source: 'bert', target: 'distilbert' }
|
| 54 |
-
];
|
| 55 |
-
|
| 56 |
-
// Clear loading message
|
| 57 |
-
loadingMessage.style.display = 'none';
|
| 58 |
-
|
| 59 |
-
// Create SVG
|
| 60 |
-
const width = container.offsetWidth;
|
| 61 |
-
const height = 500;
|
| 62 |
-
|
| 63 |
-
const svg = d3.select(container)
|
| 64 |
-
.append('svg')
|
| 65 |
-
.attr('width', width)
|
| 66 |
-
.attr('height', height);
|
| 67 |
-
|
| 68 |
-
// Create force simulation
|
| 69 |
-
const simulation = d3.forceSimulation(nodes)
|
| 70 |
-
.force('link', d3.forceLink(links).id(d => d.id).distance(100))
|
| 71 |
-
.force('charge', d3.forceManyBody().strength(-300))
|
| 72 |
-
.force('center', d3.forceCenter(width / 2, height / 2));
|
| 73 |
-
|
| 74 |
-
// Create links
|
| 75 |
-
const link = svg.append('g')
|
| 76 |
-
.attr('stroke', '#999')
|
| 77 |
-
.attr('stroke-opacity', 0.6)
|
| 78 |
-
.selectAll('line')
|
| 79 |
-
.data(links)
|
| 80 |
-
.join('line')
|
| 81 |
-
.attr('stroke-width', 2);
|
| 82 |
-
|
| 83 |
-
// Create nodes
|
| 84 |
-
const node = svg.append('g')
|
| 85 |
-
.attr('stroke', '#fff')
|
| 86 |
-
.attr('stroke-width', 1.5)
|
| 87 |
-
.selectAll('circle')
|
| 88 |
-
.data(nodes)
|
| 89 |
-
.join('circle')
|
| 90 |
-
.attr('r', 8)
|
| 91 |
-
.attr('fill', d => {
|
| 92 |
-
switch(d.group) {
|
| 93 |
-
case 1: return '#3182ce'; // Base models
|
| 94 |
-
case 2: return '#38a169'; // Derived models
|
| 95 |
-
case 3: return '#e53e3e'; // Standalone models
|
| 96 |
-
default: return '#6c757d';
|
| 97 |
-
}
|
| 98 |
-
})
|
| 99 |
-
.call(d3.drag()
|
| 100 |
-
.on('start', dragstarted)
|
| 101 |
-
.on('drag', dragged)
|
| 102 |
-
.on('end', dragended));
|
| 103 |
-
|
| 104 |
-
// Add labels
|
| 105 |
-
const labels = svg.append('g')
|
| 106 |
-
.selectAll('text')
|
| 107 |
-
.data(nodes)
|
| 108 |
-
.join('text')
|
| 109 |
-
.text(d => d.name)
|
| 110 |
-
.attr('font-size', '12px')
|
| 111 |
-
.attr('dx', 12)
|
| 112 |
-
.attr('dy', 4);
|
| 113 |
-
|
| 114 |
-
// Update positions on tick
|
| 115 |
-
simulation.on('tick', () => {
|
| 116 |
-
link
|
| 117 |
-
.attr('x1', d => d.source.x)
|
| 118 |
-
.attr('y1', d => d.source.y)
|
| 119 |
-
.attr('x2', d => d.target.x)
|
| 120 |
-
.attr('y2', d => d.target.y);
|
| 121 |
-
|
| 122 |
-
node
|
| 123 |
-
.attr('cx', d => d.x)
|
| 124 |
-
.attr('cy', d => d.y);
|
| 125 |
-
|
| 126 |
-
labels
|
| 127 |
-
.attr('x', d => d.x)
|
| 128 |
-
.attr('y', d => d.y);
|
| 129 |
-
});
|
| 130 |
-
|
| 131 |
-
// Drag functions
|
| 132 |
-
function dragstarted(event, d) {
|
| 133 |
-
if (!event.active) simulation.alphaTarget(0.3).restart();
|
| 134 |
-
d.fx = d.x;
|
| 135 |
-
d.fy = d.y;
|
| 136 |
-
}
|
| 137 |
-
|
| 138 |
-
function dragged(event, d) {
|
| 139 |
-
d.fx = event.x;
|
| 140 |
-
d.fy = event.y;
|
| 141 |
-
}
|
| 142 |
-
|
| 143 |
-
function dragended(event, d) {
|
| 144 |
-
if (!event.active) simulation.alphaTarget(0);
|
| 145 |
-
d.fx = null;
|
| 146 |
-
d.fy = null;
|
| 147 |
-
}
|
| 148 |
-
});
|
| 149 |
-
</script>
|
|
|
|
| 1 |
+
<div class="interactive-demo">
|
| 2 |
+
<div class="demo-header">
|
| 3 |
+
<h3>🔗 Model Dependency Graph</h3>
|
|
|
|
|
|
|
|
|
|
| 4 |
</div>
|
| 5 |
+
<div class="demo-content">
|
| 6 |
+
<iframe src="static/d3_dependency_graph.html" width="100%" height="600px" frameborder="0" style="border-radius: 8px; background: white;"></iframe>
|
|
|
|
|
|
|
|
|
|
| 7 |
</div>
|
| 8 |
+
<div class="demo-footer">
|
| 9 |
+
Interactive dependency graph showing real relationships between Transformers models. 🟡 Base models (HuggingFace logo), 🔵 Derived modular models. Click and drag to explore!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
</div>
|
| 11 |
</div>
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/transformers-custom.css
CHANGED
|
@@ -263,15 +263,13 @@ img {
|
|
| 263 |
margin: 1.5rem 0;
|
| 264 |
}
|
| 265 |
|
| 266 |
-
/* Table of contents styling - Fixed
|
| 267 |
@media (min-width: 1200px) {
|
| 268 |
d-article {
|
| 269 |
-
overflow: visible;
|
| 270 |
}
|
| 271 |
|
| 272 |
d-contents {
|
| 273 |
-
position: sticky !important;
|
| 274 |
-
top: 10px !important;
|
| 275 |
align-self: start !important;
|
| 276 |
background: white !important;
|
| 277 |
grid-column-start: 1 !important;
|
|
@@ -281,6 +279,9 @@ img {
|
|
| 281 |
margin-top: 0em !important;
|
| 282 |
padding-right: 3em !important;
|
| 283 |
padding-left: 2em !important;
|
|
|
|
|
|
|
|
|
|
| 284 |
overflow-y: auto !important;
|
| 285 |
height: calc(100vh - 40px) !important;
|
| 286 |
scrollbar-width: none !important;
|
|
@@ -288,23 +289,33 @@ img {
|
|
| 288 |
z-index: -100 !important;
|
| 289 |
display: block !important;
|
| 290 |
visibility: visible !important;
|
| 291 |
-
border-right: 1px solid rgba(0, 0, 0, 0.1) !important;
|
| 292 |
}
|
| 293 |
}
|
| 294 |
|
| 295 |
@media (max-width: 1199px) {
|
| 296 |
d-contents {
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
}
|
| 306 |
}
|
| 307 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
/* TOC Navigation styling */
|
| 309 |
d-contents .toc-header {
|
| 310 |
margin-bottom: 1.5rem;
|
|
|
|
| 263 |
margin: 1.5rem 0;
|
| 264 |
}
|
| 265 |
|
| 266 |
+
/* Table of contents styling - Fixed positioning like ultrascale */
|
| 267 |
@media (min-width: 1200px) {
|
| 268 |
d-article {
|
| 269 |
+
overflow: visible !important;
|
| 270 |
}
|
| 271 |
|
| 272 |
d-contents {
|
|
|
|
|
|
|
| 273 |
align-self: start !important;
|
| 274 |
background: white !important;
|
| 275 |
grid-column-start: 1 !important;
|
|
|
|
| 279 |
margin-top: 0em !important;
|
| 280 |
padding-right: 3em !important;
|
| 281 |
padding-left: 2em !important;
|
| 282 |
+
position: -webkit-sticky !important; /* For Safari */
|
| 283 |
+
position: sticky !important;
|
| 284 |
+
top: 10px !important;
|
| 285 |
overflow-y: auto !important;
|
| 286 |
height: calc(100vh - 40px) !important;
|
| 287 |
scrollbar-width: none !important;
|
|
|
|
| 289 |
z-index: -100 !important;
|
| 290 |
display: block !important;
|
| 291 |
visibility: visible !important;
|
|
|
|
| 292 |
}
|
| 293 |
}
|
| 294 |
|
| 295 |
@media (max-width: 1199px) {
|
| 296 |
d-contents {
|
| 297 |
+
display: none !important;
|
| 298 |
+
background: white !important;
|
| 299 |
+
justify-self: start !important;
|
| 300 |
+
align-self: start !important;
|
| 301 |
+
padding-bottom: 0.5em !important;
|
| 302 |
+
margin-bottom: 1em !important;
|
| 303 |
+
padding-left: 0.25em !important;
|
| 304 |
+
border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
|
| 305 |
+
overflow-y: scroll !important;
|
| 306 |
+
height: calc(100vh - 40px) !important;
|
| 307 |
+
scrollbar-width: none !important;
|
| 308 |
+
z-index: -100 !important;
|
| 309 |
}
|
| 310 |
}
|
| 311 |
|
| 312 |
+
/* Force TOC to be visible and override distill defaults */
|
| 313 |
+
d-contents {
|
| 314 |
+
display: block !important;
|
| 315 |
+
visibility: visible !important;
|
| 316 |
+
opacity: 1 !important;
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
/* TOC Navigation styling */
|
| 320 |
d-contents .toc-header {
|
| 321 |
margin-bottom: 1.5rem;
|