Spaces:
Running
Running
Update index.html
Browse files- index.html +100 -99
index.html
CHANGED
|
@@ -12,12 +12,15 @@
|
|
| 12 |
display: flex;
|
| 13 |
flex-direction: row;
|
| 14 |
height: 100vh;
|
|
|
|
|
|
|
| 15 |
}
|
| 16 |
|
| 17 |
.console {
|
| 18 |
width: 30%;
|
| 19 |
padding: 20px;
|
| 20 |
-
background-color: #
|
|
|
|
| 21 |
overflow-y: auto;
|
| 22 |
}
|
| 23 |
|
|
@@ -30,6 +33,7 @@
|
|
| 30 |
table {
|
| 31 |
width: 100%;
|
| 32 |
border-collapse: collapse;
|
|
|
|
| 33 |
}
|
| 34 |
|
| 35 |
th, td {
|
|
@@ -39,17 +43,65 @@
|
|
| 39 |
}
|
| 40 |
|
| 41 |
th {
|
| 42 |
-
background-color: #
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
.highlight {
|
| 46 |
-
background-color: #
|
| 47 |
-
color: #
|
| 48 |
padding: 10px;
|
| 49 |
margin: 20px 0;
|
| 50 |
-
border: 1px solid #
|
| 51 |
border-radius: 4px;
|
| 52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
</style>
|
| 54 |
<script>
|
| 55 |
function calculateParameters() {
|
|
@@ -63,10 +115,12 @@
|
|
| 63 |
|
| 64 |
// Attention calculations
|
| 65 |
const attentionQ = hiddenSize * hiddenSize;
|
|
|
|
| 66 |
const attentionV = hiddenSize * numKeyValueHeads;
|
| 67 |
const attentionBq = includeBias ? hiddenSize : 0;
|
|
|
|
| 68 |
const attentionBv = includeBias ? numKeyValueHeads : 0;
|
| 69 |
-
const attentionTotal = 2 * (attentionQ + attentionBq) + 2 * (attentionV + attentionBv);
|
| 70 |
|
| 71 |
// Feed Forward calculations
|
| 72 |
const switchW = hiddenSize * intermediateSize;
|
|
@@ -90,78 +144,24 @@
|
|
| 90 |
const fullSize = fullLayersParams + embeddingTotal;
|
| 91 |
|
| 92 |
// Display results
|
| 93 |
-
const
|
| 94 |
-
|
| 95 |
-
<tr>
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
</tr
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
</tr>
|
| 110 |
-
<tr>
|
| 111 |
-
<td>Attention</td>
|
| 112 |
-
<td>V</td>
|
| 113 |
-
<td>${attentionV.toLocaleString()}</td>
|
| 114 |
-
</tr>
|
| 115 |
-
<tr>
|
| 116 |
-
<td>Attention</td>
|
| 117 |
-
<td>Bv</td>
|
| 118 |
-
<td>${attentionBv.toLocaleString()}</td>
|
| 119 |
-
</tr>
|
| 120 |
-
<tr>
|
| 121 |
-
<td>Attention</td>
|
| 122 |
-
<td>Total</td>
|
| 123 |
-
<td>${attentionTotal.toLocaleString()}</td>
|
| 124 |
-
</tr>
|
| 125 |
-
<tr>
|
| 126 |
-
<td>Feed Forward</td>
|
| 127 |
-
<td>Switch W</td>
|
| 128 |
-
<td>${switchW.toLocaleString()}</td>
|
| 129 |
-
</tr>
|
| 130 |
-
<tr>
|
| 131 |
-
<td>Feed Forward</td>
|
| 132 |
-
<td>Switch b</td>
|
| 133 |
-
<td>${switchB.toLocaleString()}</td>
|
| 134 |
-
</tr>
|
| 135 |
-
<tr>
|
| 136 |
-
<td>Feed Forward</td>
|
| 137 |
-
<td>LU W</td>
|
| 138 |
-
<td>${luW.toLocaleString()}</td>
|
| 139 |
-
</tr>
|
| 140 |
-
<tr>
|
| 141 |
-
<td>Feed Forward</td>
|
| 142 |
-
<td>LU b</td>
|
| 143 |
-
<td>${luB.toLocaleString()}</td>
|
| 144 |
-
</tr>
|
| 145 |
-
<tr>
|
| 146 |
-
<td>Feed Forward</td>
|
| 147 |
-
<td>Proj W</td>
|
| 148 |
-
<td>${projW.toLocaleString()}</td>
|
| 149 |
-
</tr>
|
| 150 |
-
<tr>
|
| 151 |
-
<td>Feed Forward</td>
|
| 152 |
-
<td>Proj b</td>
|
| 153 |
-
<td>${projB.toLocaleString()}</td>
|
| 154 |
-
</tr>
|
| 155 |
-
<tr>
|
| 156 |
-
<td>Feed Forward</td>
|
| 157 |
-
<td>Total</td>
|
| 158 |
-
<td>${feedForwardTotal.toLocaleString()}</td>
|
| 159 |
-
</tr>
|
| 160 |
-
<tr>
|
| 161 |
-
<td>Embedding</td>
|
| 162 |
-
<td>Embedding</td>
|
| 163 |
-
<td>${embeddingTotal.toLocaleString()}</td>
|
| 164 |
-
</tr>
|
| 165 |
`;
|
| 166 |
|
| 167 |
document.getElementById('one_layer_params').innerText = oneLayerParams.toLocaleString();
|
|
@@ -174,29 +174,29 @@
|
|
| 174 |
|
| 175 |
<div class="console">
|
| 176 |
<h3>Input Parameters</h3>
|
| 177 |
-
<label for="hidden_size">Hidden size:</label
|
| 178 |
-
<input type="number" id="hidden_size" value="2048"
|
| 179 |
|
| 180 |
-
<label for="intermediate_size">Intermediate size:</label
|
| 181 |
-
<input type="number" id="intermediate_size" value="16384"
|
| 182 |
|
| 183 |
-
<label for="vocab_size">Vocab size:</label
|
| 184 |
-
<input type="number" id="vocab_size" value="64000"
|
| 185 |
|
| 186 |
-
<label for="num_key_value_heads">Number of key-value heads:</label
|
| 187 |
-
<input type="number" id="num_key_value_heads" value="80"
|
| 188 |
|
| 189 |
-
<label for="num_attention_heads">Number of attention heads:</label
|
| 190 |
-
<input type="number" id="num_attention_heads" value="8"
|
| 191 |
|
| 192 |
-
<label for="num_hidden_layers">Number of hidden layers:</label
|
| 193 |
-
<input type="number" id="num_hidden_layers" value="64"
|
| 194 |
|
| 195 |
-
<label for="include_bias">Include bias?</label
|
| 196 |
<select id="include_bias">
|
| 197 |
<option value="yes">Yes</option>
|
| 198 |
<option value="no">No</option>
|
| 199 |
-
</select
|
| 200 |
|
| 201 |
<button onclick="calculateParameters()">Calculate</button>
|
| 202 |
</div>
|
|
@@ -204,13 +204,14 @@
|
|
| 204 |
<div class="output">
|
| 205 |
<h3>Model Parameter Results</h3>
|
| 206 |
|
| 207 |
-
<
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
</
|
|
|
|
| 214 |
|
| 215 |
<div class="highlight">
|
| 216 |
<strong>1 Layer Parameters:</strong> <span id="one_layer_params">0</span><br>
|
|
|
|
| 12 |
display: flex;
|
| 13 |
flex-direction: row;
|
| 14 |
height: 100vh;
|
| 15 |
+
background: linear-gradient(120deg, #f8b7d4, #d1c1f2);
|
| 16 |
+
color: #4a154b;
|
| 17 |
}
|
| 18 |
|
| 19 |
.console {
|
| 20 |
width: 30%;
|
| 21 |
padding: 20px;
|
| 22 |
+
background-color: #fef4fc;
|
| 23 |
+
border-right: 2px solid #d1c1f2;
|
| 24 |
overflow-y: auto;
|
| 25 |
}
|
| 26 |
|
|
|
|
| 33 |
table {
|
| 34 |
width: 100%;
|
| 35 |
border-collapse: collapse;
|
| 36 |
+
margin-bottom: 20px;
|
| 37 |
}
|
| 38 |
|
| 39 |
th, td {
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
th {
|
| 46 |
+
background-color: #d1c1f2;
|
| 47 |
+
color: #4a154b;
|
| 48 |
}
|
| 49 |
|
| 50 |
.highlight {
|
| 51 |
+
background-color: #f8d7f1;
|
| 52 |
+
color: #4a154b;
|
| 53 |
padding: 10px;
|
| 54 |
margin: 20px 0;
|
| 55 |
+
border: 1px solid #d1c1f2;
|
| 56 |
border-radius: 4px;
|
| 57 |
}
|
| 58 |
+
|
| 59 |
+
h3 {
|
| 60 |
+
color: #4a154b;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
label, input, select {
|
| 64 |
+
display: block;
|
| 65 |
+
margin-bottom: 10px;
|
| 66 |
+
width: 100%;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
input, select {
|
| 70 |
+
padding: 8px;
|
| 71 |
+
border: 1px solid #d1c1f2;
|
| 72 |
+
border-radius: 4px;
|
| 73 |
+
background: #fef4fc;
|
| 74 |
+
color: #4a154b;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
button {
|
| 78 |
+
background-color: #d1c1f2;
|
| 79 |
+
color: white;
|
| 80 |
+
padding: 10px 20px;
|
| 81 |
+
border: none;
|
| 82 |
+
border-radius: 4px;
|
| 83 |
+
cursor: pointer;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
button:hover {
|
| 87 |
+
background-color: #bfa8e3;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.section-title {
|
| 91 |
+
background-color: #e9d8f5;
|
| 92 |
+
color: #4a154b;
|
| 93 |
+
text-align: center;
|
| 94 |
+
padding: 5px 0;
|
| 95 |
+
margin-bottom: 5px;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
.sub-table {
|
| 99 |
+
margin-top: 10px;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.no-bias {
|
| 103 |
+
display: none;
|
| 104 |
+
}
|
| 105 |
</style>
|
| 106 |
<script>
|
| 107 |
function calculateParameters() {
|
|
|
|
| 115 |
|
| 116 |
// Attention calculations
|
| 117 |
const attentionQ = hiddenSize * hiddenSize;
|
| 118 |
+
const attentionK = hiddenSize * numKeyValueHeads;
|
| 119 |
const attentionV = hiddenSize * numKeyValueHeads;
|
| 120 |
const attentionBq = includeBias ? hiddenSize : 0;
|
| 121 |
+
const attentionBk = includeBias ? numKeyValueHeads : 0;
|
| 122 |
const attentionBv = includeBias ? numKeyValueHeads : 0;
|
| 123 |
+
const attentionTotal = 2 * (attentionQ + attentionBq) + 2 * (attentionK + attentionBk) + 2 * (attentionV + attentionBv);
|
| 124 |
|
| 125 |
// Feed Forward calculations
|
| 126 |
const switchW = hiddenSize * intermediateSize;
|
|
|
|
| 144 |
const fullSize = fullLayersParams + embeddingTotal;
|
| 145 |
|
| 146 |
// Display results
|
| 147 |
+
const attentionTable = document.getElementById('attention_table');
|
| 148 |
+
attentionTable.innerHTML = `
|
| 149 |
+
<tr><th>Type</th><th>Q</th><th>K</th><th>V</th><th>Total</th></tr>
|
| 150 |
+
<tr><td>Weights</td><td>${attentionQ.toLocaleString()}</td><td>${attentionK.toLocaleString()}</td><td>${attentionV.toLocaleString()}</td><td>${attentionTotal.toLocaleString()}</td></tr>
|
| 151 |
+
${includeBias ? `<tr class="bias-row"><td>Bias</td><td>${attentionBq.toLocaleString()}</td><td>${attentionBk.toLocaleString()}</td><td>${attentionBv.toLocaleString()}</td><td></td></tr>` : ''}
|
| 152 |
+
`;
|
| 153 |
+
|
| 154 |
+
const feedForwardTable = document.getElementById('feed_forward_table');
|
| 155 |
+
feedForwardTable.innerHTML = `
|
| 156 |
+
<tr><th>Type</th><th>Switch W</th><th>LU W</th><th>Proj W</th><th>Total</th></tr>
|
| 157 |
+
<tr><td>Weights</td><td>${switchW.toLocaleString()}</td><td>${luW.toLocaleString()}</td><td>${projW.toLocaleString()}</td><td>${feedForwardTotal.toLocaleString()}</td></tr>
|
| 158 |
+
${includeBias ? `<tr class="bias-row"><td>Bias</td><td>${switchB.toLocaleString()}</td><td>${luB.toLocaleString()}</td><td>${projB.toLocaleString()}</td><td></td></tr>` : ''}
|
| 159 |
+
`;
|
| 160 |
+
|
| 161 |
+
const embeddingTable = document.getElementById('embedding_table');
|
| 162 |
+
embeddingTable.innerHTML = `
|
| 163 |
+
<tr><th>Type</th><th>Total</th></tr>
|
| 164 |
+
<tr><td>Embedding</td><td>${embeddingTotal.toLocaleString()}</td></tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
`;
|
| 166 |
|
| 167 |
document.getElementById('one_layer_params').innerText = oneLayerParams.toLocaleString();
|
|
|
|
| 174 |
|
| 175 |
<div class="console">
|
| 176 |
<h3>Input Parameters</h3>
|
| 177 |
+
<label for="hidden_size">Hidden size:</label>
|
| 178 |
+
<input type="number" id="hidden_size" value="2048">
|
| 179 |
|
| 180 |
+
<label for="intermediate_size">Intermediate size:</label>
|
| 181 |
+
<input type="number" id="intermediate_size" value="16384">
|
| 182 |
|
| 183 |
+
<label for="vocab_size">Vocab size:</label>
|
| 184 |
+
<input type="number" id="vocab_size" value="64000">
|
| 185 |
|
| 186 |
+
<label for="num_key_value_heads">Number of key-value heads:</label>
|
| 187 |
+
<input type="number" id="num_key_value_heads" value="80">
|
| 188 |
|
| 189 |
+
<label for="num_attention_heads">Number of attention heads:</label>
|
| 190 |
+
<input type="number" id="num_attention_heads" value="8">
|
| 191 |
|
| 192 |
+
<label for="num_hidden_layers">Number of hidden layers:</label>
|
| 193 |
+
<input type="number" id="num_hidden_layers" value="64">
|
| 194 |
|
| 195 |
+
<label for="include_bias">Include bias?</label>
|
| 196 |
<select id="include_bias">
|
| 197 |
<option value="yes">Yes</option>
|
| 198 |
<option value="no">No</option>
|
| 199 |
+
</select>
|
| 200 |
|
| 201 |
<button onclick="calculateParameters()">Calculate</button>
|
| 202 |
</div>
|
|
|
|
| 204 |
<div class="output">
|
| 205 |
<h3>Model Parameter Results</h3>
|
| 206 |
|
| 207 |
+
<div class="section-title">Attention Parameters</div>
|
| 208 |
+
<table id="attention_table" class="sub-table"></table>
|
| 209 |
+
|
| 210 |
+
<div class="section-title">Feed Forward Parameters</div>
|
| 211 |
+
<table id="feed_forward_table" class="sub-table"></table>
|
| 212 |
+
|
| 213 |
+
<div class="section-title">Embedding Parameters</div>
|
| 214 |
+
<table id="embedding_table" class="sub-table"></table>
|
| 215 |
|
| 216 |
<div class="highlight">
|
| 217 |
<strong>1 Layer Parameters:</strong> <span id="one_layer_params">0</span><br>
|