MAMBA_7B / src /make_mamba_install_pptx.py
namanadep's picture
Upload src/make_mamba_install_pptx.py with huggingface_hub
c372d99 verified
Raw
History Blame Contribute Delete
19.1 kB
import os
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.enum.text import PP_ALIGN
from pptx.dml.color import RGBColor
from pptx.enum.shapes import MSO_SHAPE
def create_visual_journey_presentation():
pptx_path = "/home/adminuser/aiops_pocs/MAMBA_7B/docs/MAMBA_7B_INSTALLATION_AND_ARCHITECTURE_GUIDE.pptx"
prs = Presentation()
prs.slide_width = Inches(13.333)
prs.slide_height = Inches(7.5)
# Ultra-Premium Dark Theme Color Palette
COLOR_BG = RGBColor(11, 15, 25) # Deep Obsidian Slate
COLOR_CARD = RGBColor(30, 41, 59) # Slate 800
COLOR_CARD_DARK = RGBColor(20, 27, 44) # Slate 900
COLOR_CYAN = RGBColor(6, 182, 212) # Electric Cyan
COLOR_GREEN = RGBColor(16, 185, 129) # Emerald Green
COLOR_PURPLE = RGBColor(168, 85, 247) # Vivid Purple
COLOR_AMBER = RGBColor(245, 158, 11) # Radiant Amber
COLOR_TEXT = RGBColor(248, 250, 252) # Pure White Slate
COLOR_MUTED = RGBColor(148, 163, 184) # Slate Muted
def apply_bg(slide):
bg = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0, Inches(13.333), Inches(7.5))
bg.fill.solid()
bg.fill.fore_color.rgb = COLOR_BG
bg.line.fill.background()
def add_header(slide, title_text, chapter_text="MY EXPERIMENT JOURNEY"):
tb = slide.shapes.add_textbox(Inches(0.8), Inches(0.4), Inches(11.7), Inches(0.9))
tf = tb.text_frame
tf.word_wrap = True
p_cat = tf.paragraphs[0]
p_cat.text = chapter_text.upper()
p_cat.font.size = Pt(11)
p_cat.font.bold = True
p_cat.font.color.rgb = COLOR_CYAN
p_title = tf.add_paragraph()
p_title.text = title_text
p_title.font.size = Pt(24)
p_title.font.bold = True
p_title.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 1: Title Slide (Hero Graphics)
# -------------------------------------------------------------
slide1 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide1)
# Hero Card Background Container
hero_card = slide1.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.8), Inches(1.2), Inches(11.7), Inches(5.1))
hero_card.fill.solid()
hero_card.fill.fore_color.rgb = COLOR_CARD_DARK
hero_card.line.color.rgb = COLOR_CYAN
hero_card.line.width = Pt(2)
# Top Accent Line
line = slide1.shapes.add_shape(MSO_SHAPE.RECTANGLE, Inches(0.8), Inches(1.2), Inches(11.7), Inches(0.12))
line.fill.solid()
line.fill.fore_color.rgb = COLOR_CYAN
line.line.fill.background()
tb = slide1.shapes.add_textbox(Inches(1.2), Inches(1.6), Inches(10.9), Inches(4.2))
tf = tb.text_frame
tf.word_wrap = True
p1 = tf.paragraphs[0]
p1.text = "⚡ HANDS-ON RESEARCH & DEPLOYMENT JOURNEY"
p1.font.size = Pt(13)
p1.font.bold = True
p1.font.color.rgb = COLOR_CYAN
p2 = tf.add_paragraph()
p2.text = "My Journey with Mamba 7B: From Curiosity to Benchmarking"
p2.font.size = Pt(34)
p2.font.bold = True
p2.font.color.rgb = COLOR_TEXT
p3 = tf.add_paragraph()
p3.text = "\nAn empirical exploration of Selective State Space Models (SSMs). How I discovered Mamba, installed Codestral Mamba 7B locally via Ollama, built custom test suites, and evaluated performance against Qwen 2.5 7B on NVIDIA H200 GPUs."
p3.font.size = Pt(15)
p3.font.color.rgb = COLOR_MUTED
# Stat Badges at Bottom
badges = [
("ARCHITECTURE", "Selective SSM (S6)", COLOR_GREEN),
("MODEL TESTED", "Codestral Mamba 7B", COLOR_CYAN),
("HARDWARE", "2x NVIDIA H200 NVL", COLOR_PURPLE),
("CONTEXT", "256k Window", COLOR_AMBER)
]
for idx, (b_title, b_val, b_color) in enumerate(badges):
x = Inches(1.2 + idx * 2.7)
b_box = slide1.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, x, Inches(4.8), Inches(2.5), Inches(1.1))
b_box.fill.solid()
b_box.fill.fore_color.rgb = COLOR_CARD
b_box.line.color.rgb = b_color
b_box.line.width = Pt(1)
b_tf = b_box.text_frame
b_tf.word_wrap = True
p_t = b_tf.paragraphs[0]
p_t.text = b_title
p_t.font.size = Pt(9)
p_t.font.bold = True
p_t.font.color.rgb = COLOR_MUTED
p_v = b_tf.add_paragraph()
p_v.text = b_val
p_v.font.size = Pt(12)
p_v.font.bold = True
p_v.font.color.rgb = b_color
# -------------------------------------------------------------
# SLIDE 2: Chapter 1 - The Spark of Curiosity (Visual Cards)
# -------------------------------------------------------------
slide2 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide2)
add_header(slide2, "Chapter 1: Why I Became Curious About Mamba", "Phase 1: Motivation")
pillars = [
("🔬 The Research Breakthrough", "Reading Albert Gu and Tri Dao's paper on Selective State Space Models (SSMs). The promise of escaping Transformer O(N²) quadratic attention.", COLOR_PURPLE),
("💾 The Constant Memory Hypothesis", "Transformers exhaust VRAM with KV-caches at 32k+ context. Mamba promises a fixed O(1) recurrent memory buffer.", COLOR_CYAN),
("🎯 My Goal & Mission", "Build a hands-on local deployment on NVIDIA H200 GPUs, test real-world code generation, measure throughput, and evaluate response quality.", COLOR_GREEN)
]
for idx, (title, desc, color) in enumerate(pillars):
x = Inches(0.8 + idx * 3.9)
card = slide2.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, x, Inches(1.6), Inches(3.6), Inches(5.2))
card.fill.solid()
card.fill.fore_color.rgb = COLOR_CARD
card.line.color.rgb = color
card.line.width = Pt(2)
# Top Accent Header Bar
bar = slide2.shapes.add_shape(MSO_SHAPE.RECTANGLE, x, Inches(1.6), Inches(3.6), Inches(0.1))
bar.fill.solid()
bar.fill.fore_color.rgb = color
bar.line.fill.background()
tf = card.text_frame
tf.word_wrap = True
p = tf.paragraphs[0]
p.text = title
p.font.size = Pt(17)
p.font.bold = True
p.font.color.rgb = color
p_d = tf.add_paragraph()
p_d.text = f"\n{desc}"
p_d.font.size = Pt(13)
p_d.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 3: Chapter 2 - Model Exploration & Baseline Selection
# -------------------------------------------------------------
slide3 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide3)
add_header(slide3, "Chapter 2: Researching Hugging Face & Model Selection", "Phase 2: Model Selection")
c1 = slide3.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.8), Inches(1.6), Inches(5.6), Inches(5.2))
c1.fill.solid()
c1.fill.fore_color.rgb = COLOR_CARD
c1.line.color.rgb = COLOR_GREEN
c1.line.width = Pt(2)
tf1 = c1.text_frame
tf1.word_wrap = True
p = tf1.paragraphs[0]
p.text = "🔍 Selected Model: Codestral Mamba 7B"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = COLOR_GREEN
b1 = [
"• Model Repo: mistralai/mamba-codestral-7b",
"• GGUF Quantization: Q4_K_M (3.9 GB binary)",
"• Key Feature: 256k context window for repository-level code processing.",
"• Pure SSM S6: Zero self-attention layers."
]
for b in b1:
p = tf1.add_paragraph()
p.text = b
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
c2 = slide3.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(6.8), Inches(1.6), Inches(5.6), Inches(5.2))
c2.fill.solid()
c2.fill.fore_color.rgb = COLOR_CARD
c2.line.color.rgb = COLOR_CYAN
c2.line.width = Pt(2)
tf2 = c2.text_frame
tf2.word_wrap = True
p = tf2.paragraphs[0]
p.text = "⚖️ Selected Baseline: Qwen 2.5 7B Instruct"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = COLOR_CYAN
b2 = [
"• Model Tag: qwen2.5:7b-instruct (4.7 GB)",
"• Architecture: Multi-Head Self-Attention Transformer.",
"• Why Qwen 2.5? Top-performing 7B open model for coding & technical reasoning.",
"• Fair Evaluation: Identical parameter scale (7B) on the same GPU cluster."
]
for b in b2:
p = tf2.add_paragraph()
p.text = b
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 4: Chapter 3 - Visual Stepper Installation Flow
# -------------------------------------------------------------
slide4 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide4)
add_header(slide4, "Chapter 3: Local Setup Pipeline in Ollama", "Phase 3: Installation Flow")
steps = [
("1. DOWNLOAD", "Downloaded GGUF binary from Hugging Face into /data/ directory.", COLOR_CYAN),
("2. MODELFILE", "Created custom Modelfile setting SYSTEM prompt & num_ctx 65536.", COLOR_GREEN),
("3. REGISTER", "Ran 'ollama create mamba-codestral:7b' to build Ollama layers.", COLOR_PURPLE),
("4. VERIFY", "Verified model readiness & executed test queries via Ollama API.", COLOR_AMBER)
]
for idx, (s_title, s_desc, color) in enumerate(steps):
x = Inches(0.8 + idx * 2.95)
box = slide4.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, x, Inches(1.6), Inches(2.7), Inches(5.2))
box.fill.solid()
box.fill.fore_color.rgb = COLOR_CARD
box.line.color.rgb = color
box.line.width = Pt(2)
# Step Number Badge
num_circle = slide4.shapes.add_shape(MSO_SHAPE.OVAL, x + Inches(0.9), Inches(1.9), Inches(0.9), Inches(0.9))
num_circle.fill.solid()
num_circle.fill.fore_color.rgb = color
num_circle.line.fill.background()
tf_num = num_circle.text_frame
p_n = tf_num.paragraphs[0]
p_n.text = str(idx + 1)
p_n.font.size = Pt(20)
p_n.font.bold = True
p_n.font.color.rgb = COLOR_BG
p_n.alignment = PP_ALIGN.CENTER
tf = box.text_frame
tf.word_wrap = True
p_t = tf.paragraphs[0]
p_t.text = f"\n\n\n{s_title}"
p_t.font.size = Pt(15)
p_t.font.bold = True
p_t.font.color.rgb = color
p_t.alignment = PP_ALIGN.CENTER
p_d = tf.add_paragraph()
p_d.text = f"\n{s_desc}"
p_d.font.size = Pt(12)
p_d.font.color.rgb = COLOR_TEXT
p_d.alignment = PP_ALIGN.CENTER
# -------------------------------------------------------------
# SLIDE 5: Chapter 4 - Designing the Experiment (Category Cards)
# -------------------------------------------------------------
slide5 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide5)
add_header(slide5, "Chapter 4: Designing My 10-Prompt Test Suite", "Phase 4: Test Suite Design")
categories = [
("⚡ 1. Algorithms & Data Structures", "Lock-free concurrent LRU Cache in Python & Red-Black Tree self-balancing in C++.", COLOR_CYAN),
("🛠️ 2. Systems & Low-Level Code", "Asyncio WebSockets Gateway server & Linux eBPF kernel network tracing in C/BCC.", COLOR_GREEN),
("🔒 3. Memory Safety & Rust Syntax", "C++ memory allocator race condition repair & Rust zero-copy slice lifetime parser.", COLOR_AMBER),
("🧠 4. Math Logic & AI Mechanics", "Bitmask TSP dynamic programming, pure Python matrix inversion & SSM vs Attention theory.", COLOR_PURPLE)
]
for idx, (title, desc, color) in enumerate(categories):
row = idx // 2
col = idx % 2
x = Inches(0.8 + col * 5.9)
y = Inches(1.6 + row * 2.6)
card = slide5.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, x, y, Inches(5.6), Inches(2.3))
card.fill.solid()
card.fill.fore_color.rgb = COLOR_CARD
card.line.color.rgb = color
card.line.width = Pt(1.5)
tf = card.text_frame
tf.word_wrap = True
p_t = tf.paragraphs[0]
p_t.text = title
p_t.font.size = Pt(16)
p_t.font.bold = True
p_t.font.color.rgb = color
p_d = tf.add_paragraph()
p_d.text = desc
p_d.font.size = Pt(13)
p_d.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 6: Chapter 5 - Hero Metric Callouts (Visual Stats)
# -------------------------------------------------------------
slide6 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide6)
add_header(slide6, "Chapter 5: Benchmark Execution & Key Empirical Metrics", "Phase 5: Key Metrics")
stats = [
("42.2%", "LATENCY REDUCTION", "Codestral Mamba finished responses in 4.28s avg vs Qwen's 7.40s.", COLOR_GREEN),
("195 t/s", "GENERATION SPEED", "Both models saturated GPU hardware limits at ~194.8 t/s on NVIDIA H200 GPUs.", COLOR_CYAN),
("2.25x", "EXPLANATION DENSITY", "Qwen 2.5 generated 4,347 chars/response vs Mamba's 1,930 chars.", COLOR_AMBER),
("O(1)", "MEMORY RECURRENCE", "Mamba maintained a constant memory buffer without KV-cache VRAM inflation.", COLOR_PURPLE)
]
for idx, (num, label, desc, color) in enumerate(stats):
row = idx // 2
col = idx % 2
x = Inches(0.8 + col * 5.9)
y = Inches(1.6 + row * 2.6)
card = slide6.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, x, y, Inches(5.6), Inches(2.3))
card.fill.solid()
card.fill.fore_color.rgb = COLOR_CARD
card.line.color.rgb = color
card.line.width = Pt(1.5)
tf = card.text_frame
tf.word_wrap = True
p_num = tf.paragraphs[0]
p_num.text = num
p_num.font.size = Pt(36)
p_num.font.bold = True
p_num.font.color.rgb = color
p_lbl = tf.add_paragraph()
p_lbl.text = label
p_lbl.font.size = Pt(11)
p_lbl.font.bold = True
p_lbl.font.color.rgb = COLOR_MUTED
p_desc = tf.add_paragraph()
p_desc.text = desc
p_desc.font.size = Pt(12)
p_desc.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 7: Chapter 6 - Comparing Output Styles
# -------------------------------------------------------------
slide7 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide7)
add_header(slide7, "Chapter 6: Comparing Code Generation Styles", "Phase 6: Quality Breakdown")
c1 = slide7.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.8), Inches(1.6), Inches(5.6), Inches(5.2))
c1.fill.solid()
c1.fill.fore_color.rgb = COLOR_CARD
c1.line.color.rgb = COLOR_GREEN
tf1 = c1.text_frame
tf1.word_wrap = True
p = tf1.paragraphs[0]
p.text = "🟢 Codestral Mamba 7B Style"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = COLOR_GREEN
b1 = [
"• Hyper-Concise & Direct: Jumps straight into executable code without conversational filler.",
"• Rapid Autocomplete: Ideal for real-time IDE completion where speed is paramount.",
"• Minimal Comments: Omits lengthy docstrings unless explicitly requested.",
"• 15-Line Compact Logic: e.g. Used collections.OrderedDict for a clean 15-line LRU cache."
]
for b in b1:
p = tf1.add_paragraph()
p.text = b
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
c2 = slide7.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(6.8), Inches(1.6), Inches(5.6), Inches(5.2))
c2.fill.solid()
c2.fill.fore_color.rgb = COLOR_CARD
c2.line.color.rgb = COLOR_CYAN
tf2 = c2.text_frame
tf2.word_wrap = True
p = tf2.paragraphs[0]
p.text = "🔵 Qwen 2.5 7B Instruct Style"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = COLOR_CYAN
b2 = [
"• Exhaustive & Production-Grade: Includes full class structures, type annotations & logging.",
"• Edge-Case Handling: Explicit thread locks, race condition guards & exception catching.",
"• Comprehensive Docstrings: Explains design choices and complexity bounds in detail.",
"• Full Microservices: Built multi-layered async server architectures out-of-the-box."
]
for b in b2:
p = tf2.add_paragraph()
p.text = b
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 8: Chapter 7 - Final Takeaways & Deployment Recommendations
# -------------------------------------------------------------
slide8 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide8)
add_header(slide8, "Chapter 7: My Final Verdict & Recommendations", "Phase 7: Final Roadmap")
c1 = slide8.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.8), Inches(1.6), Inches(5.6), Inches(5.2))
c1.fill.solid()
c1.fill.fore_color.rgb = COLOR_CARD
c1.line.color.rgb = COLOR_GREEN
tf1 = c1.text_frame
tf1.word_wrap = True
p = tf1.paragraphs[0]
p.text = "🚀 Where I Would Deploy Mamba 7B"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = COLOR_GREEN
recs1 = [
"1. Real-Time IDE Autocomplete: Sub-second response time for instant inline code completion.",
"2. Massive Context Ingestion (256k tokens): Ingesting giant repositories or log files without VRAM KV-cache crash.",
"3. High-Throughput Streaming APIs: Low-cost, low-latency microservice endpoints."
]
for r in recs1:
p = tf1.add_paragraph()
p.text = r
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
c2 = slide8.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(6.8), Inches(1.6), Inches(5.6), Inches(5.2))
c2.fill.solid()
c2.fill.fore_color.rgb = COLOR_CARD
c2.line.color.rgb = COLOR_CYAN
tf2 = c2.text_frame
tf2.word_wrap = True
p = tf2.paragraphs[0]
p.text = "🚀 Where I Would Deploy Qwen 2.5 7B"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = COLOR_CYAN
recs2 = [
"1. Full System Architecture Design: Designing production microservices and complex refactors.",
"2. Automated Unit Test Suite Generation: Creating high-coverage pytest suites with mocks.",
"3. Interactive Code Review & Debugging: Deep-dive vulnerability analysis and bug repairs."
]
for r in recs2:
p = tf2.add_paragraph()
p.text = r
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
prs.save(pptx_path)
print("Successfully created visual journey-framed presentation:", pptx_path)
if __name__ == "__main__":
create_visual_journey_presentation()