Spaces:
Running
Running
File size: 25,479 Bytes
f87a697 c8c4fc6 2417033 c8c4fc6 61846f9 f87a697 c8c4fc6 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 13564a6 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 13564a6 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 f9be7e0 f87a697 61846f9 f87a697 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Extracts entities, key-value pairs, dates, and line items from unstructured invoices, receipts, and enterprise contracts.">
<link rel="canonical" href="https://www.slmagents.ai/document_parser.html">
<title>SLM Document Parser: Unstructured Text & Invoice Data Extraction | SLMAgents</title>
<link rel="stylesheet" href="style.css?v=64.0">
<!-- OpenGraph / Social Meta Tags -->
<meta property="og:type" content="article">
<meta property="og:url" content="https://www.slmagents.ai/document_parser.html">
<meta property="og:title" content="SLM Document Parser: Unstructured Text & Invoice Data Extraction | SLMAgents">
<meta property="og:description" content="Extracts entities, key-value pairs, dates, and line items from unstructured invoices, receipts, and enterprise contracts.">
<meta property="og:site_name" content="SLMAgents">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="SLM Document Parser: Unstructured Text & Invoice Data Extraction | SLMAgents">
<meta name="twitter:description" content="Extracts entities, key-value pairs, dates, and line items from unstructured invoices, receipts, and enterprise contracts.">
<!-- Structured Data / Schema Markup -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "TechArticle",
"headline": "SLM Document Parser: Unstructured Text & Invoice Data Extraction | SLMAgents",
"description": "Extracts entities, key-value pairs, dates, and line items from unstructured invoices, receipts, and enterprise contracts.",
"url": "https://www.slmagents.ai/document_parser.html",
"mainEntityOfPage": "https://www.slmagents.ai/document_parser.html",
"articleSection": "Data & Utilities",
"author": {
"@type": "Organization",
"name": "SLMAgents Community",
"url": "https://github.com/t00114218-stack/SLMAgents"
},
"publisher": {
"@type": "Organization",
"name": "SLMAgents",
"logo": {
"@type": "ImageObject",
"url": "https://www.slmagents.ai/flowchart.png"
}
}
}
</script>
</head>
<body>
<!-- Top Engineering Header -->
<header class="site-top-header web-only-nav">
<div class="container nav-container">
<div style="display: flex; align-items: center; gap: 10px;">
<button class="sidebar-toggle" onclick="toggleSidebar()" aria-label="Toggle Sidebar">
<svg width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16"/>
</svg>
</button>
<a href="index.html" class="logo">
<div class="logo-icon">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/>
</svg>
</div>
<span>SLMAgents</span>
</a>
</div>
<nav>
<ul class="nav-links">
<li><a href="index.html" id="topnav-home">Home</a></li>
<li><a href="chat.html" id="topnav-chat">Chat Studio</a></li>
<li><a href="playground.html" id="topnav-playground">Playground</a></li>
<li><a href="blogs.html" id="topnav-blogs">Blogs</a></li>
<li>
<button type="button" onclick="openDownloadModal()" class="btn-nav-download">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
Download App
</button>
</li>
<li>
<a href="https://github.com/t00114218-stack/SLMAgents" target="_blank" class="btn-github-nav">
<svg width="14" height="14" fill="currentColor" viewBox="0 0 16 16">
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8"/>
</svg>
GitHub
</a>
</li>
</ul>
</nav>
</div>
</header>
<div class="layout-container">
<aside class="sidebar" id="sidebar">
<div class="sidebar-group">
<div class="sidebar-group-title">Active Libraries</div>
<ul class="sidebar-list" id="sidebar-active-list"></ul>
</div>
</aside>
<main class="main-content">
<div class="doc-content-wrapper">
<section class="doc-section" id="overview" style="margin-top: 0;">
<div class="breadcrumb" style="font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.75rem;"><a href="index.html" style="color: var(--text-secondary); text-decoration: none;">Overview</a> <span style="margin: 0 6px;">/</span> <span>slm_document_parser</span> <span style="margin: 0 6px;">/</span> <span style="color: var(--text-primary); font-weight: 600;">SLM Document Parser</span></div>
<div class="badge-pill">slm_document_parser · Data & Utilities · 10-Plane Pure-CPU Agent</div>
<h1 style="font-size: 2.25rem; color: #0f172a; font-weight: 800; margin-bottom: 0.75rem;">SLM Document Parser</h1>
<p style="font-size: 1.05rem; color: #334155; line-height: 1.65; font-weight: 500; margin: 0;">Extract tabular metrics, metadata structures, and key paragraphs from PDFs, Word docs, and plain text files locally under strict MIT-licensing parameters.</p>
<nav class="doc-nav">
<a href="#overview">01 / Overview</a>
<a href="#install">02 / OS Installers & CLI</a>
<a href="#harness">03 / 10-Plane Harness</a>
<a href="#git">04 / Git Checkout</a>
<a href="#config">05 / API Reference</a>
</nav>
<h2>01 / Overview & Capabilities</h2>
<p>The SLM Document Parser leverages high-performance local neural reasoning and visual document parsing engines orchestrated by the SLMAgents 2.0 10-Plane Pure-CPU Harness (hybrid llama.cpp GGUF Q4_K_M + quantized INT4/INT8 ONNX Runtime CPU) to parse multi-formatted documents offline. It supports high-fidelity layout preservation for scanned PDFs and legacied formats (<code>.pdf</code>, <code>.docx</code>, <code>.doc</code>, <code>.pptx</code>, <code>.ppt</code>, <code>.txt</code>) to output structured text and semantic RAG database chunks.</p>
</section>
<!-- INSTALLATION & STANDALONE OS HARNESS INSTALLERS -->
<section class="doc-section" id="install">
<h2>02 / Standalone OS Harness Installers, CLI & Python SDK</h2>
<p>In <strong>SLMAgents 2.0</strong>, <strong>SLM Document Parser</strong> executes inside the <strong>10-Plane Pure-CPU Agent Harness (<code>slm_harness</code>)</strong>. Download a self-extracting <strong>Individual Agent + Harness OS Installer</strong> for macOS, Windows, or Linux (bundling <code>slm_document_parser</code> + <code>slm_harness</code> + the <code>./slm</code> CLI), install the full 26-agent desktop suite, or install via Python <code>pip</code>:</p>
<h3>1. Individual SLM Document Parser + 10-Plane Harness Installers (All OSes)</h3>
<div class="subpage-installer-grid">
<a href="/api/installers/download/agent-macos?agent=document_parser" class="subpage-installer-card">
<div class="subpage-installer-title">
<span>macOS Installer</span>
<span class="subpage-installer-ext">.command</span>
</div>
<div class="subpage-installer-desc">Self-extracting macOS bundle with <code>slm_document_parser</code> + <code>slm_harness</code> + <code>./slm</code> CLI</div>
</a>
<a href="/api/installers/download/agent-windows?agent=document_parser" class="subpage-installer-card">
<div class="subpage-installer-title">
<span>Windows Installer</span>
<span class="subpage-installer-ext">.exe</span>
</div>
<div class="subpage-installer-desc">Native 64-bit Windows Setup with portable Python 3.11 + <code>slm_document_parser</code> + <code>slm_harness</code></div>
</a>
<a href="/api/installers/download/agent-linux?agent=document_parser" class="subpage-installer-card">
<div class="subpage-installer-title">
<span>Linux Installer</span>
<span class="subpage-installer-ext">.AppImage</span>
</div>
<div class="subpage-installer-desc">Standalone Linux AppImage with <code>slm_document_parser</code> + <code>slm_harness</code> + <code>./slm</code> CLI</div>
</a>
</div>
<h3>2. Full 26-Agent Studio & Desktop OS Installers</h3>
<div class="subpage-suite-links">
<a href="/api/installers/download/macos-dmg" class="subpage-suite-link">macOS .dmg (280 MB)</a>
<a href="/api/installers/download/windows" class="subpage-suite-link">Windows .exe (2.8 MB)</a>
<a href="/api/installers/download/linux" class="subpage-suite-link">Linux .AppImage (3.4 MB)</a>
<button onclick="openDownloadModal()" class="btn btn-primary" style="padding: 0.38rem 0.8rem; font-size: 0.76rem;">All OS Installers Modal</button>
</div>
<h3>3. 10-Plane Harness CLI (<code>./slm</code>) & Python <code>pip</code> Installation</h3>
<div class="code-panel" style="margin: 0.85rem 0;">
<div class="code-header">
<div class="code-dots"><div class="code-dot"></div><div class="code-dot"></div><div class="code-dot"></div></div>
<div class="code-title">Terminal — 10-Plane Harness CLI & Pip</div>
</div>
<div class="code-content" style="display:block;">
<pre><span style="color:#64748b;"># Option A: Install via PyPI or editable source with the 10-Plane Harness</span>
<span style="color:#34d399;">$</span> pip install slm-document-parser
<span style="color:#34d399;">$</span> pip install -e ./slm_harness -e ./slm_document_parser
<span style="color:#64748b;"># Option B: Run directly through the Unified 10-Plane Pure-CPU Harness CLI (./slm)</span>
<span style="color:#34d399;">$</span> ./slm ask "Parse @financial_report.pdf including tables and export semantic chunks"
<span style="color:#34d399;">$</span> ./slm chat <span style="color:#64748b;"># Interactive Rich TUI with 18 slash commands (/trace, /models, /arena, /undo)</span>
<span style="color:#34d399;">$</span> ./slm serve <span style="color:#64748b;"># 100% Offline Web AI Studio + OpenAI /v1 API at http://127.0.0.1:7860</span></pre>
</div>
</div>
</section>
<!-- 10-PLANE PURE-CPU HARNESS ARCHITECTURE -->
<section class="doc-section" id="harness">
<h2>03 / 10-Plane Pure-CPU Harness Integration (<code>slm_harness</code>)</h2>
<p>Rather than executing as an isolated prompt wrapper, <strong>SLM Document Parser</strong> is natively orchestrated by the <strong>SLMAgents 2.0 10-Plane Pure-CPU Harness</strong> (via <code>slm_harness.runtime.legacy_bridge</code> and <code>CascadeRouter</code>). Every call benefits from hybrid <code>llama.cpp</code> GGUF (<code>Q4_K_M</code>) + Quantized INT4/INT8 CPU execution, watermarked LRU memory governance, grammar-constrained decoding, and deterministic verification at <strong>$0 API cost</strong>:</p>
<table class="param-table">
<thead>
<tr><th>Harness Plane</th><th>Subsystem</th><th>How It Powers SLM Document Parser on Pure CPU</th></tr>
</thead>
<tbody>
<tr>
<td><strong>Plane 6</strong></td>
<td><code>CascadeRouter</code> (<35ms)</td>
<td>Stage 1 (File Extension / MIME Inspection: .pdf, .docx, .pptx)</td>
</tr>
<tr>
<td><strong>Plane 2 & 5</strong></td>
<td><code>MemoryArena</code> & Hybrid CPU Runtime</td>
<td>Specialist Role: <code>vision (Florence-2-base INT4) + primary (Qwen3-4B GGUF Q4_K_M)</code>. Managed inside Watermark LRU <code>MemoryArena</code> (<code>lite</code> 2.6 GB / <code>balanced</code> 4.7 GB / <code>power</code> 8.2 GB) with zero-copy session sharing and automatic OOM tier step-down (<code>8B -> 4B -> 3B -> 0.8B</code>).</td>
</tr>
<tr>
<td><strong>Plane 7 & 8</strong></td>
<td>Deterministic Verifier & Governance</td>
<td>Plane 3 Content-Addressed Artifact Scratchpad (artifact://<sha12>) + Plane 7 Structured Markdown & Heading Hierarchy Verifier</td>
</tr>
<tr>
<td><strong>Plane 1, 3 & 4</strong></td>
<td>Kernel, Artifact Scratchpad & 4-Tier Memory</td>
<td>SQLite WAL <code>CheckpointStore</code> (<code>/fork</code>, <code>/rewind</code>, <code>/undo</code>), content-addressed <code>artifact://<sha12></code> handles to prevent prompt bloat, and hybrid SQLite FTS5 BM25 + HNSW vector memory.</td>
</tr>
</tbody>
</table>
</section>
<!-- GIT CHECKOUT -->
<section class="doc-section" id="git">
<h2>04 / Source Checkout (Git Sparse-Checkout)</h2>
<p>Clone this agent alongside the <strong>10-Plane Pure-CPU Harness (<code>slm_harness</code>)</strong> from the monorepo using Git sparse-checkout — no need to download all 26 agents:</p>
<h3>Option 1 — Sparse Checkout with 10-Plane Harness (Recommended)</h3>
<div class="code-panel" style="margin: 0.85rem 0;">
<div class="code-header">
<div class="code-dots"><div class="code-dot"></div><div class="code-dot"></div><div class="code-dot"></div></div>
<div class="code-title">Terminal — Git Sparse Checkout</div>
</div>
<div class="code-content" style="display:block;">
<pre><span style="color:#64748b;"># 1. Create and enter a new directory</span>
<span style="color:#34d399;">$</span> mkdir slm_document_parser_workspace && cd slm_document_parser_workspace
<span style="color:#64748b;"># 2. Initialise empty git repo and add remote</span>
<span style="color:#34d399;">$</span> git init
<span style="color:#34d399;">$</span> git remote add origin https://github.com/t00114218-stack/SLMAgents.git
<span style="color:#64748b;"># 3. Enable sparse-checkout for both slm_harness and slm_document_parser</span>
<span style="color:#34d399;">$</span> git sparse-checkout init --cone
<span style="color:#34d399;">$</span> git sparse-checkout set slm_harness slm_document_parser
<span style="color:#64748b;"># 4. Pull the 10-Plane Harness and agent source</span>
<span style="color:#34d399;">$</span> git pull origin main</pre>
</div>
</div>
<h3>Option 2 — Full Repository Clone</h3>
<div class="code-panel" style="margin: 0.85rem 0;">
<div class="code-header">
<div class="code-dots"><div class="code-dot"></div><div class="code-dot"></div><div class="code-dot"></div></div>
<div class="code-title">Terminal — Full Clone</div>
</div>
<div class="code-content" style="display:block;">
<pre><span style="color:#34d399;">$</span> git clone https://github.com/t00114218-stack/SLMAgents.git
<span style="color:#34d399;">$</span> cd SLMAgents
<span style="color:#34d399;">$</span> ./slm doctor</pre>
</div>
</div>
<p style="margin-top: 1.25rem; font-size: 0.86rem; color: var(--text-secondary); border-left: 2px solid #09090b; padding-left: 1rem;">
<strong>Note:</strong> After checkout, install the harness and agent in editable mode with <code>pip install -e ./slm_harness -e ./slm_document_parser</code> or download the pre-packaged OS Harness Installer above.
</p>
</section>
<section class="doc-section" id="workflow">
<h2>🤖 Truly Agentic Hybrid Visual Pipeline</h2>
<p>The Document Parser handles layout mapping by combining visual coordinate classifiers with standard extraction loops:</p>
<ul>
<li><strong>LibreOffice Conversion Layer:</strong> Converts complex formats (DOC/PPT/PPTX) into intermediate PDFs in the background using headless <code>soffice</code> conversions.</li>
<li><strong>Page Image Rendering:</strong> Renders PDF page indices to images sequentially using <code>pypdfium2</code>.</li>
<li><strong>Visual OCR & Object Detection:</strong> Scans rendered page layouts, running Object Detection (<code><OD></code>) to locate table and figure boxes. Crops table boxes to OCR them individually, and runs detailed caption generation (<code><DETAILED_CAPTION></code>) for diagrams.</li>
<li><strong>Layout Reconstruction:</strong> Passes text, parsed tables, and diagram captions to the local neural engine to synthesize a unified, formatted Markdown page representation.</li>
<li><strong>Semantic Chunker & Linker:</strong> Segments markdown into structured paragraph chunks, extracts heading hierarchies, resolves product entities, and links related sections together.</li>
</ul>
</section>
<section class="doc-section" id="visual-demo">
<h2>Complex Table Visual OCR Extraction</h2>
<p>When the visual parser encounters complex tables inside a document scan, it crops the table coordinates, routes it to the vision parser, and synthesizes a natural language text description. Below is an example of an input expense table and its corresponding parsed description:</p>
<div style="margin: 20px 0; max-width: 600px; border-radius: 12px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.05); box-shadow: 0 10px 30px rgba(0,0,0,0.5);">
<img src="https://raw.githubusercontent.com/t00114218-stack/SLMAgents/main/website/complex_table.png" alt="Input Corporate Expense Table" style="width: 100%; height: auto; display: block;">
</div>
<div class="tip-box">
<strong>Extracted Natural Language Table Description Output:</strong><br>
<pre><code>### Q2 FY2024 Company Expense Summary
The table outlines corporate expenditures across multiple categories:
- **Infrastructure**: Spent $1,195,450 against a $1,250,000 budget (a decrease of 4.36%).
- **AI Compute Nodes**: Spent $3,842,910 against a $3,500,000 budget (an increase of 9.80%).
- **Model Conversion**: Spent $412,300 against a $450,000 budget (a decrease of 8.38%).
- **Data Storage**: Spent $845,600 against a $800,000 budget (an increase of 5.70%).
- **GPU Clusters**: Spent $2,215,800 against a $2,100,000 budget (an increase of 5.51%).</code></pre>
</div>
</section>
<section class="doc-section" id="tuning">
<h2>CPU Performance Tuning Guidelines</h2>
<p>Follow these configuration rules to optimize latency on standard CPUs:</p>
<ul>
<li><strong>Core Thread Cap:</strong> Set <code>n_threads</code> strictly to the number of physical cores to avoid context switching thread collisions.</li>
<li><strong>Sequential Processing:</strong> Process multi-page images sequentially instead of in parallel batches to keep the memory footprint under 2.0 GB.</li>
<li><strong>OpenMP Settings:</strong> Keep thread counts aligned in your shell environment:
<pre><code>export OMP_NUM_THREADS=4
export MKL_NUM_THREADS=4</code></pre>
</li>
</ul>
</section>
<section class="doc-section" id="config">
<h2>05 / Configuration & API Reference</h2>
<h3><code>SLMDocumentParser</code> Initialization</h3>
<pre><code class="language-python">from slm_document_parser.document_parser import SLMDocumentParser
parser = SLMDocumentParser(n_ctx=4096, n_threads=4)</code></pre>
<table class="param-table">
<thead>
<tr><th>Parameter</th><th>Type / Default</th><th>Description</th></tr>
</thead>
<tbody>
<tr><td>model_path</td><td>str | None</td><td>Local path to model weight checkpoints.</td></tr>
<tr><td>n_ctx</td><td>int | 4096</td><td>Inference token window size. Supports deep multi-page context windows.</td></tr>
<tr><td>n_threads</td><td>int | 4</td><td>Allocated physical CPU P-cores for 10-Plane Harness execution.</td></tr>
<tr><td>system_prompt</td><td>str | None</td><td>Optional custom system prompt instructions overriding the default template.</td></tr>
<tr><td>user_input</td><td>str | None</td><td>Optional additional user-supplied target parameters or variables.</td></tr>
</tbody>
</table>
<h3><code>extract_text</code> Method</h3>
<p>Converts document layouts and images into a single reconstructed Markdown text string:</p>
<pre><code class="language-python">markdown_content = parser.extract_text("financial_report.pdf")</code></pre>
<h3><code>chunk_document</code> Method</h3>
<p>Extracts markdown text and slices it into linked semantic chunks with metadata properties:</p>
<pre><code class="language-python">chunks = parser.chunk_document("financial_report.pdf")
print(chunks[0])</code></pre>
<div class="tip-box">
<strong>Extracted Semantic Chunk Output (JSON):</strong><br>
<pre><code class="language-json">{
"text": "SpaceX successfully launched the Falcon 9 rocket from Cape Canaveral Space Force Station, landing the booster return flight for the 15th time. The mission delivered communication payloads into low Earth orbit.",
"metadata": {
"source": "financial_report.pdf",
"heading": "1. Launch Milestones",
"subheading": "Falcon 9 Performance",
"product": "SpaceX",
"key_terms": ["Falcon 9", "Cape Canaveral", "booster"],
"format": "pdf",
"chunk_index": 0,
"related_chunks": [1, 2]
}
}</code></pre>
</div>
<h3><code>parse_and_chunk_stream</code> Method</h3>
<p>Streaming generator yielding semantic chunks page-by-page as they are processed to reduce first-chunk response times (TTFT):</p>
<pre><code class="language-python">for chunk in parser.parse_and_chunk_stream("multi_page_manual.pdf"):
print(f"Processed Chunk: {chunk['text'][:100]}...")</code></pre>
<h3><code>export_chunks_to_excel</code> Method</h3>
<p>Saves the parsed chunks to an Excel spreadsheet:</p>
<pre><code class="language-python"># Exports to workbook. Set append=True to write to an existing sheet
parser.export_chunks_to_excel(chunks, "rag_dataset.xlsx", append=False)</code></pre>
<div class="tip-box">
<strong>Output Excel Table Layout:</strong><br>
<table class="param-table">
<thead>
<tr><th>Chunk Index</th><th>Source File</th><th>Heading</th><th>Subheading</th><th>Product</th><th>Related Chunks</th><th>Text</th></tr>
</thead>
<tbody>
<tr><td>0</td><td>financial_report.pdf</td><td>1. Launch Milestones</td><td>Falcon 9 Performance</td><td>SpaceX</td><td>1,2</td><td>SpaceX successfully launched the Falcon 9...</td></tr>
</tbody>
</table>
</div>
</section>
<footer>
<div class="footer-row">
<div><strong style="color: var(--text-primary);">SLMAgents 2.0</strong> · Powered by the 10-Plane Pure-CPU Agent Harness (<code>slm_harness</code>) · MIT License</div>
<div class="footer-links">
<a href="index.html">Home</a>
<a href="index.html#os-installers">OS Installers</a>
<a href="chat.html">Chat Studio</a>
<a href="playground.html">Playground</a>
<a href="blogs.html">Blogs</a>
<a href="https://github.com/t00114218-stack/SLMAgents" target="_blank">GitHub</a>
</div>
</div>
</footer>
</div>
</main>
</div>
<script src="app.js?v=100.0"></script>
</body>
</html>
|