From 96372d338ec2c3c8f502645292b824ded3986263 Mon Sep 17 00:00:00 2001 From: Carlos Crespo Macaya Date: Fri, 9 Jan 2026 14:48:51 +0100 Subject: [PATCH] feat: polish UI with custom design system and add profile links - Add custom CSS with Outfit + JetBrains Mono fonts, design tokens - Add branded header with gradient logo and feature badges - Fix label styling to not look like buttons - Add Key Concepts tab explaining TTT innovation - Add incremental integration diagrams (Vanilla -> RAG -> Neural Memory -> Docker) - Remove confusing Playground tab - Add polished footer with all profile links (GitHub, LinkedIn, Kaggle 2x gold medals, HuggingFace, Google Scholar, Personal website) Co-Authored-By: Claude Opus 4.5 --- deploy/huggingface/app.py | 735 +++++++++++++++++++++++++++++++++++--- 1 file changed, 678 insertions(+), 57 deletions(-) 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

+
+ + +
+ + πŸ™ GitHub + + + πŸ’Ό LinkedIn + + + πŸ“Š Kaggle 2Γ—πŸ₯‡ + + + πŸ€— HuggingFace + + + πŸŽ“ Scholar + + + 🌐 Website + +
+
+ +
+

+ 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 +
+
    +
  1. Convert facts to vectors (embeddings)
  2. +
  3. Store in vector database
  4. +
  5. On query, find similar vectors
  6. +
  7. Pass retrieved docs to LLM
  8. +
+
+
+ βœ“ Simple + βœ“ Scalable + βœ— No patterns + βœ— Grows +
+
+ + +
+

+ 🧠 Solution B: Neural Memory (Learning) +

+

+ Learn information into neural weights. Memory IS the network. +

+
+
+ HOW +
+
    +
  1. Encode fact as tensor
  2. +
  3. Forward pass through neural net
  4. +
  5. Compute prediction error (surprise)
  6. +
  7. Update weights via gradient descent
  8. +
+
+
+ βœ“ 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) +

+
+
+
πŸ‘€
+
Query
+
+
β†’
+
+
πŸ”
+
Retriever
+
keyword match
+
+
β†’
+
+
πŸ—ƒοΈ
+
Vector DB
+
top-k docs
+
+
β†’
+
+
πŸ“‹
+
Context
+
prompt injection
+
+
β†’
+
+
πŸ€–
+
LLM
+
+
+
+
+ βœ“ External memory storage +
+
+ βœ— No pattern learning +
+
+
+''' + +NEURAL_MEMORY_INTEGRATION_DIAGRAM_HTML = ''' +
+

+ Step 2b + Adding Neural Memory (Test-Time Training) +

+
+
+
πŸ‘€
+
Query
+
+
β†’
+
+
🧠
+
Neural Memory
+
TTT Module
+
+
β†’
+
+
πŸ“Š
+
Patterns
+
+ surprise
+
+
β†’
+
+
πŸ“‹
+
Rich Context
+
all facts + hints
+
+
β†’
+
+
πŸ€–
+
LLM
+
+
+
+
+ βœ“ 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__":