Spaces:
Running
Running
Commit ·
028b203
1
Parent(s): a86908c
Add token color if max
Browse files- frontend/index.html +5 -10
- frontend/script.js +3 -0
- frontend/styles.css +7 -0
frontend/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
| 6 |
<title>DeepGaze</title>
|
| 7 |
-
<link rel="stylesheet" href="
|
| 8 |
<!-- Load D3 -->
|
| 9 |
<script src="https://d3js.org/d3.v6.min.js"></script>
|
| 10 |
<style>
|
|
@@ -72,13 +72,15 @@
|
|
| 72 |
a rich and nuanced understanding of the language. Despite the critical role that these attention mechanisms play,
|
| 73 |
it's interesting to note that only about one third of all the weights in a large language model are actually in the
|
| 74 |
attention blocks. So while the famous slogan "attention is all you need" highlights the importance of these connections,
|
| 75 |
-
in terms of sheer weight, it's only one third of what you really need!
|
| 76 |
</p>
|
|
|
|
| 77 |
</section>
|
| 78 |
|
| 79 |
<!-- Deep Gaze into Attention Heads Section -->
|
| 80 |
<section class="deep-gaze-section">
|
| 81 |
<h2>A Deep Gaze into Attention Heads</h2>
|
|
|
|
| 82 |
<p>Click on a head that looks interesting to gaze deeper into it in the next section</p>
|
| 83 |
<!-- Text Input & Process Button -->
|
| 84 |
<form id="textForm" class="text-form">
|
|
@@ -113,17 +115,10 @@
|
|
| 113 |
</p>
|
| 114 |
<div id="tokenContainer"></div>
|
| 115 |
</section>
|
| 116 |
-
|
| 117 |
-
<!-- (Optional debugging output area has been removed) -->
|
| 118 |
-
|
| 119 |
</main>
|
| 120 |
</div>
|
| 121 |
|
| 122 |
-
<div class="credits-container">
|
| 123 |
-
Created by ferdi & samu - Credits to <a href="https://jessevig.com/" target="_blank">BertViz</a>
|
| 124 |
-
</div>
|
| 125 |
-
|
| 126 |
<!-- External JavaScript (all event listeners and functions are defined here) -->
|
| 127 |
-
<script src="
|
| 128 |
</body>
|
| 129 |
</html>
|
|
|
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
| 6 |
<title>DeepGaze</title>
|
| 7 |
+
<link rel="stylesheet" href="styles.css" />
|
| 8 |
<!-- Load D3 -->
|
| 9 |
<script src="https://d3js.org/d3.v6.min.js"></script>
|
| 10 |
<style>
|
|
|
|
| 72 |
a rich and nuanced understanding of the language. Despite the critical role that these attention mechanisms play,
|
| 73 |
it's interesting to note that only about one third of all the weights in a large language model are actually in the
|
| 74 |
attention blocks. So while the famous slogan "attention is all you need" highlights the importance of these connections,
|
| 75 |
+
in terms of sheer weight, it's only one third of what you really need!
|
| 76 |
</p>
|
| 77 |
+
<p id="credits">Made with <3 by Ferdi & Samu. Credits for model view below to <a href="https://jessevig.com/" target="_blank">BertViz</a>.</p>
|
| 78 |
</section>
|
| 79 |
|
| 80 |
<!-- Deep Gaze into Attention Heads Section -->
|
| 81 |
<section class="deep-gaze-section">
|
| 82 |
<h2>A Deep Gaze into Attention Heads</h2>
|
| 83 |
+
<p>Type in a token sequence (below 50 characters)</p>
|
| 84 |
<p>Click on a head that looks interesting to gaze deeper into it in the next section</p>
|
| 85 |
<!-- Text Input & Process Button -->
|
| 86 |
<form id="textForm" class="text-form">
|
|
|
|
| 115 |
</p>
|
| 116 |
<div id="tokenContainer"></div>
|
| 117 |
</section>
|
|
|
|
|
|
|
|
|
|
| 118 |
</main>
|
| 119 |
</div>
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
<!-- External JavaScript (all event listeners and functions are defined here) -->
|
| 122 |
+
<script src="script.js?v=202845563"></script>
|
| 123 |
</body>
|
| 124 |
</html>
|
frontend/script.js
CHANGED
|
@@ -187,6 +187,9 @@ function highlightAttention(index, attentionData, layer_idx, head_idx) {
|
|
| 187 |
Array.from(container.children).forEach((span, idx) => {
|
| 188 |
if (idx < index) {
|
| 189 |
const weight = weights[idx];
|
|
|
|
|
|
|
|
|
|
| 190 |
const newFontSize = baseFontSize + (weight / maxWeight) * maxIncrease;
|
| 191 |
span.style.fontSize = newFontSize + "px";
|
| 192 |
} else {
|
|
|
|
| 187 |
Array.from(container.children).forEach((span, idx) => {
|
| 188 |
if (idx < index) {
|
| 189 |
const weight = weights[idx];
|
| 190 |
+
if (weight == maxWeight){
|
| 191 |
+
span.style.color = "#800000"; // Bordo red
|
| 192 |
+
}
|
| 193 |
const newFontSize = baseFontSize + (weight / maxWeight) * maxIncrease;
|
| 194 |
span.style.fontSize = newFontSize + "px";
|
| 195 |
} else {
|
frontend/styles.css
CHANGED
|
@@ -188,4 +188,11 @@ button:hover {
|
|
| 188 |
padding: 10px 20px;
|
| 189 |
font-size: 16px;
|
| 190 |
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
}
|
|
|
|
| 188 |
padding: 10px 20px;
|
| 189 |
font-size: 16px;
|
| 190 |
cursor: pointer;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
#credits {
|
| 194 |
+
font-size: 0.8rem;
|
| 195 |
+
color: #888;
|
| 196 |
+
margin-top: 1rem;
|
| 197 |
+
font-style: italic;
|
| 198 |
}
|