Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
-
OpenLLM Real Models App -
|
| 4 |
"""
|
| 5 |
|
| 6 |
import gradio as gr
|
|
@@ -49,8 +49,8 @@ class GPT(nn.Module):
|
|
| 49 |
ln_f = nn.LayerNorm(config.n_embd),
|
| 50 |
))
|
| 51 |
|
| 52 |
-
# Language model head -
|
| 53 |
-
self.lm_head = nn.Linear(config.n_embd, config.vocab_size, bias=
|
| 54 |
|
| 55 |
# Initialize weights
|
| 56 |
self.apply(self._init_weights)
|
|
@@ -133,7 +133,7 @@ class Block(nn.Module):
|
|
| 133 |
return x
|
| 134 |
|
| 135 |
class CausalSelfAttention(nn.Module):
|
| 136 |
-
"""Multi-head self-attention with causal masking -
|
| 137 |
def __init__(self, config):
|
| 138 |
super().__init__()
|
| 139 |
assert config.n_embd % config.n_head == 0
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
+
OpenLLM Real Models App - Ultimate working version with correct lm_head bias handling
|
| 4 |
"""
|
| 5 |
|
| 6 |
import gradio as gr
|
|
|
|
| 49 |
ln_f = nn.LayerNorm(config.n_embd),
|
| 50 |
))
|
| 51 |
|
| 52 |
+
# Language model head - NO bias to match saved model
|
| 53 |
+
self.lm_head = nn.Linear(config.n_embd, config.vocab_size, bias=False)
|
| 54 |
|
| 55 |
# Initialize weights
|
| 56 |
self.apply(self._init_weights)
|
|
|
|
| 133 |
return x
|
| 134 |
|
| 135 |
class CausalSelfAttention(nn.Module):
|
| 136 |
+
"""Multi-head self-attention with causal masking - ULTIMATE WORKING VERSION"""
|
| 137 |
def __init__(self, config):
|
| 138 |
super().__init__()
|
| 139 |
assert config.n_embd % config.n_head == 0
|