diff --git a/deploy/huggingface/app.py b/deploy/huggingface/app.py
index 62ea873..bdd0f05 100644
--- a/deploy/huggingface/app.py
+++ b/deploy/huggingface/app.py
@@ -25,6 +25,360 @@
matplotlib.use("Agg")
+# =============================================================================
+# CUSTOM CSS FOR POLISHED UI
+# =============================================================================
+
+CUSTOM_CSS = """
+@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Outfit:wght@300;400;500;600;700&display=swap');
+
+:root {
+ --neural-cyan: #00d4ff;
+ --neural-cyan-glow: rgba(0, 212, 255, 0.3);
+ --rag-orange: #ff8c42;
+ --purple-accent: #a855f7;
+ --bg-deep: #0a0a1a;
+ --bg-card: #12122a;
+ --bg-card-hover: #1a1a3a;
+ --text-primary: #f8fafc;
+ --text-secondary: #94a3b8;
+ --border-subtle: rgba(148, 163, 184, 0.1);
+ --success-green: #22c55e;
+}
+
+/* Global font settings */
+.gradio-container {
+ font-family: 'Outfit', system-ui, -apple-system, sans-serif !important;
+ background: linear-gradient(180deg, var(--bg-deep) 0%, #0f0f23 100%) !important;
+}
+
+/* Headings */
+.gradio-container h1, .gradio-container h2, .gradio-container h3, .gradio-container h4 {
+ font-family: 'Outfit', sans-serif !important;
+ font-weight: 600 !important;
+ letter-spacing: -0.02em !important;
+}
+
+/* Code and monospace */
+.gradio-container code, .gradio-container pre {
+ font-family: 'JetBrains Mono', monospace !important;
+}
+
+/* Tab styling */
+.tabs > .tab-nav > button {
+ font-family: 'Outfit', sans-serif !important;
+ font-weight: 500 !important;
+ padding: 12px 24px !important;
+ border-radius: 8px 8px 0 0 !important;
+ transition: all 0.3s ease !important;
+}
+
+.tabs > .tab-nav > button.selected {
+ background: linear-gradient(135deg, var(--neural-cyan) 0%, var(--purple-accent) 100%) !important;
+ color: white !important;
+}
+
+/* Button styling */
+.gr-button {
+ font-family: 'Outfit', sans-serif !important;
+ font-weight: 500 !important;
+ border-radius: 8px !important;
+ transition: all 0.3s ease !important;
+}
+
+.gr-button-primary {
+ background: linear-gradient(135deg, var(--neural-cyan) 0%, var(--purple-accent) 100%) !important;
+ border: none !important;
+}
+
+.gr-button-primary:hover {
+ transform: translateY(-2px) !important;
+ box-shadow: 0 8px 25px var(--neural-cyan-glow) !important;
+}
+
+.gr-button-secondary {
+ background: transparent !important;
+ border: 1px solid var(--text-secondary) !important;
+ color: var(--text-secondary) !important;
+}
+
+.gr-button-secondary:hover {
+ border-color: var(--neural-cyan) !important;
+ color: var(--neural-cyan) !important;
+}
+
+/* FIX: Labels should NOT look like buttons */
+.gr-textbox label, .gr-plot label, .gr-dropdown label, .gr-checkbox label,
+label.svelte-1gfkn6j, .label-wrap, span.svelte-1gfkn6j {
+ background: transparent !important;
+ border: none !important;
+ padding: 0 !important;
+ box-shadow: none !important;
+ font-weight: 500 !important;
+ color: var(--text-secondary) !important;
+ cursor: default !important;
+}
+
+/* Ensure label containers don't have button styling */
+.gr-form > label, .gr-box > label, div[data-testid="textbox"] > label {
+ background: none !important;
+ border: none !important;
+ box-shadow: none !important;
+}
+
+/* Input styling */
+.gr-textbox textarea, .gr-textbox input {
+ font-family: 'Outfit', sans-serif !important;
+ background: var(--bg-card) !important;
+ border: 1px solid var(--border-subtle) !important;
+ border-radius: 8px !important;
+ transition: all 0.3s ease !important;
+}
+
+.gr-textbox textarea:focus, .gr-textbox input:focus {
+ border-color: var(--neural-cyan) !important;
+ box-shadow: 0 0 0 3px var(--neural-cyan-glow) !important;
+}
+
+/* Card/box styling */
+.gr-box, .gr-panel {
+ background: var(--bg-card) !important;
+ border: 1px solid var(--border-subtle) !important;
+ border-radius: 12px !important;
+}
+
+/* Plot styling */
+.gr-plot {
+ background: var(--bg-card) !important;
+ border-radius: 12px !important;
+ border: 1px solid var(--border-subtle) !important;
+}
+
+/* Markdown styling */
+.prose {
+ color: var(--text-primary) !important;
+}
+
+.prose h3, .prose h4 {
+ color: var(--neural-cyan) !important;
+}
+
+/* Smooth animations */
+* {
+ transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
+}
+"""
+
+HEADER_HTML = '''
+
+
+
+
+
+
+
+
π§
+
+
Docker Neural Memory
+
Real Test-Time Training β Not a Simulation
+
+
+
+
+
+ β‘ PyTorch TTT
+ π³ Docker Native
+ π MCP Server
+ π Titans Architecture
+
+
+
+'''
+
+FOOTER_HTML = '''
+
+
+
+
+
Built by
+
Carlos Crespo Macaya
+
AI Engineer β GenAI Systems & Applied MLOps
+
+
+
+
+
+
+
+
+ Docker Neural Memory β Containerized AI memory with real test-time training
+
+
+
+'''
+
# =============================================================================
# HUGGINGFACE INFERENCE CLIENT
# =============================================================================
@@ -843,6 +1197,309 @@ def get_memory_stats() -> str:
"""
+# =============================================================================
+# KEY CONCEPTS (New Educational Tab)
+# =============================================================================
+
+KEY_CONCEPTS_HTML = '''
+
+
+
+
+ β The Problem: LLMs Have No Memory
+
+
+
+
Every API call to an LLM starts fresh:
+
+
// Call 1
+
User: "My name is Carlos"
+
AI: "Nice to meet you, Carlos!"
+
+
// Call 2 (new session)
+
User: "What's my name?"
+
AI: "I don't know your name."
+
+
+
+
The model's weights are frozen after training:
+
+ - Can't learn new information
+ - Can't remember past conversations
+ - Can't adapt to user preferences
+ - Knowledge is static (training cutoff)
+
+
+
+
+
+
+
+ Two Solutions to Add Memory
+
+
+
+
+
+
+ π Solution A: RAG (Retrieval)
+
+
+ Store information externally, retrieve relevant pieces when needed.
+
+
+
+ HOW
+
+
+ - Convert facts to vectors (embeddings)
+ - Store in vector database
+ - On query, find similar vectors
+ - Pass retrieved docs to LLM
+
+
+
+ β Simple
+ β Scalable
+ β No patterns
+ β Grows
+
+
+
+
+
+
+ π§ Solution B: Neural Memory (Learning)
+
+
+ Learn information into neural weights. Memory IS the network.
+
+
+
+ HOW
+
+
+ - Encode fact as tensor
+ - Forward pass through neural net
+ - Compute prediction error (surprise)
+ - Update weights via gradient descent
+
+
+
+ β Learns patterns
+ β Fixed size
+ β Can infer
+ β Complex
+
+
+
+
+
+
+
+ β‘ The Innovation: Test-Time Training (TTT)
+
+
+
+
Traditional Training
+
+ Train once β Freeze weights β Deploy
+ Model can't learn after deployment
+
+
+
+
Test-Time Training (Titans)
+
+ Deploy β Continue learning β Weights update
+ Model learns from every interaction
+
+
+
+
+
+ This demo implements real TTT: When you add a fact, actual PyTorch gradients flow and actual neural network weights change. This is not a simulationβit's the Titans architecture from Google's December 2024 paper.
+
+
+
+
+'''
+
+# =============================================================================
+# INCREMENTAL INTEGRATION DIAGRAMS
+# =============================================================================
+
+VANILLA_LLM_DIAGRAM_HTML = '''
+
+
+ Step 1
+ Vanilla LLM (The Problem)
+
+
+
+
π€
+
User Query
+
"What's my preference?"
+
+
β
+
+
π€
+
LLM
+
Frozen weights
+
+
β
+
+
β
+
No Memory
+
"I don't know"
+
+
+
+ β οΈ LLM has no way to remember user-specific information between sessions
+
+
+'''
+
+RAG_INTEGRATION_DIAGRAM_HTML = '''
+
+
+ Step 2a
+ Adding RAG (Retrieval-Augmented Generation)
+
+
+
+
β
+
+
π
+
Retriever
+
keyword match
+
+
β
+
+
ποΈ
+
Vector DB
+
top-k docs
+
+
β
+
+
π
+
Context
+
prompt injection
+
+
β
+
+
+
+
+ β External memory storage
+
+
+ β No pattern learning
+
+
+
+'''
+
+NEURAL_MEMORY_INTEGRATION_DIAGRAM_HTML = '''
+
+
+ Step 2b
+ Adding Neural Memory (Test-Time Training)
+
+
+
+
β
+
+
π§
+
Neural Memory
+
TTT Module
+
+
β
+
+
π
+
Patterns
+
+ surprise
+
+
β
+
+
π
+
Rich Context
+
all facts + hints
+
+
β
+
+
+
+
+ β Learns patterns
+
+
+ β Fixed memory size
+
+
+ β Can infer/predict
+
+
+
+'''
+
+DOCKER_DEPLOYMENT_DIAGRAM_HTML = '''
+
+
+ Step 3
+ Docker Deployment (Production Ready)
+
+
+
+
+
+ π³
+ Docker Container
+
+
+
+
π§ Neural Memory
+
PyTorch TTT Module
+
+
+
π MCP Server
+
Claude Desktop Integration
+
+
+
π HTTP API
+
REST Endpoints
+
+
+
+
+
+
β
+
+
πΎ
+
Volume
+
Checkpoints
+
+
+
+
+
+ Why Docker? Learned neural weights persist across container restarts via Docker volumes. Deploy anywhere with identical behavior. Version control your AI's memory state like Git commits.
+
+
+
+'''
+
# =============================================================================
# DOCKER ECOSYSTEM INTEGRATION
# =============================================================================
@@ -1505,14 +2162,9 @@ def restore(name: str) -> str:
# GRADIO INTERFACE
# =============================================================================
-with gr.Blocks(title="Docker Neural Memory", theme=gr.themes.Soft()) as demo:
- gr.Markdown("""
- # Docker Neural Memory
- ## Real Test-Time Training - Not a Simulation
-
- This demo runs **actual PyTorch** code. When you observe content,
- real gradients flow and real weights update.
- """)
+with gr.Blocks(title="Docker Neural Memory", theme=gr.themes.Soft(), css=CUSTOM_CSS) as demo:
+ # Branded header
+ gr.HTML(HEADER_HTML)
with gr.Tabs():
# TAB 1: Comparison Demo (NEW - Main Feature)
@@ -1631,67 +2283,36 @@ def restore(name: str) -> str:
# Architecture Summary
gr.Markdown(ARCHITECTURE_SUMMARY_MD)
- # TAB 3: Neural Memory Playground (original Live Demo)
- with gr.TabItem("Neural Memory Playground"):
- gr.Markdown("### Watch Real Neural Learning")
-
- with gr.Row():
- with gr.Column(scale=1):
- observe_input = gr.Textbox(
- label="Content to Observe",
- placeholder="Enter text to trigger real learning...",
- lines=3,
- )
- observe_btn = gr.Button("Observe (Learn)", variant="primary", size="lg")
- observe_output = gr.Markdown()
+ # TAB 3: Key Concepts
+ with gr.TabItem("Key Concepts"):
+ gr.HTML(KEY_CONCEPTS_HTML)
- with gr.Column(scale=1):
- weights_plot = gr.Plot(label="Neural Weights (Real PyTorch)")
+ # TAB 4: Integration & Docker
+ with gr.TabItem("Integration & Docker"):
+ gr.Markdown("## How Memory Modules Integrate with LLMs")
+ gr.Markdown("Follow this incremental explanation to understand how both RAG and Neural Memory attach to a vanilla LLM.")
- history_plot = gr.Plot(label="Learning History")
+ # Step 1: Vanilla LLM
+ gr.HTML(VANILLA_LLM_DIAGRAM_HTML)
- observe_btn.click(
- observe_content,
- inputs=[observe_input],
- outputs=[observe_output, weights_plot, history_plot],
- )
+ # Step 2a: RAG Integration
+ gr.HTML(RAG_INTEGRATION_DIAGRAM_HTML)
- gr.Markdown("---")
+ # Step 2b: Neural Memory Integration
+ gr.HTML(NEURAL_MEMORY_INTEGRATION_DIAGRAM_HTML)
- with gr.Row():
- with gr.Column():
- surprise_input = gr.Textbox(
- label="Check Surprise (No Learning)",
- placeholder="Check novelty without updating weights...",
- )
- surprise_btn = gr.Button("Check Surprise")
- surprise_output = gr.Markdown()
- surprise_btn.click(check_surprise, inputs=[surprise_input], outputs=[surprise_output])
-
- with gr.Column():
- stats_btn = gr.Button("Get Memory Stats")
- stats_output = gr.Markdown()
- stats_btn.click(get_memory_stats, outputs=[stats_output])
-
- reset_btn = gr.Button("Reset Memory", variant="secondary")
- reset_output = gr.Markdown()
- reset_btn.click(reset_memory, outputs=[reset_output])
+ # Step 3: Docker Deployment
+ gr.HTML(DOCKER_DEPLOYMENT_DIAGRAM_HTML)
- # TAB 4: Docker Integration
- with gr.TabItem("Docker Integration"):
+ # Docker details
gr.Markdown(DOCKER_INTEGRATION_MD)
# TAB 5: About
with gr.TabItem("About"):
gr.Markdown(ABOUT_MD)
- gr.Markdown("""
- ---
- *Docker Neural Memory - Containerized AI memory with real test-time training*
-
- [GitHub](https://github.com/macayaven/docker-neural-memory) |
- [Contact](mailto:macayaven@gmail.com)
- """)
+ # Polished footer with profile links
+ gr.HTML(FOOTER_HTML)
if __name__ == "__main__":