Spaces:
Running
Running
Update index.html
Browse files- index.html +38 -12
index.html
CHANGED
|
@@ -120,18 +120,44 @@
|
|
| 120 |
const addTabBtn = document.getElementById('add-tab-btn');
|
| 121 |
|
| 122 |
// --- Example Code ---
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
// --- Tab Management ---
|
| 136 |
let tabCounter = 0;
|
| 137 |
|
|
|
|
| 120 |
const addTabBtn = document.getElementById('add-tab-btn');
|
| 121 |
|
| 122 |
// --- Example Code ---
|
| 123 |
+
const exampleCodeMain = `
|
| 124 |
+
# A specific model implementation that uses an external class
|
| 125 |
+
class MyAwesomeModel(BaseModel, AttentionMixin):
|
| 126 |
+
def __init__(self, config):
|
| 127 |
+
super().__init__(config)
|
| 128 |
+
self._init_attention(config)
|
| 129 |
+
|
| 130 |
+
def forward(self, input_ids) -> BaseModelOutputWithPast:
|
| 131 |
+
"""The main forward pass for the model."""
|
| 132 |
+
x = self._split_heads(input_ids)
|
| 133 |
+
# The return type is a class not defined in this file
|
| 134 |
+
return BaseModelOutputWithPast(last_hidden_state=x)
|
| 135 |
+
`;
|
| 136 |
+
|
| 137 |
+
const exampleCodeDeps = `
|
| 138 |
+
# This class is an external dependency, not defined here
|
| 139 |
+
# from modeling_outputs import BaseModelOutputWithPast
|
| 140 |
+
|
| 141 |
+
# A common mixin for attention mechanisms
|
| 142 |
+
class AttentionMixin:
|
| 143 |
+
def _init_attention(self, config):
|
| 144 |
+
self.num_heads = config.num_heads
|
| 145 |
+
self.head_dim = config.hidden_size // config.num_heads
|
| 146 |
+
|
| 147 |
+
def _split_heads(self, tensor):
|
| 148 |
+
# Logic to split tensor for multi-head attention
|
| 149 |
+
return tensor
|
| 150 |
+
|
| 151 |
+
# A base class for all models, similar to PreTrainedModel
|
| 152 |
+
class BaseModel:
|
| 153 |
+
def __init__(self, config):
|
| 154 |
+
self.config = config
|
| 155 |
+
|
| 156 |
+
def from_pretrained(cls, model_name):
|
| 157 |
+
# Load weights
|
| 158 |
+
pass
|
| 159 |
+
`;
|
| 160 |
+
|
| 161 |
// --- Tab Management ---
|
| 162 |
let tabCounter = 0;
|
| 163 |
|