Spaces:
Running
Running
Download index.html from YVYRU/rocketflim: direct link, hf CLI and curl.
- Browser
- Download file 22 kB
-
https://huggingface.co/spaces/YVYRU/rocketflim/resolve/main/index.html
- Command line
-
hf download hf://spaces/YVYRU/rocketflim/index.html
-
curl -L -o index.html https://huggingface.co/spaces/YVYRU/rocketflim/resolve/main/index.html
22 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Syntactic Bunker - Context Compression Demo</title> | |
| <link rel="icon" type="image/x-icon" href="/static/favicon.ico"> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script> | |
| tailwind.config = { | |
| theme: { | |
| extend: { | |
| colors: { | |
| cyberblue: '#00d9ff', | |
| cyberpurple: '#a855f7', | |
| darkbg: '#0a0a18', | |
| panelbg: '#121230', | |
| } | |
| } | |
| } | |
| } | |
| </script> | |
| <link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet"> | |
| <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| <style> | |
| @import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;600&family=Orbitron:wght@400;600&display=swap'); | |
| body { | |
| font-family: 'JetBrains Mono', monospace; | |
| background-color: #0a0a18; | |
| color: #ffffff; | |
| overflow-x: hidden; | |
| } | |
| .cyber-gradient { | |
| background: linear-gradient(135deg, #00d9ff 0%, #a855f7 100%); | |
| } | |
| .cyber-border { | |
| border: 1px solid rgba(0, 217, 255, 0.3); | |
| box-shadow: 0 0 15px rgba(0, 217, 255, 0.2); | |
| } | |
| .cyber-glow { | |
| box-shadow: 0 0 20px rgba(0, 217, 255, 0.4); | |
| } | |
| .matrix-cell { | |
| width: 40px; | |
| height: 40px; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| font-size: 12px; | |
| border: 1px solid rgba(168, 85, 247, 0.2); | |
| transition: all 0.3s ease; | |
| background-color: rgba(18, 18, 48, 0.5); | |
| } | |
| .matrix-cell:hover { | |
| background: rgba(168, 85, 247, 0.1); | |
| transform: scale(1.1); | |
| } | |
| .helix-animation { | |
| animation: rotate 2s linear infinite; | |
| } | |
| @keyframes rotate { | |
| from { transform: rotate(0deg); } | |
| to { transform: rotate(360deg); } | |
| } | |
| .typewriter { | |
| overflow: hidden; | |
| border-right: .15em solid #00d9ff; | |
| white-space: nowrap; | |
| animation: typing 3.5s steps(40, end), blink-caret .75s step-end infinite; | |
| width: 0; | |
| } | |
| /* Improved accessibility for focus states */ | |
| button:focus, input:focus, textarea:focus { | |
| outline: 2px solid #00d9ff; | |
| outline-offset: 2px; | |
| } | |
| /* Sample text button */ | |
| .sample-btn { | |
| background: linear-gradient(135deg, #a855f7, #00d9ff); | |
| transition: all 0.3s ease; | |
| } | |
| .sample-btn:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 10px 25px rgba(168, 85, 247, 0.3); | |
| } | |
| /* Error message style */ | |
| .error-message { | |
| color: #ef4444; | |
| font-size: 0.875rem; | |
| margin-top: 0.5rem; | |
| } | |
| @keyframes typing { | |
| from { width: 0 } | |
| to { width: 100% } | |
| } | |
| @keyframes blink-caret { | |
| from, to { border-color: transparent } | |
| 50% { border-color: #00d9ff; } | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-darkbg min-h-screen"> | |
| <header class="py-6 border-b cyber-border"> | |
| <div class="container mx-auto px-6"> | |
| <h1 class="text-3xl md:text-4xl font-bold text-center cyber-gradient bg-clip-text text-transparent" data-aos="fade-down"> | |
| SYNTACTIC BUNKER | |
| </h1> | |
| <p class="text-center text-cyberblue mt-2" data-aos="fade-down" data-aos-delay="200"> | |
| Context Compression Demo (Real Backend Integration) | |
| </p> | |
| </div> | |
| </header> | |
| <main class="container mx-auto px-4 py-8"> | |
| <div class="grid grid-cols-1 lg:grid-cols-2 gap-8"> | |
| <!-- LEFT PANEL - Input Section --> | |
| <div class="bg-panelbg rounded-xl p-6 cyber-border" data-aos="fade-right"> | |
| <h2 class="text-xl font-semibold text-cyberblue mb-4 flex items-center"> | |
| <i data-feather="message-square" class="mr-2"></i> | |
| Conversation History Input | |
| </h2> | |
| <div class="relative"> | |
| <textarea | |
| id="inputText" | |
| class="w-full h-[400px] bg-[#1a1a3a] border border-cyberblue/30 rounded-lg p-4 text-white resize-none focus:outline-none focus:ring-2 focus:ring-cyberblue" | |
| placeholder="Paste your conversation history here... Example: 'User: Hello, how are you? AI: I'm great, thanks! What can I help with today?'" | |
| aria-label="Conversation history input" | |
| ></textarea> | |
| <div class="absolute bottom-3 right-3 text-xs text-gray-400"> | |
| <span id="charCount">0</span> characters | |
| </div> | |
| </div> | |
| <div class="mt-6 flex justify-center"> | |
| <button | |
| id="compressBtn" | |
| class="cyber-glow bg-cyberblue text-white px-8 py-3 rounded-lg font-semibold hover:bg-cyan-600 transition-all flex items-center" | |
| onclick="compressText()" | |
| > | |
| <i data-feather="cpu" class="mr-2"></i> | |
| Compress to State Vector | |
| </button> | |
| </div> | |
| <div id="processingAnimation" class="hidden mt-6 flex justify-center items-center"> | |
| <div class="helix-animation text-cyberblue"> | |
| <i data-feather="loader" class="w-12 h-12"></i> | |
| </div> | |
| <span class="ml-3 text-cyberblue">Processing...</span> | |
| </div> | |
| </div> | |
| <!-- RIGHT PANEL - Output Section --> | |
| <div class="bg-panelbg rounded-xl p-6 cyber-border" data-aos="fade-left"> | |
| <h2 class="text-xl font-semibold text-cyberpurple mb-4 flex items-center"> | |
| <i data-feather="database" class="mr-2"></i> | |
| Compressed State Vector | |
| </h2> | |
| <div class="grid grid-cols-8 gap-1 mb-6 bg-[#1a1a3a] p-3 rounded-lg"> | |
| <!-- 8x8 Matrix Grid --> | |
| <div id="matrixGrid" class="grid grid-cols-8 gap-1"> | |
| <!-- Matrix cells will be generated dynamically --> | |
| </div> | |
| </div> | |
| <div class="mb-6 text-center"> | |
| <div id="compressionRatio" class="text-3xl font-bold text-cyberpurple"> | |
| 0.0% compression | |
| </div> | |
| <div class="text-sm text-gray-400 mt-1">Information density achieved</div> | |
| </div> | |
| <div class="mb-6 p-4 bg-[#1a1a3a] rounded-lg"> | |
| <h3 class="text-cyberblue mb-2 font-semibold">VRAM Savings</h3> | |
| <div id="vramSavings" class="text-lg"> | |
| Original: 0.0GB → Compressed: 0.0GB | |
| </div> | |
| </div> | |
| <div class="mb-4"> | |
| <h3 class="text-cyberpurple mb-2 font-semibold">Query Interface</h3> | |
| <div class="flex"> | |
| <input | |
| type="text" | |
| id="queryInput" | |
| class="flex-grow bg-[#1a1a3a] border border-cyberpurple/30 rounded-l-lg p-3 text-white focus:outline-none" | |
| placeholder="Ask about the original text..." | |
| aria-label="Query input" | |
| > | |
| <button | |
| class="bg-cyberpurple text-white px-4 rounded-r-lg hover:bg-purple-600 transition-all disabled:opacity-50 disabled:cursor-not-allowed" | |
| id="queryBtn" | |
| aria-label="Ask question" | |
| > | |
| <i data-feather="search"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <div id="responseArea" class="bg-[#1a1a3a] p-4 rounded-lg min-h-[100px]"> | |
| <p class="text-gray-400 italic">Responses will appear here based on the compressed vector...</p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- BOTTOM: Technical Explanation Panel --> | |
| <div class="mt-12 bg-panelbg rounded-xl p-6 cyber-border" data-aos="fade-up"> | |
| <h2 class="text-xl font-semibold text-center mb-6 cyber-gradient bg-clip-text text-transparent"> | |
| Technical Specifications | |
| </h2> | |
| <div class="space-y-4"> | |
| <!-- How it Works --> | |
| <div class="collapse-container"> | |
| <button class="collapse-btn w-full text-left p-4 bg-[#1a1a3a] rounded-lg flex justify-between items-center focus:outline-none" aria-expanded="false" aria-controls="how-it-works"> | |
| <span class="font-semibold text-cyberblue">How It Works (TF-IDF + Dimensionality Reduction)</span> | |
| <i data-feather="chevron-down" class="collapse-icon transition-transform duration-300"></i> | |
| </button> | |
| <div id="how-it-works" class="collapse-content hidden p-4 bg-[#1a1a3a] rounded-b-lg mt-1"> | |
| <p>Our compression algorithm uses Term Frequency-Inverse Document Frequency (TF-IDF) to identify the most semantically significant tokens in the conversation history. Through principal component analysis and neural embeddings, we reduce dimensionality from O(n) to a fixed 64-dimensional state vector while preserving semantic relationships. Now powered by a real Python backend using scikit-learn!</p> | |
| </div> | |
| </div> | |
| <!-- VRAM Efficiency Theory --> | |
| <div class="collapse-container"> | |
| <button class="collapse-btn w-full text-left p-4 bg-[#1a1a3a] rounded-lg flex justify-between items-center"> | |
| <span class="font-semibold text-cyberpurple">VRAM Efficiency Theory (O(n²) vs O(1) Scaling)</span> | |
| <i data-feather="chevron-down" class="collapse-icon"></i> | |
| </button> | |
| <div class="collapse-content hidden p-4 bg-[#1a1a3a] rounded-b-lg mt-1"> | |
| <p>Traditional attention mechanisms scale quadratically (O(n²)) with context length, making long conversations prohibitively expensive. Our state vector approach maintains constant memory usage (O(1)) regardless of original context size, enabling efficient processing of extensive dialogue histories without VRAM constraints.</p> | |
| </div> | |
| </div> | |
| <!-- Information Preservation --> | |
| <div class="collapse-container"> | |
| <button class="collapse-btn w-full text-left p-4 bg-[#1a1a3a] rounded-lg flex justify-between items-center"> | |
| <span class="font-semibold text-cyberblue">Information Preservation (Shannon vs Gödelian Concepts)</span> | |
| <i data-feather="chevron-down" class="collapse-icon"></i> | |
| </button> | |
| <div class="collapse-content hidden p-4 bg-[#1a1a3a] rounded-b-lg mt-1"> | |
| <p>While Shannon information theory focuses on probabilistic entropy, our approach incorporates Gödelian concepts of meaningful information preservation. The compression maintains not just statistical patterns but logical relationships and semantic coherence, allowing accurate reconstruction of conversation context from the minimal state vector.</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </main> | |
| <footer class="py-6 mt-12 border-t cyber-border"> | |
| <div class="container mx-auto px-6 text-center text-sm text-gray-400"> | |
| <p>Syntactic Bunker © 2023 - Context Compression Technology Demo</p> | |
| </div> | |
| </footer> | |
| <script> | |
| // Backend endpoint configuration | |
| const BACKEND_URL = 'http://localhost:5000/compress'; // Adjust if needed | |
| // Global variables | |
| let isCompressed = false; | |
| let currentVector = []; | |
| // Initialize animations and icons | |
| AOS.init({ | |
| duration: 800, | |
| once: true | |
| }); | |
| // Initialize matrix grid | |
| function initializeMatrix() { | |
| const matrixGrid = document.getElementById('matrixGrid'); | |
| matrixGrid.innerHTML = ''; | |
| for (let i = 0; i < 64; i++) { | |
| const cell = document.createElement('div'); | |
| cell.className = 'matrix-cell'; | |
| cell.textContent = '0.00'; | |
| cell.id = `matrix-cell-${i}`; | |
| cell.setAttribute('role', 'gridcell'); | |
| cell.setAttribute('aria-label', `Dimension ${i + 1}`); | |
| matrixGrid.appendChild(cell); | |
| } | |
| matrixGrid.setAttribute('role', 'grid'); | |
| matrixGrid.setAttribute('aria-label', 'Compressed state vector matrix'); | |
| } | |
| // Update character count | |
| function updateCharCount() { | |
| const text = document.getElementById('inputText').value; | |
| document.getElementById('charCount').textContent = text.length; | |
| } | |
| // Show error message | |
| function showError(message) { | |
| const errorEl = document.getElementById('errorMessage'); | |
| errorEl.textContent = message; | |
| errorEl.classList.remove('hidden'); | |
| } | |
| // Hide error message | |
| function hideError() { | |
| document.getElementById('errorMessage').classList.add('hidden'); | |
| } | |
| // Load sample text | |
| function loadSample() { | |
| const sampleText = `User: Tell me about AI context compression. | |
| AI: Context compression is a technique to reduce the memory footprint of long conversations in large language models. It preserves key semantic information while discarding redundancy. | |
| User: How does it work? | |
| AI: It typically involves summarization, key-value extraction, or embedding-based reduction to a fixed-size vector. | |
| User: What's the benefit for VRAM? | |
| AI: It allows handling much longer contexts without exceeding GPU memory limits, scaling from O(n²) to O(1) in attention computation.`; | |
| document.getElementById('inputText').value = sampleText; | |
| updateCharCount(); | |
| hideError(); | |
| } | |
| // Compress text with backend | |
| async function compressText() { | |
| const inputText = document.getElementById('inputText').value.trim(); | |
| if (!inputText) { | |
| showError('Please enter some conversation text first'); | |
| return; | |
| } | |
| hideError(); | |
| // Show processing animation | |
| const processingEl = document.getElementById('processingAnimation'); | |
| const btn = document.getElementById('compressBtn'); | |
| processingEl.classList.remove('hidden'); | |
| btn.disabled = true; | |
| isCompressed = false; | |
| try { | |
| const response = await fetch(BACKEND_URL, { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| body: JSON.stringify({ text: inputText }) | |
| }); | |
| if (!response.ok) { | |
| throw new Error(`Backend error: ${response.status}`); | |
| } | |
| const data = await response.json(); | |
| currentVector = data.vector; | |
| // Update matrix display | |
| currentVector.forEach((value, index) => { | |
| const cell = document.getElementById(`matrix-cell-${index}`); | |
| cell.style.transition = 'all 0.5s ease'; | |
| cell.textContent = value.toFixed(2); | |
| cell.style.color = parseFloat(value) > 0 ? '#00d9ff' : '#a855f7'; | |
| }); | |
| // Calculate compression metrics | |
| const inputLength = inputText.length; | |
| const originalSizeBytes = inputLength * 4; // Approximate 4 bytes per char | |
| const compressedSizeBytes = 64 * 8; // 64 floats * 8 bytes | |
| const compressionRatio = ((1 - compressedSizeBytes / originalSizeBytes) * 100).toFixed(1); | |
| document.getElementById('compressionRatio').textContent = | |
| `${Math.max(0, compressionRatio)}% compression achieved`; | |
| const originalSizeGB = (originalSizeBytes / (1024 ** 3)).toFixed(3); | |
| const compressedSizeGB = (compressedSizeBytes / (1024 ** 3)).toFixed(3); | |
| document.getElementById('vramSavings').innerHTML = | |
| `Original: <span class="text-cyberblue">${originalSizeGB}GB</span> → ` + | |
| `Compressed: <span class="text-cyberpurple">${compressedSizeGB}GB</span>`; | |
| // Enable query | |
| document.getElementById('queryBtn').disabled = false; | |
| isCompressed = true; | |
| } catch (error) { | |
| console.error('Compression error:', error); | |
| showError('Failed to compress: ' + error.message + '. Ensure backend is running on localhost:5000.'); | |
| } finally { | |
| // Hide processing animation | |
| processingEl.classList.add('hidden'); | |
| btn.disabled = false; | |
| } | |
| } | |
| // Ask question simulation (can be extended to use vector) | |
| function askQuestion() { | |
| const question = document.getElementById('queryInput').value.trim(); | |
| if (!question) { | |
| alert('Please enter a question'); | |
| return; | |
| } | |
| if (!isCompressed) { | |
| alert('Please compress the text first'); | |
| return; | |
| } | |
| const responses = [ | |
| "Based on the compressed context, the conversation primarily discussed artificial intelligence and memory optimization techniques.", | |
| "The state vector indicates the dialogue focused on neural network architectures and efficiency improvements.", | |
| "From the compressed data, I can infer the conversation involved technical discussions about transformer models and their limitations.", | |
| "The semantic embeddings suggest the original text covered topics related to machine learning scalability challenges.", | |
| "Analysis of the state vector reveals discussions about context window limitations and potential solutions." | |
| ]; | |
| const responseArea = document.getElementById('responseArea'); | |
| const responseText = responses[Math.floor(Math.random() * responses.length)]; | |
| responseArea.innerHTML = `<p class="typewriter text-cyberblue">${responseText}</p>`; | |
| // Clear input | |
| document.getElementById('queryInput').value = ''; | |
| } | |
| // Collapse functionality with ARIA updates | |
| function initCollapses() { | |
| document.querySelectorAll('.collapse-btn').forEach(button => { | |
| button.addEventListener('click', () => { | |
| const content = button.nextElementSibling; | |
| const icon = button.querySelector('.collapse-icon'); | |
| const isExpanded = !content.classList.contains('hidden'); | |
| content.classList.toggle('hidden'); | |
| button.setAttribute('aria-expanded', !isExpanded); | |
| icon.setAttribute('data-feather', isExpanded ? 'chevron-down' : 'chevron-up'); | |
| feather.replace({ width: '20', height: '20' }); | |
| }); | |
| }); | |
| } | |
| // Event listeners setup | |
| function initEventListeners() { | |
| document.getElementById('inputText').addEventListener('input', updateCharCount); | |
| document.getElementById('sampleBtn').addEventListener('click', loadSample); | |
| document.getElementById('compressBtn').addEventListener('click', compressText); | |
| document.getElementById('queryBtn').addEventListener('click', askQuestion); | |
| document.getElementById('queryInput').addEventListener('keypress', (e) => { | |
| if (e.key === 'Enter') askQuestion(); | |
| }); | |
| // Disable query button initially | |
| document.getElementById('queryBtn').disabled = true; | |
| } | |
| // Initialize on load | |
| document.addEventListener('DOMContentLoaded', () => { | |
| feather.replace(); | |
| initializeMatrix(); | |
| updateCharCount(); | |
| initEventListeners(); | |
| initCollapses(); | |
| }); | |
| </script> | |
| </body> | |
| </html> | |