<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Prince Kojo Dugboryele on Medium]]></title>
        <description><![CDATA[Stories by Prince Kojo Dugboryele on Medium]]></description>
        <link>https://medium.com/@dugboryeleprince?source=rss-303561abde62------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Prince Kojo Dugboryele on Medium</title>
            <link>https://medium.com/@dugboryeleprince?source=rss-303561abde62------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 22:45:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dugboryeleprince/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Fitting Is Not Serving: What an 8 GB GPU Can Actually Do With Concurrent LLM Requests]]></title>
            <link>https://medium.com/@dugboryeleprince/fitting-is-not-serving-what-an-8-gb-gpu-can-actually-do-with-concurrent-llm-requests-4878f37632cb?source=rss-303561abde62------2</link>
            <guid isPermaLink="false">https://medium.com/p/4878f37632cb</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[gpu]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[benchmarking]]></category>
            <dc:creator><![CDATA[Prince Kojo Dugboryele]]></dc:creator>
            <pubDate>Sat, 21 Nov 2026 23:11:43 GMT</pubDate>
            <atom:updated>2026-11-21T23:11:43.789Z</atom:updated>
            <content:encoded><![CDATA[<p><em>I benchmarked vLLM, llama.cpp and Ollama on an RTX 5060 Laptop with 8 GB of VRAM. The model loading successfully turned out to be the least interesting part of the story.</em></p><h3>1. Introduction: the illusion of fitting a model into VRAM</h3><p>Every local LLM guide ends at the same milestone: the model loads, nvidia-smi shows a happy number, and a chat completion comes back. Mine did too. A 4-bit Qwen2.5-7B sat in roughly 5 GB of my 8 GB VRAM, answered prompts at ~50 tokens/s, and left me with the impression that I had ~3 GB of headroom to spend on whatever I wanted.</p><p>That impression was wrong, and the way it was wrong is the subject of this article.</p><p>The headroom was not a pool I could spend freely. Depending on the engine, it was already reserved, already fragmented into fixed-size slots, or already committed to a context window I had chosen at startup. And when I started sending concurrent requests the three engines I tested behaved so differently that “it fits” stopped being a useful statement at all:</p><ul><li><strong>vLLM</strong> scaled a 4-bit 7B model from 67 tokens/s single-stream to <strong>~804 tokens/s aggregate at 16 concurrent requests</strong>, with p95 end-to-end latency still at ~1.0 s.</li><li><strong>llama.cpp</strong> saturated at <strong>~200 tokens/s around 4 concurrent requests</strong> and then simply queued everything else; p95 latency doubled past my service threshold at 8.</li><li><strong>Ollama</strong>, out of the box, processed requests <strong>one at a time</strong>: aggregate throughput stayed flat at ~45–50 tokens/s while p95 latency grew linearly to ~20 s at 16 concurrent requests.</li></ul><p>Same GPU, same model family, same 4-bit weights class. The difference was entirely in how each engine budgets memory and schedules work.</p><p>So I set up a controlled study around one question: <strong>how do quantization, context length, KV-cache allocation and engine memory management interact to determine the maximum concurrent workload an 8 GB consumer GPU can sustain?</strong> This article is the write-up of that study: the environment, the four experiments, the failures, and the configuration advice I would now give my past self.</p><h3>2. The GPU memory budget: weights are only the entry fee</h3><p>Before measuring anything, it helps to write down what actually occupies VRAM during inference:</p><ol><li><strong>Model weights.</strong> Parameters × bytes per parameter. A 7B model is ~14–15 GiB in FP16, ~7.6 GiB in 8-bit, ~4.4 GiB in 4-bit GGUF. This is the only component most “will it fit?” calculators consider.</li><li><strong>KV cache.</strong> Every token in every active sequence stores attention keys and values in every layer. For a model with L layers, H_kv key/value heads and head dimension d, in FP16:</li></ol><p>bytes_per_token = L × H_kv × d × 2 (K and V) × 2 (bytes)</p><p>For the models I tested this works out to:</p><figure><img alt="Table showing kv per token for selected models" src="https://cdn-images-1.medium.com/max/673/1*lpH56QnzFdpWqqCtIY1VDA.png" /></figure><p><strong>3. Activations and runtime.</strong> Prefill batches, attention workspace, CUDA graphs, allocator fragmentation. Small compared to weights, but not zero, and it spikes with batch size and prompt length.</p><p><strong>4. Reservations.</strong> The component everyone forgets: memory an engine allocates <em>up front</em> for future work. vLLM sizes a PagedAttention block pool at startup; llama.cpp allocates the KV cache for the configured context at load; Ollama allocates for num_ctx.</p><h3>3. Environment and methodology</h3><h3>Hardware and software</h3><figure><img alt="A table showing hardware and software information for the experiments" src="https://cdn-images-1.medium.com/max/673/1*aAGrNcoF2M84DtLy_kR-1Q.png" /></figure><h3>Configurations actually run</h3><figure><img alt="A table showing the experiment configurations per model and inference" src="https://cdn-images-1.medium.com/max/1024/1*I1I9eY9MTfBqUkfWouCzCw.png" /><figcaption>Two details matter for reading the results. First, this llama.cpp build defaults to <strong>4 server slots with a unified KV pool</strong> when --parallel is unset, so -c 8192 is a <em>shared</em> 8192-token pool across 4 slots, not 8192 per slot. Second, Ollama was run with stock ollama serve — no OLLAMA_NUM_PARALLEL, no tuning. Its behaviour below is the out-of-the-box behaviour, which is exactly what most users get.</figcaption></figure><h3>Workload and metrics</h3><p>All engines were driven through their OpenAI-compatible /v1/chat/completions endpoint with streaming, temperature=0, and a fixed prompt (&quot;Explain in two sentences what a KV cache is in transformer inference.&quot;, 70 chars, a few dozen tokens). Output was capped at <strong>64 tokens</strong>.</p><ul><li><strong>Concurrency sweep:</strong> levels 1, 2, 4, 8, 16 simultaneous requests, 3 repeats per level (2 for the 12B), a warm-up request before each sweep. Per request: TTFT, TPOT, end-to-end latency, completion tokens. Per level: aggregate tokens/s, p50/p95 latency, peak VRAM (100 ms nvidia-smi polling), host RAM, failures.</li><li><strong>Context sweep:</strong> single requests with tokenizer-built prompts of 512 / 1024 / 2048 / 4096 / 8192 tokens (as far as each configuration allowed), 3 repeats, same 64-token output cap.</li><li><strong>Sustainability criterion, fixed before testing:</strong> a concurrency level is sustainable if <strong>p95 end-to-end latency ≤ 2.0 s and zero failed requests</strong>. I did not move this threshold after seeing results.</li></ul><p>Every record carries timestamp, experiment id, engine/model/quantization, GPU/driver/CUDA, torch and Python versions. Raw JSONL, harness code and configs are published with this article (repository link at the end).</p><p>Two notes on measurement. Peak VRAM is polled at 100 ms, so sub-100 ms spikes can be missed. And p95 over 16 samples is really “the second-slowest request”; treat it as a tail indicator, not a precise percentile.</p><h3>Experiment 1: the cost of model weights</h3><p>On-disk weight sizes for the conversions I produced:</p><figure><img alt="Table showing models in fp16, 8-bit, and 4-bit conversions" src="https://cdn-images-1.medium.com/max/549/1*2UQDipbKPntHmH5M7GmqZA.png" /></figure><p>FP16 7B/8B is a non-starter on 8 GB: the weights alone are twice the card. I did not attempt it. 8-bit is where the story gets interesting, because <strong>it fails differently per engine</strong>:</p><ul><li><strong>vLLM:</strong> bitsandbytes 8-bit quantization is not supported in 0.33.0 (“unknown quantization method”). The supported 4-bit path for Qwen2.5–7B is the AWQ checkpoint, which I used instead. So my “vLLM 7B” is AWQ 4-bit, not 8-bit — a fairness caveat I carry through the whole article.</li><li><strong>llama.cpp / Ollama:</strong> Q8_0 GGUFs convert fine, but the 7B (7.6 GiB) would leave under 0.4 GiB for KV cache and runtime, and the 8B (8.0 GiB) exceeds the card before any cache at all. I converted them and did not obtain usable benchmark runs; they are excluded from the results rather than silently dropped.</li></ul><p>What the successful loads show is that <strong>weight bytes and VRAM bytes are not the same number</strong>. Observed steady-state footprints (single stream through 16 concurrent, essentially flat):</p><figure><img alt="Table showing model weights and observed run plateau on VRAM" src="https://cdn-images-1.medium.com/max/802/1*aeHGk3JB7mkdXaN__UU6cA.png" /></figure><p>Single-stream decode speed (mean of concurrency-1 runs) adds the performance half of the quantization story:</p><figure><img alt="Table showing ttft and tokens/s observed in single stream for models" src="https://cdn-images-1.medium.com/max/620/1*e8hA26ENivWFonRADJW4zw.png" /></figure><p>Lower bits did not mean slower here: the AWQ 7B outruns both GGUF Q4_K_M 7B/8B runs by ~30%, and a 4-bit 7B is roughly as fast as an FP16 3B. Quantization kernels, not bit count alone, set decode speed on this GPU.</p><h3>Experiment 2: context length and the KV cache</h3><p>If VRAM were allocated lazily per token, a context sweep would show a rising memory curve. It does not:</p><figure><img alt="Peak VRAM against context length for experimented models" src="https://cdn-images-1.medium.com/max/640/1*5BMQhoPFzT5nK39ARsU9aw.png" /></figure><p>Every engine’s footprint is flat across context lengths, because the KV cache was already allocated at startup for the configured window. The memory cost of context was paid before the first request; the sweep only reveals the <em>compute</em> cost:</p><figure><img alt="Table showing various observed metrics for inference configurations" src="https://cdn-images-1.medium.com/max/1002/1*yt0VnMYT3DH10YyOBTti1g.png" /><figcaption>TTFT grows roughly linearly with prompt tokens — prefill is compute-bound and processes the whole prompt before the first token. TPOT stays essentially constant, because decode attends over the KV cache whose per-token cost is already paid. Long context on this GPU is a <em>latency</em> tax at prefill, not a memory surprise at runtime.</figcaption></figure><p>The memory surprise happens earlier, at startup, when the configured window does not fit:</p><ul><li><strong>vLLM Qwen2.5–7B AWQ at </strong><strong>--max-model-len 4096:</strong> the server refuses to start. After weights and profiling, ~0.16 GiB remained; the minimum KV cache for one 4096-token sequence needs 4096 × 56 KiB = 0.22 GiB. The arithmetic in section 2 predicts the failure exactly. At 2048 it starts and serves (peak 6734 MiB).</li><li><strong>vLLM Qwen2.5–3B at 8192-token prompts:</strong> HTTP 400, because --max-model-len 4096 was the largest window that fit. The engine rejects over-long prompts cleanly rather than dying.</li><li><strong>llama.cpp / Ollama:</strong> no runtime failures at any tested length within their configured windows; the ceiling is whatever -c / num_ctx you chose.</li></ul><p>So the usable context ceiling on this card, per configuration, was: <strong>8192</strong> (llama.cpp Qwen7B, vLLM 0.5B), <strong>4096</strong> (llama.cpp Llama8B, Ollama llama3.1:8b, vLLM 3B), <strong>2048</strong> (vLLM 7B AWQ; Ollama qwen2.5:7b as tested, although its configured window is 4096). A 4-bit 7B on vLLM buys you throughput but sells your context down to 2048; the same weights on llama.cpp keep 8192. That trade — context vs concurrency — is the central budget decision on 8 GB, and no “will it fit” calculator shows it.</p><p>One small anomaly worth reporting: vLLM’s footprint stepped up once during the sweeps (0.5B: 6841 → 6899 MiB; AWQ: 6626 → 6734 MiB at the first 2048-token prefill) and then stayed flat. Longer prefills exercise larger activation buffers, and the caching allocator keeps them. Reserved-vs-used memory is not a static number even in a “preallocating” engine.</p><h3>Experiment 3: what happens when multiple users arrive</h3><p>This is the experiment the article exists for. Same short prompt, 64-token outputs, concurrency 1 → 16.</p><figure><img alt="Count of tokens/s against concurrency for inference-model combinations" src="https://cdn-images-1.medium.com/max/640/1*VXGQuFOB1AZm0wtoe4zFCA.png" /></figure><p>Three qualitatively different curves:</p><p><strong>vLLM scales.</strong> Continuous batching plus the preallocated KV pool means every new request joins the running batch instead of waiting for a slot:</p><figure><img alt="Observed concurrency runs on Qwen2.5 variants using vLLM" src="https://cdn-images-1.medium.com/max/513/1*VLt6fJtuipGeSWsLNaMUGQ.png" /></figure><p>Aggregate tokens/s, mean of 3 runs. The 7B AWQ delivers <strong>12× single-stream throughput at 16 users</strong> while per-request experience barely degrades: p95 end-to-end goes 0.78 s → 1.02 s. The 0.5B reaches ~3074 tokens/s at p95 0.28 s. This is what selling your free VRAM into a KV pool at startup buys you.</p><p><strong>llama.cpp saturates at its slot count.</strong> With 4 auto slots, throughput climbs to ~200 tokens/s at 4 concurrent and then flatlines (198–208 through 16). Extra requests queue: median TTFT jumps from ~40–70 ms at 4 concurrent to ~1.1–1.3 s at 8 and ~2.2–2.5 s at 16. Throughput is capped by compute and slot count; latency absorbs the overflow.</p><p><strong>Ollama serializes.</strong> Aggregate throughput is flat (~45–53 tokens/s) at every level, and latency scales almost perfectly linearly: p95 1.28 s at 1, 1.19 s at 2, 3.87 s at 4, 9.16 s at 8, 19.94 s at 16 (Qwen7B). With one parallel slot, 16 users means 16 sequential generations. Nothing is broken — this is the default configuration doing exactly what it is configured to do.</p><figure><img alt="p95 latency against concurrency for model-inference combinations" src="https://cdn-images-1.medium.com/max/640/1*Ml24n9wHRg1FKCvsTIpy0g.png" /></figure><p>Applying the pre-registered criterion (p95 ≤ 2.0 s, zero failures):</p><figure><img alt="Max concurrency, tokens/s, p95 observed in a table for different models" src="https://cdn-images-1.medium.com/max/918/1*Ap2OqA0ANKfMEhUYRWOs2A.png" /></figure><p>Two observations I did not expect to matter this much:</p><p><strong>Nobody OOMed at request time.</strong> Across every concurrency level and every engine, failed requests = 0. On this GPU, memory exhaustion is a <em>startup or configuration</em> event (section 5), not a runtime event — because all three engines commit their memory up front. Runtime pressure shows up as queueing latency instead. If you only monitor for OOM kills, you will miss the actual failure mode of an overloaded 8 GB server: silently terrible p95.</p><p><strong>The concurrency test was not KV-bound, and that is the point.</strong> With ~20-token prompts and 64-token outputs, 16 sequences of Qwen2.5–7B need only ~75 MiB of KV. The binding constraints in this sweep were slots, batching and compute. Memory sets the <em>context ceiling</em> you can configure; scheduling determines how many users you can serve inside it. A study that only swept concurrency with short prompts would miss the memory story entirely, and a study that only swept context would miss the scheduling story. You need both.</p><h3>Experiment 4: how the engines manage memory</h3><p>The curves above are consequences of three different memory philosophies:</p><p><strong>vLLM: reserve everything, batch everything.</strong> At startup it profiles the model, then converts essentially all remaining VRAM (up to --gpu-memory-utilization) into a PagedAttention KV block pool. Footprint is flat from 1 to 16 concurrent (6734 MiB for the AWQ 7B) because the pool already exists; requests consume blocks, not new allocations. Continuous batching keeps the GPU fed with whatever is in flight. Cost: the reservation is unconditional. A 0.5B model that needs megabytes of KV still holds ~6.7 GiB, and the context ceiling is whatever survives after weights — 2048 for the AWQ 7B.</p><p><strong>llama.cpp: one unified pool, fixed slots.</strong> -c 8192 allocates a single shared KV pool; this build defaults to 4 slots sharing it. Footprint flat at 5015 MiB. Concurrency is bounded by slots (hence the saturation at 4), but the unified pool means one long request can borrow the whole window: a single 8192-token prompt fits here, while vLLM&#39;s AWQ 7B could not even reserve 4096. It is the most <em>context-flexible</em> engine of the three on this card, at the price of a hard concurrency ceiling you must raise explicitly (-np) if you want more slots.</p><p><strong>Ollama: convenience defaults, auto-fit.</strong> Stock settings gave one parallel slot and a 4096-token window: smallest footprint of the three for Qwen7B (4787 MiB), simplest deployment, and linear latency collapse under load. It is llama.cpp underneath, but the defaults — not the kernel — are what you benchmark when you benchmark Ollama. Tuning OLLAMA_NUM_PARALLEL and num_ctx changes the picture; I deliberately measured the out-of-the-box picture, because that is what most installations run.</p><p>A fairness caveat, stated plainly: these are not identical stacks. vLLM ran AWQ/FP16 safetensors with its own kernels; llama.cpp and Ollama ran GGUF Q4_K_M. vLLM’s advantage in aggregate throughput is real for these configurations on this GPU, but it is an engine-plus-format-plus-defaults comparison, not a controlled kernel experiment.</p><h3>8. Pushing the limit: a 12B model on 8 GB</h3><p>After the main sweeps I asked the obvious greedy question: how big a model can this card actually run? Gemma-4–12B-it at Q4_K_M is 6.7 GiB on disk. With a 512-token context it fits — barely, and differently per engine:</p><figure><img alt="Observed metrics for a 12B model" src="https://cdn-images-1.medium.com/max/930/1*r_fkOr0Yyrp6SVPQBIKcgA.png" /></figure><p>llama.cpp forces all layers onto the GPU (-ngl 99): 6792 MiB of weights plus ~520 MiB of KV and buffers at 512 tokens. Ollama&#39;s auto-fit lands ~700 MiB lower — below the GGUF file size, which means part of the weights stayed in system RAM — and pays for it with ~26% slower single-stream decode (23.5 vs 31.8 tokens/s). Same weights, same window, two different placement decisions, two different performance profiles. (The offload is inferred from footprint arithmetic and speed, not from server logs; I flag it as inference.)</p><p>Against the 2 s criterion, 12B is not a serving configuration on this card: llama.cpp passes only at concurrency 1, and borderline (1.97 s and 2.05 s across the two runs); Ollama fails even at 1. vLLM was not tested at 12B: no pre-quantized checkpoint I had would leave room for a KV pool, and FP16 is out of the question.</p><p>What fits, summarized: <strong>7–8B at 4-bit with a real context window and real concurrency; 12B at 4-bit only as a single-stream, 512-token curiosity.</strong> The 8 GB boundary is not “which model loads” but “which model loads <em>with enough budget left to be useful</em>”.</p><h3>9. Results and trade-offs</h3><p>Normalizing throughput by the memory it consumes makes the trade-off concrete (aggregate tokens/s at each config’s sustainable concurrency, divided by its VRAM plateau):</p><figure><img alt="Normalised table showing tokens/s per GB for the configurations" src="https://cdn-images-1.medium.com/max/716/1*36n4MK3vpajLuUu3TKCZjw.png" /></figure><figure><img alt="Complements the above table, a scatterplot of p95 against throughout for all experimented configs" src="https://cdn-images-1.medium.com/max/800/1*IJ_1XN_Jf386ZHydDvus2g.png" /></figure><p>The scatter is the article in one picture: vLLM configurations live in the high-throughput/low-latency corner <em>because</em> they spend memory on reservations; llama.cpp sits mid-throughput with modest memory and excellent context flexibility; Ollama defaults sit at low throughput and low memory, with latency that depends entirely on how many users you admit.</p><p>There is no winner, only workloads:</p><ul><li><strong>Many users, short contexts:</strong> vLLM with a 4-bit checkpoint and a deliberately small --max-model-len. 16 users at ~1 s p95 on a laptop GPU is a genuinely useful service.</li><li><strong>Few users, long contexts:</strong> llama.cpp with -ngl 99 and a large unified -c. 8192 tokens of context on a 4-bit 7B, ~50 tokens/s per user, 4 users at ~1.1 s p95.</li><li><strong>One user, zero ops:</strong> Ollama defaults. Just do not point a team at it.</li></ul><p>And the quantization lesson from Experiment 1 stands: on this GPU, 4-bit was not a compromise on speed — the AWQ 7B was the fastest 7B configuration I measured, single-stream <em>and</em> concurrent. The compromise was context, paid to vLLM’s reservation model, not to the quantization.</p><h3>10. Recommendations, limitations and conclusion</h3><ol><li><strong>Budget KV explicitly before choosing a context window.</strong> sequences × tokens × bytes_per_token (12/36/56/128 KiB for the models here). On 8 GB, treat ~0.5 GiB as untouchable headroom for activations and fragmentation.</li><li><strong>On vLLM, </strong><strong>--max-model-len is your real memory dial.</strong> 4096 vs 2048 was the difference between &quot;server refuses to start&quot; and &quot;16 concurrent users at 1 s p95&quot; for the AWQ 7B. Set it to what your workload needs, not to the model&#39;s maximum.</li><li><strong>On llama.cpp, set </strong><strong>-np to your expected concurrency</strong> and remember -c is a shared pool in recent builds. The default 4 slots is a fine default and a hard ceiling.</li><li><strong>On Ollama, change the defaults before serving anyone else.</strong> OLLAMA_NUM_PARALLEL and num_ctx are the difference between linear latency collapse and actual batching.</li><li><strong>Monitor p95, not OOMs.</strong> Preallocating engines fail by queueing, not by crashing. A flat VRAM graph and a climbing p95 is the signature of an overloaded 8 GB server.</li></ol><p>What this study does not establish: results are from one laptop GPU (thermals were not logged; sustained runs may throttle differently), one prompt shape and a 64-token output cap, so prefill-heavy or long-generation workloads will shift the balance; p95 over ≤16 samples is a coarse tail estimate; VRAM polling at 100 ms can miss brief spikes; no output-quality evaluation was run, so quantization quality trade-offs are unmeasured here; Q8_0/FP16 GGUFs were converted but not successfully benchmarked; the 12B runs lack TTFT/TPOT because the harness captured usage totals but no content deltas for that model; and engine comparisons mix quantization formats and kernels. Early pilot records (a 32-token pilot run, pre-metadata records, and connection-refused attempts against a server that was not up) were excluded from analysis and remain in the raw data for transparency.</p><p>What it does establish, on this machine and stack: <strong>fitting a model into VRAM is an entry fee, not a capability.</strong> The 8 GB budget is spent three ways — weights, KV capacity, and scheduling headroom — and every engine spends it differently. vLLM trades context for concurrency; llama.cpp trades concurrency for context; Ollama’s defaults trade both for simplicity. Quantization decides how much budget survives the weights; the engine decides what that budget can buy; and the only way to know which purchase suits your workload is to measure concurrency and context together, against a criterion you fixed in advance.</p><p>I started this project expecting to write “here is how big a model you can run on 8 GB”. The measurements rewrote the title: here is how much <em>serving</em> you can run on 8 GB, and what you must give up to get it.</p><p>Link to project files: <a href="https://github.com/pryyyynz/model-analysis">https://github.com/pryyyynz/model-analysis</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4878f37632cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Built a Private, Multimodal Search Engine for My Entire Digital Life — On One 8 GB GPU]]></title>
            <link>https://medium.com/@dugboryeleprince/i-built-a-private-multimodal-search-engine-for-my-entire-digital-life-on-one-8-gb-gpu-b68d55de4eec?source=rss-303561abde62------2</link>
            <guid isPermaLink="false">https://medium.com/p/b68d55de4eec</guid>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[vlm]]></category>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[clip]]></category>
            <dc:creator><![CDATA[Prince Kojo Dugboryele]]></dc:creator>
            <pubDate>Sat, 27 Jun 2026 17:03:08 GMT</pubDate>
            <atom:updated>2026-06-27T17:03:08.330Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A local-first system that makes your photos, journals, voice notes, screenshots, email, calendar, and browser history searchable by meaning — and answers questions about your own life — without a single byte leaving your machine.</em></p><h3>The problem: I couldn’t find my own memories</h3><p>A few months ago I went looking for a whiteboard photo I’d taken after a brainstorming session. I knew it existed. I knew roughly when. And I still spent twenty minutes scrolling a camera roll, then grepping a notes folder, then searching my email — because the thing I wanted lived as <em>pixels in a JPEG</em>, and nothing I owned could read it.</p><p>That’s the strange thing about a modern digital life: it’s enormous, it’s all “mine,” and almost none of it is searchable in the way I actually think. I don’t remember filenames or dates. I remember <em>“the screenshot with the wifi password,”</em> or <em>“the day I was at the beach,”</em> or <em>“that voice memo where I planned the trip.”</em></p><p>So I built Life Log Search: one natural-language search box over everything — text, photos, audio, video, email, calendar, browser history — that runs entirely on my own hardware and can both find the right moment and answer questions about it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*liytxUH4IiM5gngg7mq9dw.png" /><figcaption><em>Figure 1 — The whole system lives inside one boundary: your machine. Sources are ingested and enriched, embedded, stored in Qdrant + SQLite, and served through a hybrid-retrieval + RAG layer to a small web UI</em></figcaption></figure><p>A few real queries it now handles:</p><ul><li><em>“the screenshot with the Airbnb wifi password”</em> → resolves to a photo by reading the text inside the image (OCR).</li><li><em>“what did the whiteboard from the brainstorm say?”</em> → returns a cited answer synthesized from the content of that photo.</li><li><em>“the voice memo where I planned the trip budget”</em> → surfaces an audio clip by its transcript, not its filename.</li></ul><p>None of those are filename matches. They’re meaning matches, across modalities, and that’s the whole point.</p><p>This post is the engineering tour: the constraint that shaped every decision, the one architectural idea that made multimodality tractable, the retrieval pipeline, and the unglamorous bugs that turned out to matter most.</p><h3>The constraint that shaped everything</h3><p>Two rules, fixed up front, drove every subsequent choice:</p><ol><li>Strictly local, always. No cloud inference. No “optional” cloud enrichment. Setup may download model weights, but normal operation must never depend on a third-party API. Your journal is not training data and your photos are not someone’s telemetry.</li><li>One consumer GPU — 8 GB of VRAM.</li></ol><p>For an ML engineer, the second rule is where it gets interesting, because rule #1 takes the easy escape hatch off the table. You can’t shrug and call an API for the embeddings, or the vision model, or the LLM. Every capability — text embeddings, image embeddings, transcription, captioning, OCR, a vision-language model, <em>and</em> a generative LLM for answers — has to fit on the same 8 GB card.</p><p>It does not fit. Not simultaneously. So the system is built around a single, uncomfortable fact: the models take turns. More on that scheduling problem later — first, the idea that made the data side tractable.</p><h3>The keystone idea: “describe pixels as text”</h3><p>The naive way to build multimodal search is to maintain a separate stack per modality: a text search engine, an image search engine, an audio search engine, each with its own index, ranking, and quirks. That’s N pipelines to build, tune, and keep consistent — and fusing their results is a nightmare because their scores don’t mean the same thing.</p><p>I went the other way. The core move is:</p><blockquote><em>Wherever possible, turn a non-text modality into text, and let one text pipeline serve all of it.</em></blockquote><p>A photo isn’t just an opaque vector. Run it through local vision models and it <em>becomes</em> text: the words inside it (OCR), a description of the scene (captioning), the objects and settings present (zero-shot tags), who’s in it (face identities), and — for video — what’s happening (action recognition). Each of those outputs is written back as a derived text chunk, tagged with metadata.derived_from so I always know it was machine-generated, and it then flows into the exact same embedding-and-retrieval path as a journal entry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sWZZr0ijCZTK-XIDzVqB1w.png" /><figcaption><em>Figure 2 — One image fans out to six local models. Their outputs converge as derived text chunks into a single e5 + BM25 pipeline. CLIP keeps a separate lane for pure visual similarity</em></figcaption></figure><p>This buys two things that matter enormously:</p><ul><li>One ranking pipeline. Everything competes in the same scoring space, so cross-modal fusion is principled instead of hand-wavy.</li><li>Cheap extensibility. Adding a new modality means writing <em>one ingestor class</em> — not touching retrieval at all. (This was an explicit design objective; the retrieval layer has never had to learn about a new source type.)</li></ul><p>CLIP still gets its own lane for <em>pure</em> visual similarity (“find me photos that look like this”), because some queries really are about pixels, not words. But the default path for “what was in that image” is text.</p><h3>Ingestion: from raw files to normalized chunks</h3><p>Ingestion is deliberately boring, which is a compliment. Each source — text, images, audio, video, email, calendar, browser history — has a connector that discovers items, extracts raw content, and normalizes everything into a single shared contract, the NormalizedChunkRecord. That record carries chunk identity, source type, file path, timestamps, coordinates, a session id, the target vector collection, and modality-specific metadata.</p><p>A few modality specifics worth calling out:</p><ul><li>Audio &amp; video are transcribed locally with WhisperX (large-v3); the transcript becomes searchable text, and video is chunked per-scene so a 3-file corpus doesn&#39;t masquerade as 30 results.</li><li>Photos contribute EXIF timestamps and GPS, with optional (and offline-toggleable) reverse geocoding so “where was I” has an answer.</li><li>Storage is split by job: Qdrant (in Docker) holds the dense vectors; SQLite holds metadata, the source registry, and ingest-run bookkeeping. Vectors and facts have very different access patterns, and keeping them separate keeps each store simple.</li></ul><p>Ingest is incremental — re-running only processes new or changed inputs — and a file watcher picks up changes so the index stays warm without a manual rebuild.</p><h3>The enrichment pass: local vision on a strict budget</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S_lkWJrzFRpugx6ytp-2FA.png" /><figcaption><em>Figure 3 — Every capability is handled by a local model. Nothing in this list calls out to an API</em></figcaption></figure><p>Now the 8 GB problem becomes concrete. You cannot hold a VLM <em>and</em> a generative LLM resident at once on this card. So enrichment runs as a low-priority background pass that processes one model at a time, and — critically — it yields to live queries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gZkZGh-QDowuVMDUjq_WRQ.png" /><figcaption><em>Figure 4 — The GPU is a single resource that the workloads time-share. A query trips a </em><em>_query_in_progress gate; the background enrichment pass releases the GPU, the query path runs its models one at a time, then enrichment resumes where it left off</em></figcaption></figure><p>When a query arrives, a gate flips, the enrichment pass parks itself, and the GPU is handed to the retrieval and answer path. When the answer is sent, enrichment picks back up. It’s cooperative scheduling — not glamorous, but it’s the honest way to run a vision model and an 8B LLM on hardware that can’t hold both. Interactivity always wins; background understanding fills in the gaps when you’re not looking.</p><p>Faces get a special mention. InsightFace produces an embedding per detected face; an incremental greedy cosine-clustering step groups them. You name a cluster once (“this is Mum”), and that name is written back as a searchable person:&lt;cluster_id&gt; text chunk — so &quot;photos of Mum at the beach&quot; is just a normal multimodal query again. The &quot;describe pixels as text&quot; pattern, applied to identity.</p><h3>Retrieval: hybrid search, done properly</h3><p>This is the heart of it. A query doesn’t hit a single index — it runs three retrieval paths in parallel and then earns its ranking through fusion and reranking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJ202MaFPqucBmGqse5kEQ.png" /><figcaption><em>Figure 5 — The retrieval and answer pipeline. Three parallel paths, fused and reranked, then grouped — and only then does the LLM summarize what was actually retrieved</em></figcaption></figure><p>Walking the pipeline:</p><p>1. Query analysis &amp; decomposition. The query is parsed for intent and for temporal/spatial hints. Complex questions (long, or joined by “and”/”then”) are decomposed into up to three sub-queries, each retrieved independently and merged by max score — with the original query always appended so recall never suffers from a bad split.</p><p>2. Three parallel retrievers:</p><ul><li>BM25 for sparse keyword matching — with real tokenization and stopword stripping, so <em>“sunset on the beach”</em> doesn’t waste its signal matching “on” and “the.”</li><li>Dense e5 for semantic text and transcripts — the path that understands <em>meaning</em>, including all those derived chunks from images and audio.</li><li>CLIP for visual similarity, locked to the right image/video collection so a photo filter doesn’t leak video frames.</li></ul><p>3. Reciprocal-rank fusion (RRF) merges the three ranked lists into one. RRF is rank-based, so it doesn’t care that BM25 scores and cosine similarities live on different scales — exactly what you want when fusing heterogeneous retrievers.</p><p>4. Temporal boost. An explicit date range in the query is treated as a <em>hard</em> filter (drop out-of-range hits, with a fallback to keep-all when nothing lands in range), and the range midpoint becomes a soft recency/closeness boost.</p><p>5. Cross-encoder rerank. A ms-marco-MiniLM cross-encoder re-scores the top candidates — but applied as a multiplicative boost (score × (1 + α·sigmoid(logit))) rather than <em>replacing</em> the fused score. That detail matters: a replacing reranker throws away the temporal signal and the fusion evidence; a multiplicative one refines them.</p><p>6. Session grouping. Hits that belong together in time are grouped into SessionCards, so the UI shows coherent moments instead of 40 disconnected fragments.</p><p>The three contracts — NormalizedChunkRecord (ingest → storage), RetrievalHit (the ranking unit), and SessionCard (the presentation unit) — are the spine that keeps these layers decoupled. Each layer only speaks the contract.</p><h3>The bugs that actually mattered</h3><p>The architecture diagram is the easy 20%. Here’s the part nobody puts in the README — the silent failures that made search feel “meh” until I hunted them down:</p><ul><li>Dense semantic search was completely dead for months. Text embedding defaulted <em>off</em> at ingest, so the dense vectors were never built — every “semantic” search was secretly BM25 keyword-only. Worse, a metadata bug hid these chunks from the backfill reconciler, so they looked fine. The fix was a backfill that embedded each chunk’s own passage:-prefixed text and a config flag flipped on by default. The day dense text actually fired, the trip-budget voice memo started coming back by what I&#39;d actually said in it — instead of nothing.</li><li>The cross-encoder was burying every photo. It scored text-less image hits against an empty string, assigned them near-zero, and sank them. Fix: skip text-less hits in the reranker entirely.</li><li>CLIP injected scanned-document noise. CLIP fires on essentially every query, dropping a couple of scanned-doc photos in at the RRF floor score. Harmless when strong text matches exist (the cross-encoder floats them above), but visible when text matches are weak. A known, bounded tradeoff I chose to leave rather than risk suppressing legitimate cross-modal hits.</li></ul><p>If there’s a lesson here, it’s that retrieval quality is mostly operational hygiene, not algorithms. The fancy parts worked from day one; the embeddings silently never being built, is what made it feel broken.</p><h3>From results to a cited answer</h3><p>Grouped cards are useful, but often I don’t want ten results — I want the answer. So the top session cards are handed to an AnswerSynthesizer running on a local LLM (qwen3:8b via Ollama), which writes a grounded, natural-language answer with inline [n] citations that map back to specific sessions. It answers in its own voice — not RAG boilerplate — and it only summarizes what was actually retrieved, so it can&#39;t invent a memory you don&#39;t have.</p><p>One local model wears three hats — answers, query planning, and chit-chat — and it swaps VRAM with the embedding and vision models per the scheduling dance above. And the entire answer layer degrades gracefully: if Ollama isn’t running, the pipeline quietly falls back to ranked session cards. Nothing in the core search path depends on the LLM being up.</p><h3>It’s not just reactive: proactive intelligence</h3><p>Search answers questions you think to ask. A life log should also surface things you didn’t:</p><ul><li>On this day — memories from the same date in past years.</li><li>Daily &amp; weekly digests — a recap of what happened, LLM-narrated with a deterministic fallback.</li><li>Auto session titles &amp; summaries — so cards read like moments, not query dumps.</li><li>Insights — top places, busiest weekday and month, recurring places across years.</li></ul><p>A deliberate design choice: the insights are deterministic first. The statistics are computed from the data and are true whether or not the LLM is available; the model only <em>narrates</em> them. I never want a “your year in review” that’s a hallucination.</p><h3>Taking it to my phone — without breaking the privacy model</h3><blockquote>The whole thing runs on a PC, but I wanted it from my phone. The obvious answer — host it in the cloud — would torch the entire premise. So the data stays home and only <em>queries and results</em> travel.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sYnTMQjbknE8RhG5JtnPVQ.png" /><figcaption><em>Figure 6 — The frontend is the only thing in the cloud. It proxies same-origin </em><em>/api calls through a Cloudflare tunnel to the backend on the PC. Personal files never cross the boundary — only the query and the results do</em></figcaption></figure><p>The topology: phone → a Vercel-hosted frontend over HTTPS → the frontend proxies same-origin /api calls through a Cloudflare tunnel → FastAPI on the PC. Because the browser only ever talks to one origin, there&#39;s no CORS and no mixed-content to fight. Access is gated by a single-user app password (an HMAC-signed token, validated by middleware), and the same token can ride as a ?token= query param so &lt;img&gt;/&lt;video&gt; preview tags authenticate too.</p><p>The frontend is also an installable PWA with a share-target, so I can share a photo straight from the OS share sheet into ingest. The important invariant: the only bytes that ever leave the machine are the query text and the ranked results — never the photos, journals, or audio they came from.</p><h3>What I’d do differently, and what’s next</h3><p>Honest tradeoffs and open threads:</p><ul><li>The VRAM ceiling forces serialization. Cooperative scheduling works, but cold-start model loads add latency to the first query after an enrichment burst. Smarter model residency (keep the small embedder hot, swap only the big models) is the obvious next win.</li><li>CLIP → SigLIP2. A stronger image-text backbone would improve the visual lane and shrink the scanned-doc noise problem.</li><li>Smarter entity handling. Wiring named-entity recognition into place/person <em>filters</em> (not just ranking) would make “photos of X in Paris last spring” sharper.</li><li>Better backfill ergonomics. The “embeddings silently never built” class of bug should be impossible — enrichment should always push its vectors to the index in the same transaction.</li></ul><h3>Closing</h3><p>The constraint turned out to be the feature. Being forced to run everything locally on a single 8 GB GPU — no cloud escape hatch — pushed me toward a cleaner architecture: one “describe pixels as text” pattern that unifies modalities, one honest scheduler that time-shares the GPU, and a retrieval pipeline where every result can explain where it came from. The privacy guarantee isn’t a compromise on capability; it’s the thing that made the design coherent.</p><p>The stack, in one breath: FastAPI + SQLite + Qdrant, a local model suite (e5-large-v2, OpenCLIP ViT-L-14, WhisperX, a MiniLM cross-encoder, BLIP, X-CLIP, Qwen2-VL-2B, InsightFace), Ollama (qwen3:8b) for answers, and a Next.js PWA reachable over a Cloudflare tunnel — all on one machine, nothing leaving it.</p><p>Code: <a href="http://github.com/pryyyynz/lifelog">github.com/pryyyynz/lifelog</a></p><p>If you’ve got a GPU and a digital life you can’t search, build your own. The most useful AI you run might be the one that only you can see.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b68d55de4eec" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>