Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,18 +33,30 @@ class RotaryEmbedding(keras.layers.Layer):
|
|
| 33 |
self.dim = dim
|
| 34 |
self.max_len = max_len
|
| 35 |
self.theta = theta
|
| 36 |
-
self.built_cache = False
|
| 37 |
|
| 38 |
def build(self, input_shape):
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
super().build(input_shape)
|
| 50 |
|
|
@@ -579,6 +591,9 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
| 579 |
gr.HTML("""
|
| 580 |
<div class="header">
|
| 581 |
<div class="celebration">π π β¨ π π</div>
|
|
|
|
|
|
|
|
|
|
| 582 |
<h1>π€ SAM-Z-1 Chat π€</h1>
|
| 583 |
<p><strong>LATEST RELEASE!</strong> Our fastest non-reasoning model</p>
|
| 584 |
<div class="twin-badge">Twin of SAM-X-1 (Reasoning Model)</div>
|
|
@@ -591,6 +606,9 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
| 591 |
else:
|
| 592 |
gr.HTML("""
|
| 593 |
<div class="header">
|
|
|
|
|
|
|
|
|
|
| 594 |
<h1>π€ SAM-Z-1 Chat</h1>
|
| 595 |
<p>Fast, direct responses without reasoning overhead</p>
|
| 596 |
<p style="font-size: 0.9rem; margin-top: 0.5rem;">
|
|
|
|
| 33 |
self.dim = dim
|
| 34 |
self.max_len = max_len
|
| 35 |
self.theta = theta
|
|
|
|
| 36 |
|
| 37 |
def build(self, input_shape):
|
| 38 |
+
# Compute embeddings using numpy, then convert to TF tensors
|
| 39 |
+
inv_freq = 1.0 / (self.theta ** (np.arange(0, self.dim, 2, dtype=np.float32) / self.dim))
|
| 40 |
+
t = np.arange(self.max_len, dtype=np.float32)
|
| 41 |
+
freqs = np.outer(t, inv_freq)
|
| 42 |
+
emb = np.concatenate([freqs, freqs], axis=-1)
|
| 43 |
+
|
| 44 |
+
# Create non-trainable weights for cos and sin embeddings
|
| 45 |
+
self.cos_cached = self.add_weight(
|
| 46 |
+
name="cos_cached",
|
| 47 |
+
shape=(self.max_len, self.dim),
|
| 48 |
+
initializer=keras.initializers.Constant(np.cos(emb)),
|
| 49 |
+
trainable=False,
|
| 50 |
+
dtype=tf.float32
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
self.sin_cached = self.add_weight(
|
| 54 |
+
name="sin_cached",
|
| 55 |
+
shape=(self.max_len, self.dim),
|
| 56 |
+
initializer=keras.initializers.Constant(np.sin(emb)),
|
| 57 |
+
trainable=False,
|
| 58 |
+
dtype=tf.float32
|
| 59 |
+
)
|
| 60 |
|
| 61 |
super().build(input_shape)
|
| 62 |
|
|
|
|
| 591 |
gr.HTML("""
|
| 592 |
<div class="header">
|
| 593 |
<div class="celebration">π π β¨ π π</div>
|
| 594 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/64e3486b82fb6ae7a06c749c/yBUDdaTze1L84NaDSpZGf.jpeg"
|
| 595 |
+
alt="SAM-Z-1"
|
| 596 |
+
style="max-width: 400px; border-radius: 12px; margin: 1rem auto; display: block; box-shadow: 0 8px 24px rgba(0,0,0,0.2);">
|
| 597 |
<h1>π€ SAM-Z-1 Chat π€</h1>
|
| 598 |
<p><strong>LATEST RELEASE!</strong> Our fastest non-reasoning model</p>
|
| 599 |
<div class="twin-badge">Twin of SAM-X-1 (Reasoning Model)</div>
|
|
|
|
| 606 |
else:
|
| 607 |
gr.HTML("""
|
| 608 |
<div class="header">
|
| 609 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/64e3486b82fb6ae7a06c749c/yBUDdaTze1L84NaDSpZGf.jpeg"
|
| 610 |
+
alt="SAM-Z-1"
|
| 611 |
+
style="max-width: 300px; border-radius: 12px; margin: 1rem auto; display: block; box-shadow: 0 4px 16px rgba(0,0,0,0.15);">
|
| 612 |
<h1>π€ SAM-Z-1 Chat</h1>
|
| 613 |
<p>Fast, direct responses without reasoning overhead</p>
|
| 614 |
<p style="font-size: 0.9rem; margin-top: 0.5rem;">
|