Spaces:
Sleeping
Sleeping
Commit ·
9a74bcc
1
Parent(s): d13b04a
cosmatic changes
Browse files
README.md
CHANGED
|
@@ -1,12 +1,41 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
license: mit
|
| 9 |
-
short_description:
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: SimpleAI-259M
|
| 3 |
+
emoji: ⚡
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
license: mit
|
| 9 |
+
short_description: A compact, general-purpose LLM for reasoning and logic.
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# ⚡ SimpleAI-259M
|
| 13 |
+
|
| 14 |
+
**SimpleAI-259M** is a high-performance Large Language Model (LLM). It is the result of a targeted SFT (Supervised Fine-Tuning) run focused on unlocking reasoning, numeracy, and character-level precision.
|
| 15 |
+
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
## 🚀 SFT Training Report (Step 971)
|
| 19 |
+
Final Loss: **1.0419**
|
| 20 |
+
|
| 21 |
+
### 📊 Benchmark Performance
|
| 22 |
+
| Category | Score | Status |
|
| 23 |
+
| :--- | :--- | :--- |
|
| 24 |
+
| **ARC-Easy** | **35.19%** | 📈 Reasoning Gain |
|
| 25 |
+
| **MMLU** | **30.96%** | ✅ General Knowledge |
|
| 26 |
+
| **GSM8K (Math)** | **12.50%** | 🚀 Numeracy Breakthrough |
|
| 27 |
+
| **SpellingBee** | **100.00%** | 🏆 Perfect Character Accuracy |
|
| 28 |
+
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
## 🔮 Future Roadmap: SimpleAI Series
|
| 32 |
+
1. **SimpleAI-D12-v2:** Enhanced dataset targeting sub-1.0 training loss.
|
| 33 |
+
2. **SimpleAI-D24:** A deeper 24-layer variant for multi-step logical deduction.
|
| 34 |
+
3. **SimpleAI-Omni:** Multimodal integration for cross-modal reasoning.
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
## 🧑💻 Usage
|
| 39 |
+
The model uses standard system tags for interaction:
|
| 40 |
+
- `<|user_start|>` / `<|user_end|>`
|
| 41 |
+
- `<|assistant_start|>`
|
app.py
CHANGED
|
@@ -4,10 +4,8 @@ import gradio as gr
|
|
| 4 |
from nanochat.gpt import GPT, GPTConfig
|
| 5 |
from nanochat.tokenizer import RustBPETokenizer
|
| 6 |
|
| 7 |
-
#
|
| 8 |
TOKENIZER_DIR = "."
|
| 9 |
-
|
| 10 |
-
print(f"--- System Initialization ---")
|
| 11 |
tokenizer = RustBPETokenizer.from_directory(TOKENIZER_DIR)
|
| 12 |
|
| 13 |
# Map Special Tokens
|
|
@@ -36,23 +34,17 @@ model.eval()
|
|
| 36 |
def predict(message, history):
|
| 37 |
try:
|
| 38 |
# 1. Stateless Prompt Construction
|
| 39 |
-
# We completely ignore 'history' to prevent the model from repeating old answers.
|
| 40 |
tokens = [tokenizer.bos_token_id]
|
| 41 |
-
|
| 42 |
-
# We only encode the CURRENT message
|
| 43 |
user_content = str(message).strip()
|
| 44 |
tokens.extend([tokenizer.user_start_id] + tokenizer.encode(user_content) + [tokenizer.user_end_id])
|
| 45 |
-
|
| 46 |
-
# Add the signal for the assistant to start talking
|
| 47 |
tokens.append(tokenizer.assistant_start_id)
|
| 48 |
|
| 49 |
# 2. Streaming Generation
|
| 50 |
with torch.no_grad():
|
| 51 |
-
# Pass as a Python list to satisfy the nanochat engine assertion
|
| 52 |
output = model.generate(
|
| 53 |
tokens,
|
| 54 |
max_tokens=512,
|
| 55 |
-
temperature=0.
|
| 56 |
top_k=40
|
| 57 |
)
|
| 58 |
|
|
@@ -61,23 +53,35 @@ def predict(message, history):
|
|
| 61 |
token_id = token if isinstance(token, int) else token.item()
|
| 62 |
char = tokenizer.decode([token_id])
|
| 63 |
|
| 64 |
-
# Check for stop tags in the character stream
|
| 65 |
if any(tag in char for tag in ["<|assistant_end|>", "<|end|>", "<|user_start|>"]):
|
| 66 |
break
|
| 67 |
|
| 68 |
generated_text += char
|
| 69 |
-
# Yielding the text as it generates for that "real-time" feel
|
| 70 |
yield generated_text.strip()
|
| 71 |
|
| 72 |
except Exception as e:
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
# Launching with Gradio 6.0 compatibility
|
| 77 |
demo = gr.ChatInterface(
|
| 78 |
fn=predict,
|
| 79 |
-
title="⚡ SimpleAI",
|
| 80 |
-
description="Fast. Focused. Simple"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
)
|
| 82 |
|
| 83 |
if __name__ == "__main__":
|
|
|
|
| 4 |
from nanochat.gpt import GPT, GPTConfig
|
| 5 |
from nanochat.tokenizer import RustBPETokenizer
|
| 6 |
|
| 7 |
+
# --- System Initialization ---
|
| 8 |
TOKENIZER_DIR = "."
|
|
|
|
|
|
|
| 9 |
tokenizer = RustBPETokenizer.from_directory(TOKENIZER_DIR)
|
| 10 |
|
| 11 |
# Map Special Tokens
|
|
|
|
| 34 |
def predict(message, history):
|
| 35 |
try:
|
| 36 |
# 1. Stateless Prompt Construction
|
|
|
|
| 37 |
tokens = [tokenizer.bos_token_id]
|
|
|
|
|
|
|
| 38 |
user_content = str(message).strip()
|
| 39 |
tokens.extend([tokenizer.user_start_id] + tokenizer.encode(user_content) + [tokenizer.user_end_id])
|
|
|
|
|
|
|
| 40 |
tokens.append(tokenizer.assistant_start_id)
|
| 41 |
|
| 42 |
# 2. Streaming Generation
|
| 43 |
with torch.no_grad():
|
|
|
|
| 44 |
output = model.generate(
|
| 45 |
tokens,
|
| 46 |
max_tokens=512,
|
| 47 |
+
temperature=0.75,
|
| 48 |
top_k=40
|
| 49 |
)
|
| 50 |
|
|
|
|
| 53 |
token_id = token if isinstance(token, int) else token.item()
|
| 54 |
char = tokenizer.decode([token_id])
|
| 55 |
|
|
|
|
| 56 |
if any(tag in char for tag in ["<|assistant_end|>", "<|end|>", "<|user_start|>"]):
|
| 57 |
break
|
| 58 |
|
| 59 |
generated_text += char
|
|
|
|
| 60 |
yield generated_text.strip()
|
| 61 |
|
| 62 |
except Exception as e:
|
| 63 |
+
yield f"⚠️ System Error: {str(e)}"
|
| 64 |
+
|
| 65 |
+
# --- UI Customization ---
|
| 66 |
+
custom_theme = gr.themes.Soft(
|
| 67 |
+
primary_hue="indigo",
|
| 68 |
+
secondary_hue="slate",
|
| 69 |
+
).set(
|
| 70 |
+
button_primary_background_fill="*primary_600",
|
| 71 |
+
button_primary_text_color="white",
|
| 72 |
+
)
|
| 73 |
|
|
|
|
| 74 |
demo = gr.ChatInterface(
|
| 75 |
fn=predict,
|
| 76 |
+
title="⚡ SimpleAI-259M",
|
| 77 |
+
description="**Fast. Focused. Simple.** A lightweight general intelligence model optimized for reasoning and logic.",
|
| 78 |
+
theme=custom_theme,
|
| 79 |
+
examples=[
|
| 80 |
+
"If Sarah has 10 pencils and gives 4 to her friend, how many pencils does she have left?",
|
| 81 |
+
"Write a Python function to calculate the area of a circle.",
|
| 82 |
+
"Which part of a plant is usually responsible for making food using sunlight?",
|
| 83 |
+
],
|
| 84 |
+
type="messages"
|
| 85 |
)
|
| 86 |
|
| 87 |
if __name__ == "__main__":
|