<?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[OpusClip AI Engineering &amp; Research - Medium]]></title>
        <description><![CDATA[Stories from the people who build OpusClip - Medium]]></description>
        <link>https://medium.com/opus-engineering?source=rss----2fafb4e68ba5---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>OpusClip AI Engineering &amp;amp; Research - Medium</title>
            <link>https://medium.com/opus-engineering?source=rss----2fafb4e68ba5---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:41:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/opus-engineering" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A scalable LLM-as-a-Judge framework for video quality evaluation]]></title>
            <link>https://medium.com/opus-engineering/a-scalable-llm-as-a-judge-framework-for-video-quality-evaluation-74612034bd1e?source=rss----2fafb4e68ba5---4</link>
            <guid isPermaLink="false">https://medium.com/p/74612034bd1e</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[evaluation]]></category>
            <category><![CDATA[judges]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[video-quality]]></category>
            <dc:creator><![CDATA[OpusClip AI & Engineering Team]]></dc:creator>
            <pubDate>Mon, 08 Dec 2025 05:22:04 GMT</pubDate>
            <atom:updated>2025-12-08T06:11:25.113Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Written by Zora Zhang, Jacob Ji, and Sheng Shen, Curation Team</em></p><p>Evaluating short-form video quality has always been a challenging problem. There’s <strong>no universally accepted definition of what “quality” actually means</strong>, and most judgments rely on <strong>subjective human perception</strong>. Human evaluation is not only <strong>slow and costly</strong>, but also <strong>hard to reproduce</strong> consistently across different evaluators or time periods. While the industry has developed mature metrics for low-level aspects, like visual fidelity or compression quality, <strong>there’s still no standardized way to evaluate video content quality</strong> in dimensions such as storytelling, engagement, or informational value.</p><p>At OpusClip, we previously integrated an online Judge step into our production pipeline, but the earlier version faced clear limitations — the framework wasn’t generalizable, and the pipeline lacked scalability and traceability across different use cases. It also couldn’t flexibly support offline workflows or specialized evaluation scenarios that required customized rubrics or data control. Moreover, the previous Judge only relied on text-based cues and lacked visual and audio evaluation capabilities, making it difficult to assess holistic clip quality such as framing, sound clarity, and editing rhythm.</p><p>To overcome the limitations of earlier evaluation methods, we rebuilt the system into a <strong>new LLM-as-a-Judge framework</strong> that combines human-like understanding with structured, rubric-based assessment. By integrating video, audio, and text signals, the Judge delivers more accurate, human-aligned evaluations while offering a flexible and reproducible mechanism that adopts an end-to-end pipeline spanning data, model, and business integration. The upgraded system delivers three key capabilities that directly address prior pain points:</p><ul><li><strong>Reliable:</strong> Rubric-guided scoring aligns closely with human annotation, with each evaluation grounded in explicit reasoning and validated against golden samples to ensure consistency and trustworthiness.</li><li><strong>Extensible:</strong> Thanks to its modular design, the Judge can adapt to new evaluation scenarios simply by plugging in scenario-specific samples and rubrics — allowing rapid deployment of domain-relevant evaluation systems without rebuilding from scratch.</li><li><strong>Automated:</strong> From sample collection and annotation to model calibration and evaluation, the entire lifecycle is automated through scripts and APIs, supporting scalable, repeatable evaluations with less manual work.</li></ul><p>Together, these design principles transform the Judge from a single-purpose model into a <strong>reliable, extensible evaluation service</strong> — capable of powering both offline benchmarking and online quality monitoring across OpusClip video ecosystem.</p><h3>Behind the Scenes: How We Built the Judge System</h3><p>To understand why the Judge works, it helps to look at how it’s built — the system structure, the data pipeline, the rubrics, and the iteration workflows that shape the model’s behavior.</p><p>At a high level, our LLM-as-a-Judge pipeline works as a continuous loop between <strong>rubrics</strong>, <strong>data</strong>, and <strong>models</strong>. Rubrics define <em>what</em> we want to measure. The dataset pipeline collects and annotates examples that reflect those rubrics. The model iteration loop then uses these annotated samples to refine the Judge — evaluating, correcting, and re-prompting until the model consistently aligns with human expectations. Finally, the production judge feeds back into real business scenarios like content curation, generating new insights and new failure cases that drive the next cycle of improvements.</p><p>This creates a full, self-sustaining workflow: <strong>define → collect → annotate → iterate → validate → apply → improve.</strong></p><p>The diagram below summarizes how all components work together — from rubric setup to sample annotation to offline evaluation and iterative prompt/model refinement:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WZKD9czMNljHVzUj.png" /></figure><h3>Data preparation</h3><p>Building a trustworthy dataset for subjective video evaluation is deceptively hard.</p><p>For our Judge to learn human taste, we needed data that was statistically reliable, diverse enough to represent real-world content, and annotated with high-quality human labels. Getting this foundation right turned out to be one of the most crucial parts of the entire system.</p><blockquote><strong>How large should the dataset be?</strong></blockquote><p>The first question we faced was surprisingly fundamental: <strong>How much data is enough?</strong></p><p>Collecting and annotating more samples improves stability, but every additional sample comes with real cost — especially when each one requires multi-rubric human labeling. We needed a principled way to balance statistical confidence with operational efficiency.</p><p>To do this, we used the binomial proportion confidence interval to estimate the minimum sample size needed for a target agreement rate. For example, validating an 80% human–LLM agreement at 95% confidence requires roughly <strong>246 samples</strong>.</p><p>This gave us a quantitative target that kept annotation cost manageable while ensuring evaluation reliability.</p><blockquote><strong>Where do the samples come from?</strong></blockquote><p>A robust Judge requires representative examples across the quality spectrum — not just good clips or popular clips, but also weak, noisy, or user-disliked ones.</p><p>We built an automated data-fetching workflow that pulls from four internal sources:</p><ul><li><strong>✅ Good clips:</strong> golden samples, and high-view videos</li><li><strong>❌ Bad clips:</strong> low-view clips or those explicitly disliked by users</li></ul><p>However, raw sampling tends to produce a biased dataset — most clips fall into mid-quality, with too few extreme cases. To fix this, we first ran the LLM Judge on all candidates, then selected a subset with a <strong>more uniform score distribution</strong>, ensuring:</p><ul><li>balanced high / medium / low total scores</li><li>each rubric includes clear examples of <strong>0 / 1 / 2</strong></li></ul><blockquote><strong>How do we annotate at scale?</strong></blockquote><p>Annotation quickly became a bottleneck — human review was slow, costly, and hard to scale. We needed a way to <strong>accelerate labeling</strong> while still ensuring <strong>rubric-level reliability</strong>.</p><p>To solve this, we adopted a <strong>human–LLM collaborative workflow</strong>, supported by an internal annotation tool built specifically for rubric-based scoring:</p><p><strong>Step 1: LLM pre-annotation</strong></p><p>The Judge model first generates rubric-level scores and short rationales for every clip. This provides a structured starting point and reduces redundant human work.</p><p><strong>Step 2: Human verification (via our internal annotation tool)</strong></p><p>Annotators then review, correct, or confirm the model’s output using our internal annotation interface — a tool that supports:</p><ul><li>side-by-side video preview with LLM pre-annotation results</li><li>per-rubric scoring &amp; rationale inputs</li><li>rubric guideline expansion for quick reference during judgment</li><li>one-click save &amp; upload to store final annotations into the dataset pipeline</li></ul><p><strong>Step 3: Multi-annotator validation</strong></p><p>Each clip is annotated by multiple reviewers, and the final ground truth is derived through <strong>majority voting</strong> — with escalation to expert review if needed.</p><p>In addition, requiring annotators to write concise <strong>rationales</strong> for each score also improved transparency and provided high-quality reasoning data for <strong>LLM tuning</strong> and future <strong>rubric refinement</strong>.</p><h3>Rubric design</h3><p>At the heart of our Judge system is a set of rubrics — the blueprint that tells the model <em>what good video taste looks like</em>. Good rubrics turn subjective opinions into structured, repeatable evaluation signals, and designing them well turned out to be one of the most defining parts of the entire project.</p><p>We ultimately converged on <strong>four major dimensions of short-form video quality</strong>, each capturing a different facet of user perception:</p><ul><li><strong>Hook</strong> — Does the clip immediately make sense? Is it engaging enough for viewers to stay?</li><li><strong>Content</strong> — Is the message clear, complete, and logically delivered?</li><li><strong>Visual</strong> — Does the video look good? Framing, assets, overlay, production value.</li><li><strong>Audio</strong> — Is the sound clean, intelligible, and free from distracting noise?</li></ul><blockquote><strong>How granular should a rubric be?</strong></blockquote><p>This was an early and surprisingly tricky question:</p><p>Too coarse, and the Judge can’t distinguish meaningful differences.</p><p>Too fine-grained, and both humans and LLMs collapse into inconsistent scoring.</p><p>Through multiple iterations, we found that <strong>simpler rubrics generalize better</strong>: a 0–1–2 scale strikes the best balance between interpretability and expressiveness. When rubrics had too many score levels, both human and LLM judgments became unstable. With the 3-level structure, human agreement improved significantly, and the LLM’s calibration converged faster.</p><blockquote><strong>How do we make rubrics clear and actionable?</strong></blockquote><p>A rubric only works if annotators — human or LLM — can apply it without guessing.</p><p>We applied some design principles to make each rubric self-contained and unambiguous:</p><ul><li><strong>Explicit definitions</strong> for all score levels</li><li><strong>Quantifiable cues</strong> wherever possible</li><li><strong>Positive and negative examples</strong> to illustrate score boundaries</li></ul><blockquote><strong>How do we verify the rubrics actually work?</strong></blockquote><p>Once the rubrics were defined, we needed to verify whether they actually worked — both for humans and for the model.</p><p>We adopted a three-step rubric evaluation process:</p><ol><li><strong>Human alignment check:</strong> Three annotators independently scored the same clips to test agreement.</li><li><strong>Model consistency check:</strong> The Judge model was run multiple times to assess scoring stability.</li><li><strong>Orthogonality analysis:</strong> We examined correlations across rubrics to ensure that each measured a distinct aspect of quality.</li></ol><h3>Model iteration &amp; eval</h3><p>Rubrics and data define the Judge’s initial “taste,” but iteration is what shapes it into a reliable, deployable evaluation system. In practice, refining an LLM Judge is a continuous interplay between human insight, model behavior, and meta-prompt refinement.</p><blockquote><strong><em>How do we iterate the Judge efficiently?</em></strong></blockquote><p>We eventually built two complementary improvement pathways: one grounded in <strong>Human-in-the-loop</strong>, the other driven by <strong>Meta-prompt</strong> automation. Each shines in different scenarios.</p><ul><li>When failure patterns are interpretable, they are fed into the <strong>Human-in-the-loop</strong> route — human reviewers diagnose concrete misjudgments (e.g., caption vs. overlay confusion, missing hook content, or poor visual grounding) and directly refine prompt definitions or rubric examples. This path offers fast, targeted improvements with explicit rationales, though it remains limited by manual scalability.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qo21lYeGZMRZ34Jj" /><figcaption>pathway 1. judge as human in the loop</figcaption></figure><ul><li>For the human-driven route, the main artifact is a refined prompt segment or a new example appended to the rubric definition.</li><li>When causes are diffuse or multi-factorial, we tried the <strong>Meta-Prompt</strong> pipeline for automated meta-analysis — this pipeline will aggregate current judgments and human feedback into a meta-prompt that generates revised heuristics or evaluation prompts. This enables multi-round, self-reflective refinement at scale, but with potential risks of bias or hallucinations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YdBhFQkvkV_0RJjC.png" /><figcaption>pathway 2. judge as meta-prompting</figcaption></figure><ul><li>For the meta-driven route, the output is an overall <strong>revised meta-prompt candidate</strong> which is then stress-tested on the <em>anchor set</em> (a fixed subset of known judgments) to ensure no regression before rollout.</li><li>Overall, human insight anchors interpretability and domain knowledge, while meta-prompt automation accelerates scalability and adaptability across new categories or rubric expansions.</li></ul><blockquote><strong>How do we evaluate the Judge effectively?</strong></blockquote><p>Iteration only matters if you can measure progress rigorously.</p><p>We designed a three-part evaluation framework to ensure the Judge is <strong>stable, aligned, and business-relevant</strong>.</p><p><strong>Evaluation 1: Consistency and Repeatability (Judge Stability)</strong></p><ul><li><strong>Metrics:</strong> Measure intra-model consistency through <em>exact match rate</em> and inter-run agreement metrics, computed per dimension (<em>hook</em>, <em>storyline</em>, <em>visual, audio</em>).</li><li><strong>Procedure:</strong> Before and after each prompt update, rescore a fixed <strong>Anchor Set</strong> of 100–200 videos multiple times (&gt;=3). Require low variance across dimensions; otherwise, the new prompt is not promoted for deployment.</li></ul><p><strong>Evaluation 2: Human Alignment (Agreement Rate)</strong></p><ul><li><strong>Metrics:</strong> Compute rubric-level <strong>Spearman/Pearson correlations</strong>, weighted accuracy (with ±1 label tolerance), and macro/micro <strong>F1 scores</strong> between Judge outputs and human annotations.</li><li><strong>Data Source:</strong> Use the multi-annotator majority-vote truth set defined in Section 3.2, and preserve human rationales for comparison against Judge rationales.</li><li><strong>Threshold:</strong> Any newly added or modified rubric must achieve <strong>no-regression</strong> performance on the offline validation set and demonstrate improvements across both high- and low-score samples (to avoid “mean-only” illusions).</li></ul><p><strong>Evaluation 3: Business Correlation</strong></p><ul><li><strong>Metrics:</strong> Correlation with <strong>Export Rate</strong> and <strong>View Count (VV)</strong>; compute <strong>ranked quantile gaps</strong> (difference between Top-K and Bottom-K mean scores) and <strong>AUC</strong> treating “view and exported vs. viewed but not exported” as a binary target.</li><li><strong>Reference:</strong> Offline and online studies have shown that high-quality clips consistently receive higher Judge scores and correlate positively with user engagement. Formalize this analysis as a mandatory <strong>business alignment dashboard</strong> for every pre-release evaluation.</li></ul><p><strong>Failure Mode Regression (Failure Taxonomy &amp; Tests)</strong></p><ul><li><strong>Definition:</strong> Maintain a live catalog of known failure patterns (e.g., captions misclassified as overlays, over-extended hook truncation judgments, or misinterpreted colloquial speech).</li><li><strong>Procedure:</strong> For each failure type, curate 5–10 Minimal Reproducible Examples.</li><li><strong>Requirement:</strong> Every prompt update must show measurable improvement on the failure list with no new regressions. Incorporate these examples into the <strong>“discriminative examples”</strong> section of the Meta-Prompt, extending the negative examples portion of the prompt for self-correction.</li></ul><h3>Validation: Does It Actually Work?</h3><p>After building the Judge and tuning it across rubrics, data, and model iterations, the natural next question is simple: <strong>Does it actually work?</strong></p><p>To answer that, we validated the Judge from two angles:</p><ol><li>how well it aligns with human annotations, and</li><li>how strongly it correlates with real business outcomes.</li></ol><h3>Performance on data samples</h3><p>To understand whether our Judge truly reflects human taste, we ran a two-phase evaluation — first on a small set of high-quality golden samples for prompt refinement, and then on a larger, statistically representative dataset to validate generalization.</p><p><strong>Phase 1 — Tuning with Golden Samples (60 clips)</strong></p><p>We started with 60 carefully annotated clips to calibrate rubrics and iterate on prompts.</p><p>On this set, the Judge reached <strong>76.9% rubric-level accuracy</strong>, giving us an initial signal that the system was learning the right evaluation patterns.</p><p><strong>Phase 2 — Testing Generalization (190 additional clips)</strong></p><p>After tuning, we expanded to a total of <strong>250 samples </strong>— the minimum required to validate an 80% expected agreement rate with 95% confidence.</p><p>Across this broader dataset, the Judge achieved a comparable <strong>75.2% accuracy</strong>, showing that performance remained stable even on unseen clips.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8qHoSOJHpHu0xKB7e-_zCg.png" /><figcaption>Rubric accuracy across sample sets</figcaption></figure><p>Accuracy measures alignment with human labels, but consistency tells us whether the Judge behaves like a real evaluator — making stable decisions instead of random ones.</p><p>To measure stability, we scored the 60 golden samples <strong>eight times</strong> and computed per-rubric variance.</p><p>The results were encouraging:</p><ul><li>Most rubrics showed <strong>very low variance</strong> (<em>mean std &lt; 0.15</em>). → The Judge gives nearly identical scores on repeated evaluations.</li><li>Variance was slightly higher on naturally subjective dimensions (e.g., <strong>Engagement</strong>, <strong>Hook Info Standalone</strong>) → matching human annotator disagreement patterns.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MvpWI19mCYT4IzKZDOUr9A.png" /></figure><h3>Validation with business metrics</h3><p>Technical accuracy is one thing — but does the Judge actually <em>matter</em> for the business?</p><p>To find out, we ran an offline–online validation using <strong>648 randomly sampled production clips</strong> (all created on the same day to eliminate temporal or project bias). Each clip was scored by the LLM Judge, then grouped into five score bands with roughly balanced sample sizes.</p><p>For each band, we measured two key metrics:</p><ul><li><strong>Export Rate</strong> — the percentage of clips that users <em>actually exported</em> (i.e., downloaded or posted to a social platform). In OpusClip, export rate is one of the strongest indicators of “this clip is good enough for a creator to use”.</li><li><strong>Normalized Recall</strong> — a reweighted metric assuming equal sample count across score bands — useful for understanding each band’s contribution to total exports independent of sampling imbalance.</li></ul><p>And here’s what the data shows:</p><p><strong>📈 Higher Judge score → higher likelihood of being exported</strong></p><p>As the plot below illustrates, export rate climbs steadily from <strong>13%</strong> in the lowest band to <strong>35%</strong> in the highest band. Normalized recall tells a similar story: if every band had the same number of clips, the highest-scoring band alone would contribute <strong>〜⅓ of all exports</strong>.</p><p>This is a strong signal: <strong>Judge scores don’t just match human perception. They meaningfully predict real user behavior.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Plmip5cnqW9xzBcl" /><figcaption>Export rate &amp; normalized recall for each score range</figcaption></figure><h3>What’s Next: Where We Go From Here</h3><p>Building a rubric-based, human-aligned Judge is just the beginning. The next phase focuses on two fronts: making the system smarter, and bringing it into more real-world workflows.</p><p><strong>Evolving the System</strong></p><p>We plan to deepen the Judge’s evaluative abilities and make the framework more adaptive:</p><ul><li><strong>Richer rubrics:</strong> Extend current dimensions to cover more rubrics like smoothness, intent clarity, and audience alignment.</li><li><strong>Rubric evaluation model:</strong> Build an internal evaluator to automatically assess rubric coverage and inter-rubric correlation.</li><li><strong>Generative rubrics:</strong> Explore LLM-generated rubrics that adapt automatically to new content types or evaluation goals.</li><li><strong>Meta-prompt iteration:</strong> Improve the meta-prompt layer to drive structured, scalable refinement of how the Judge reasons.</li><li><strong>Fine-tuning:</strong> Use accumulated annotations and rationales to fine-tune Judge models for greater stability and domain accuracy.</li></ul><p><strong>Expanding Real-World Applications</strong></p><p>With a reliable core in place, the next step is expanding where and how the Judge is used:</p><ul><li><strong>Online integration:</strong> Bring the Judge into real-time workflows such clip curation monitoring to evaluate content outcomes as they happen.</li><li><strong>Broader use cases:</strong> Embed the Judge into more content pipelines, supporting data-driven evaluation and decision-making across the product ecosystem.</li><li><strong>Business validation:</strong> Continue studying correlations between Judge scores and downstream metrics (e.g., clip export rate) to measure real-world impact.</li></ul><p><strong>Questions?</strong> Drop them in the comments. Our team loves talking about video quality evaluation optimizations.</p><h3>Join Our Team</h3><p>If these practical optimizations resonate with you and you’re passionate about solving complex technical challenges at scale, we’d love to hear from you.</p><p>Check out our open positions: <a href="https://www.opus.pro/careers">opus.pro/careers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74612034bd1e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opus-engineering/a-scalable-llm-as-a-judge-framework-for-video-quality-evaluation-74612034bd1e">A scalable LLM-as-a-Judge framework for video quality evaluation</a> was originally published in <a href="https://medium.com/opus-engineering">OpusClip AI Engineering &amp; Research</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Our Journey to Stop Kubernetes OOM Kills]]></title>
            <link>https://medium.com/opus-engineering/our-journey-to-stop-kubernetes-oom-kills-436e491e699c?source=rss----2fafb4e68ba5---4</link>
            <guid isPermaLink="false">https://medium.com/p/436e491e699c</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[jemalloc]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[monorepo]]></category>
            <category><![CDATA[memory-management]]></category>
            <dc:creator><![CDATA[OpusClip AI & Engineering Team]]></dc:creator>
            <pubDate>Thu, 13 Nov 2025 22:30:23 GMT</pubDate>
            <atom:updated>2025-11-13T22:30:22.263Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Written by Joe, Senior Software Engineer, Platform Team</em></p><p><strong>Picture this:</strong> You migrate your Node.js service to Kubernetes. At first, everything looks fine — until pods start consuming gigabytes of memory, hitting 5GB, then crashing with OOM kills… multiple times per day.</p><p>This was our reality. After weeks of chasing false leads, we discovered the culprits, applied fixes from runtime to infra to code, and finally cut pod memory usage from <strong>5GB → ~300MB</strong>.</p><p>Here’s the full journey:</p><h3>The Problem: Pods Dying of OOM</h3><p>After moving our service into Kubernetes, pod memory usage climbed continuously. Even after raising the memory limit to <strong>5GB</strong>, pods would still crash with Out-Of-Memory (OOM) kills.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*izMOp1f1-fjttc6g.png" /></figure><p>This wasn’t a once-in-a-while hiccup — it was happening multiple times per day.</p><h3>First Hypothesis: TypeScript Memory Leak</h3><p>Initial suspicion fell on a memory leak inside the TypeScript service. But monitoring told a different story:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ILHVha4QadzDPfsb.png" /></figure><ul><li>Memory spiked, then dropped back down via <strong>garbage collection</strong>.</li><li>No evidence of a persistent leak.</li></ul><p>The problem wasn’t the code itself — it was <strong>how the service was running</strong>.</p><h3>Root Cause #1: Nx Daemon in Production</h3><p>We noticed the service was launched with:</p><pre>NX_DAEMON=true</pre><p>This is Nx’s default behavior. The <strong>Nx Daemon</strong> is great for local development — it keeps a project graph in memory and watches for file changes — but in <strong>production</strong>, it’s a terrible idea.</p><p>Why? Because it spawns background processes that keep memory unnecessarily high.</p><p>👉 The fix: disable it either in nx.json:</p><pre>&quot;tasksRunnerOptions&quot;: {<br>  &quot;default&quot;: {<br>    &quot;options&quot;: {<br>      &quot;useDaemonProcess&quot;: false<br>    }<br>  }<br>}</pre><p>Or with an environment variable:</p><pre>export NX_DAEMON=false</pre><p>After disabling the daemon in our Docker image, memory dropped from <strong>~5GB to 1–2GB</strong>. Better, but not enough.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ju7WE6n0tSNSVKTg.png" /></figure><h3>Root Cause #2: Running nx serve in Production</h3><p>Next discovery: the service was being started like this:</p><pre>npm exec nx run service:serve</pre><p>Checking process logs showed <strong>multiple Nx plugin-worker processes</strong> still running inside the pod:</p><pre>/usr/bin/node /app/node_modules/nx/src/daemon/server/start.js<br>/usr/bin/node /app/node_modules/nx/src/project-graph/plugins/isolation/plugin-worker ...</pre><p>These workers were consuming huge amounts of memory.</p><p>👉 The fix: run Node directly, bypassing Nx:</p><pre>node dist/apps/service/src/main.js</pre><p>This change was a game-changer:</p><ul><li>Memory stabilized within <strong>~1GB</strong></li><li>No more runaway growth from Nx worker processes</li></ul><h3>Root Cause #3: Memory Allocator (Switching to jemalloc)</h3><p>Even with Nx gone, the service’s memory showed a slow upward trend.</p><p>The default allocator (V8’s malloc) wasn’t aggressive in releasing memory. The solution? <strong>jemalloc</strong> — a general-purpose allocator with better fragmentation handling.</p><p>Dockerfile snippet:</p><pre>FROM node:18<br>RUN apt-get update &amp;&amp; \<br>    apt-get install -y --no-install-recommends libjemalloc2 &amp;&amp; \<br>    rm -rf /var/lib/apt/lists/*<br>ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2<br>CMD [&quot;node&quot;, &quot;dist/apps/service/src/main.js&quot;]</pre><p>After switching, memory recycling improved significantly. The slow growth vanished.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*96I25WzWqQg7oZ5L.png" /></figure><h3>Code-Level Optimizations</h3><p>While infra-level fixes helped, we also tackled hotspots in the codebase:</p><ol><li><strong>De-duplicated concurrent GCS operations</strong> → stopped redundant downloads/uploads.</li><li><strong>Chunked file uploads/downloads</strong> → avoided giant memory spikes.</li><li><strong>Wrapped API clients</strong> → prevented massive log dumps from raw Axios errors.</li></ol><p>These optimizations cut unnecessary memory spikes and stabilized I/O patterns.</p><h3>🚀 Final Outcome</h3><p>After all fixes:</p><ul><li>Memory usage stabilized around <strong>300MB per pod</strong></li><li>No more OOM kills</li><li>No unnecessary restarts</li><li>Service is now stable and predictable in production</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Us8SBaGgBnfCJA6L.png" /></figure><h3>Key Takeaways</h3><ul><li><strong>Disable Nx Daemon</strong> in production — it’s for local dev only.</li><li><strong>Don’t use nx serve</strong> in production; start services directly with Node.</li><li><strong>Switch to jemalloc</strong> for better memory management.</li><li><strong>Optimize code I/O patterns</strong> to avoid unnecessary spikes.</li></ul><p>By combining infra fixes, runtime tweaks, and code optimizations, we cut pod memory usage by <strong>over 90%</strong> and eliminated OOM errors entirely.</p><p><strong>Questions?</strong> Drop them in the comments. Our team loves talking about memory optimizations.</p><h3>Join Our Team</h3><p>If these practical optimizations resonate with you and you’re passionate about solving complex technical challenges at scale, we’d love to hear from you.</p><p>Check out our open positions: <a href="https://www.opus.pro/careers">opus.pro/careers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=436e491e699c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opus-engineering/our-journey-to-stop-kubernetes-oom-kills-436e491e699c">Our Journey to Stop Kubernetes OOM Kills</a> was originally published in <a href="https://medium.com/opus-engineering">OpusClip AI Engineering &amp; Research</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bridging the Gap: How Engineers and PMs Ship Winning LLM Features Together]]></title>
            <link>https://medium.com/opus-engineering/bridging-the-gap-how-engineers-and-pms-ship-winning-llm-features-together-147a36ab4089?source=rss----2fafb4e68ba5---4</link>
            <guid isPermaLink="false">https://medium.com/p/147a36ab4089</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-engineering]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[product-management]]></category>
            <dc:creator><![CDATA[Jace Yu]]></dc:creator>
            <pubDate>Mon, 15 Sep 2025 10:58:08 GMT</pubDate>
            <atom:updated>2025-09-15T10:58:07.920Z</atom:updated>
            <content:encoded><![CDATA[<h3>How Engineers and PMs Ship Winning LLM Features Faster: 3 Technical Decisions</h3><p><strong>TL;DR:</strong></p><ul><li><strong>Prompts belong in configs, not code: </strong>Enable rapid iteration without deployments</li><li><strong>Variables go last: </strong>Save 90% on costs through KV-cache optimization</li><li><strong>Separate semantics from schema</strong>: PMs own meaning, engineers own structure</li></ul><p>The best LLM features aren’t built in silos. When engineers and PMs at <strong>OpusClip</strong> started collaborating on prompt architecture, <strong>iteration cycles dropped from days to minutes</strong>, <strong>API costs fell by 10x</strong>, and <strong>prompts in production are more reliable</strong>. Here are the three technical decisions that made the biggest difference.</p><h3>PM to Prompt Distance</h3><p><strong>What it is:</strong> The number of hops — and the amount of interpretation — between your product requirement and the exact text/settings the model actually receives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zLLFbHw29DqVCOuTB7jkcQ.png" /><figcaption><a href="https://www.linkedin.com/posts/manus-im_product-to-prompt-distance-is-fast-becoming-activity-7349444736048320512-zjjS?utm_source=share&amp;utm_medium=member_desktop&amp;rcm=ACoAACdAQCkBye_l2SHKxHq1FoCJdVQJdLz5Boc">Tao Zhang first defines this metric in Manus.</a></figcaption></figure><p>Here’s what typically happens:</p><ol><li><strong>PM writes</strong>: “The assistant should be professional but approachable”</li><li><strong>Spec translates</strong>: “Use formal language with occasional casual phrases”</li><li><strong>Engineer implements</strong>: “You are a professional assistant. Maintain formal tone while being friendly.”</li><li><strong>Runtime adds context</strong>: “You are a professional assistant. Maintain formal tone while being friendly. Current user: {user_name}. Previous context: {history}”</li></ol><p>Each step adds interpretation and delay.</p><p><strong>Why it matters:</strong></p><ul><li><strong>Speed of iteration.</strong> Fewer hops = faster experiments.</li><li><strong>Quality &amp; intent fidelity.</strong> Each handoff (PM → spec → UI copy → template → runtime prompt) adds interpretation risk.</li><li><strong>Observability.</strong> When prompts are hidden in code, it’s hard to debug.</li></ul><p><strong>How to reduce distance: </strong>Ask your engineer teammates to put prompts on dynamic configs, or a prompt management platform. Don’t put prompts on code.</p><h3>KV‑Cache</h3><p><strong>What it is:</strong> KV-Cache (Key-Value Cache) is like a smart notebook that lets LLMs remember their previous calculations. Without it, every time your chatbot generates a new word, it would need to re-read the entire conversation from scratch.</p><p>Imagine you’re having a conversation with a chatbot. Each time you send a new message, the chatbot needs to understand the entire conversation history to provide a relevant response. Without a KV-Cache, the model would have to re-read and re-process the whole conversation from the beginning every single time it generates a new word. This is incredibly inefficient and slow, leading to a frustratingly laggy user experience, especially with longer conversations or longer prompts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h8t0jEhBl2fpC89sKmjmxw.png" /></figure><p>KV-Cache has two major benefits:</p><ul><li><strong>Faster Response Times (Same response qualities but faster speeds):</strong> By avoiding redundant computations, the KV-Cache allows the LLM to generate responses much more quickly. For users, this means less waiting and a more fluid, natural interaction with your AI feature.</li><li><strong>Reduced Computational Costs (Same money but more users):</strong> Re-processing less data means using less computational power. This directly translates to lower operational costs for running your LLM, making your product more scalable.</li></ul><p><strong>Why PMs should care: </strong>modern LLM providers now charge 10x less for cached tokens than new tokens.</p><blockquote>For example, GPT-5 charges $1.25 for 1M input tokens, but it only charges $0.125 for 1M cached tokens.</blockquote><p><strong>How to leverage KV-cache: </strong>Always put variables at the end of your prompts.</p><p>❌ <strong>Bad prompt structure</strong> (minimal caching):</p><pre>User: {{user_name}}<br>Question: {{user_question}}<br>Conversation history: {{chat_history}}<br><br>You are a customer support agent for TechCorp.<br>Guidelines:<br>- Be empathetic and professional<br>- Check our knowledge base before answering<br>- Escalate billing issues to human agents<br>- Always verify account details first</pre><p>✅ <strong>Good prompt structure</strong> (maximum caching):</p><pre>You are a customer support agent for TechCorp.<br>Guidelines:<br>- Be empathetic and professional  <br>- Check our knowledge base before answering<br>- Escalate billing issues to human agents<br>- Always verify account details first<br><br>User: {{user_name}}<br>Question: {{user_question}}<br>Conversation history: {{chat_history}}Structured Output / Response Schema</pre><p>The static instructions get cached across all requests, while only the dynamic user content changes. For a support bot handling 10,000 daily conversations, this restructuring alone could save $200–300 or more per day.</p><h3>Structured Output / Response Schema</h3><p><strong>What it is:</strong> Instead of returning free‑form text, the model returns <strong>well‑formed JSON</strong>. You define a schema — fields, types, enums — and the model adheres to it.</p><p><strong>This is counterintuitive for many PMs: you don’t need to describe the format in your prompt at all.</strong></p><ul><li><strong>Structured output is an API-level feature</strong>, not a prompt trick. You turn it on <strong>in code</strong> by registering a schema/response format; then the runtime enforces it.</li><li><strong>Once it’s configured, don’t re-specify the format in the prompt.</strong> Tell the model <em>what</em> to fill, not <em>how to format</em> it.</li><li><strong>Consumer chatbot UIs (e.g., ChatGPT-style apps) generally don’t expose this.</strong> They’re optimized for human-readable text, not machine-parsable payloads.</li></ul><p><strong>We have to show some code here to explain it:</strong></p><pre>import OpenAI from &quot;openai&quot;<br>import { z } from &quot;zod&quot;<br>import { zodTextFormat } from &quot;openai/helpers/zod&quot;<br><br>// 1) Your schema stays in code (Zod)<br>const RelevancyItem = z.object({<br>  clipId: z.string(),<br>  relevant: z.boolean(),<br>  relevantReason: z.string(),<br>  advertisement: z.boolean(),<br>})<br>const RelevancyArray = z.array(RelevancyItem)<br>type Relevancy = z.infer&lt;typeof RelevancyArray&gt;<br><br>// 2) Build the semantics-only prompt (no format instructions)<br>const prompt = promptTemplate.join(&quot;\n&quot;).replace(INPUT_REPLACE, input)<br><br>const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY })<br><br>// 3) Call Responses API and let the helper parse &amp; validate for you<br>const response = await openai.responses.parse({<br>  model: &quot;gpt-4o-mini&quot;,<br>  input: [<br>    { role: &quot;system&quot;, content: &quot;Judge search-trend relevancy using the definitions provided.&quot; },<br>    { role: &quot;user&quot;, content: prompt },<br>  ],<br>  text: {<br>    // zodTextFormat drives structured output and runtime validation<br>    format: zodTextFormat(RelevancyArray, &quot;relevancy_results&quot;),<br>  },<br>})<br><br>// 4) Already parsed &amp; validated:<br>const results: Relevancy = response.output_parsed<br><br>// 5) Same post-filtering<br>const relatedResults = results.filter(<br>  (r) =&gt; r.relevant &amp;&amp; r.evergreen &amp;&amp; !r.advertisement<br>)</pre><p><strong>⚠️ Conflict Notice (VERY IMPORTANT)</strong></p><p>Once a <strong>schema/responseFormat</strong> is set in code, <strong>do not describe output formatting in the prompt</strong>. Mixing prompt-format rules with the engineer-defined schema creates two sources of truth and measurably hurts reliability:</p><ul><li><strong>Validation failures &amp; retries</strong> → higher latency/cost; occasional data loss if coerced.</li><li><strong>Instruction dilution</strong> → worse task quality (model juggles format vs. content).</li><li><strong>Downstream breakage</strong> → typed logic fails on “pretty” but invalid payloads.</li></ul><p><strong>Please remember:</strong> <em>Schema owns format; prompt owns semantics. </em>Keep prompts about what each field should contain (definitions, decision rules), <strong>not</strong> how to format.</p><p>❌ <strong>Your prompt should NOT say</strong>:</p><pre>Analyze these search results and return a JSON object with:<br>- videoId: the video identifier<br>- isRelevant: boolean indicating if it matches<br>- relevanceReason: explanation string<br>- isPaid: boolean for sponsored content<br>Format as valid JSON with these exact field names.</pre><p>✅ <strong>Your prompt SHOULD say</strong>:</p><pre>Analyze these search results for relevance to the user&#39;s query.<br><br>For relevance assessment:<br>- Consider semantic match, not just keyword overlap<br>- Educational content is preferred over entertainment<br>- Recent content (last 6 months) is more relevant<br><br>For paid content detection:<br>- Look for &quot;Sponsored&quot;, &quot;Ad&quot;, or &quot;#ad&quot; markers<br>- Check if the channel name includes &quot;Official&quot; or &quot;Brand&quot;<br><br>Provide clear reasoning for why content is or isn&#39;t relevant.</pre><p>Notice: all semantics, zero formatting. The schema handles structure; your prompt handles meaning.</p><p>One worth-to-mention common pitfall that PMs to avoid: changing field names in prompts without coordinating with engineering. If your engineer’s schema says videoId but your prompt mentions video_id or clip_id, you&#39;re creating confusion that degrades performance.</p><h3>Putting It All Together</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qCAC6ywG17E1WbUqvhuZRg.png" /></figure><ol><li><strong>Low pm to prompt distance</strong> lets you iterate quickly on prompt improvements</li><li><strong>Optimized KV-cache</strong> makes those iterations cheaper to test at scale</li><li><strong>Proper structured output</strong> ensures reliable, parseable responses regardless of prompt changes</li></ol><h3>Next Steps</h3><ol><li><strong>Audit your current setup</strong>: Where do your prompts live? Are variables at the end? Are you mixing format and content instructions?</li><li><strong>Start one conversation</strong>: Pick the highest-impact improvement and discuss with your engineering team. Most engineers appreciate PMs who understand these constraints.</li><li><strong>Measure the impact</strong>: Track iteration speed, cost per request, and error rates before and after changes.</li></ol><p><strong>Questions?</strong> Drop them in the comments. Our team loves talking about efficient engineering &amp; pm collaborations.</p><h3>Join Our Team</h3><p>If these practical takeaways resonate with you and you’re passionate about solving complex technical challenges at scale, we’d love to hear from you.</p><p>Check out our open positions: <a href="https://www.opus.pro/careers">opus.pro/careers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=147a36ab4089" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opus-engineering/bridging-the-gap-how-engineers-and-pms-ship-winning-llm-features-together-147a36ab4089">Bridging the Gap: How Engineers and PMs Ship Winning LLM Features Together</a> was originally published in <a href="https://medium.com/opus-engineering">OpusClip AI Engineering &amp; Research</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How OpusSearch Built Exact Matching for Enterprise RAG with Milvus BM25]]></title>
            <link>https://medium.com/opus-engineering/how-opussearch-built-exact-matching-for-enterprise-rag-with-milvus-bm25-aa1098a9888b?source=rss----2fafb4e68ba5---4</link>
            <guid isPermaLink="false">https://medium.com/p/aa1098a9888b</guid>
            <category><![CDATA[semantic-vs-exact-match]]></category>
            <category><![CDATA[opusclip-engineering]]></category>
            <category><![CDATA[ai-video-search]]></category>
            <category><![CDATA[milvus-vector-database]]></category>
            <category><![CDATA[rag-architecture]]></category>
            <dc:creator><![CDATA[OpusClip AI & Engineering Team]]></dc:creator>
            <pubDate>Mon, 11 Aug 2025 06:26:02 GMT</pubDate>
            <atom:updated>2025-08-11T06:26:02.709Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Written by Chronos Kou, Senior Software Engineer at OpusClip.</em></p><h3>The Semantic Search Blind Spot</h3><p>Picture this: You’re a video editor on deadline. You need clips from “episode 281” of your podcast. You type it into our search. Our AI-powered semantic search, proud of its intelligence, returns clips from 280, 282, and even suggests episode 218 because the numbers are similar, right?</p><p><strong>Wrong.</strong></p><p>When we launched <a href="https://www.opus.pro/opussearch">OpusSearch</a> for enterprises in January 2025, we thought semantic search would be enough. Natural language queries like “find funny moments about dating” worked beautifully. Our <a href="https://milvus.io/">Milvus</a>-powered RAG system was crushing it.</p><p><strong>But then reality hit us in the face with user feedback</strong>:</p><blockquote><em>“I just want clips from episode 281. Why is this so hard?”</em></blockquote><blockquote><em>“When I search ‘That’s what she said,’ I want EXACTLY that phrase, not ‘that’s what he meant.’”</em></blockquote><p>Turns out that video editors and clippers don’t always want AI to be clever. Sometimes they want software to be <strong>straightforward and correct</strong>.</p><h3>Why do we care about Search?</h3><p>We built an <a href="https://www.opus.pro/opussearch">enterprise search function</a> because we identified that <strong>monetizing</strong> large video catalogs is the key challenge organizations face. Our RAG-powered platform serves as a <strong>growth agent</strong> that enables enterprises to <strong>search, repurpose, and monetize their entire video libraries. </strong>Read about success case stories from <strong>All The Smoke</strong>, <strong>KFC Radio</strong> and <strong>TFTC</strong> <a href="https://www.opus.pro/blog/growing-a-new-youtube-channel-in-90-days-without-creating-new-videos">here</a>.</p><h3>Why We Doubled Down on Milvus (Instead of Adding Another Database)</h3><p>The obvious solution was to add Elasticsearch or MongoDB for exact matching. However, as a startup, maintaining multiple search systems introduces significant operational overhead and complexity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-MLAeoyuJ87BMfgRW_W51g.png" /><figcaption>Strong community adoption with <strong>35k+ GitHub stars</strong></figcaption></figure><p>Milvus had recently shipped their full-text search feature, and an evaluation with our own dataset <strong>without any tuning</strong> showed compelling advantages:</p><ul><li><strong>Superior partial matching accuracy. </strong>For example “drinking story” and “jumping high”, other vector DBs returns sometimes “dining story” and “getting high” which alters the meaning.</li><li>Milvus <strong>returns longer, more comprehensive results</strong> than other databases when queries are general, which is naturally more ideal for our use case.</li></ul><h3>Architecture from 5000 feet</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8wKOqmLe0k64O35FKnSqbg.png" /><figcaption>Milvus is the foundational vector database for our Enterprise RAG architecture</figcaption></figure><h3>BM25 + Filtering = Exact Match Magic</h3><p>Milvus’s <strong>full-text search</strong> isn’t really about exact matching, but it’s about relevance scoring using BM25 (<a href="https://en.wikipedia.org/wiki/Okapi_BM25">Best Matching 25</a>), which calculates how relevant a document is to your query. It’s great for “<strong>find me something close,</strong>” but terrible for “find me exactly this.”</p><p>We then <strong>combined BM25’s power with Milvus’s TEXT_MATCH filtering.</strong> Here’s how it works:</p><ol><li><strong>Filter first:</strong> TEXT_MATCH finds documents containing your exact keywords</li><li><strong>Rank second:</strong> BM25 sorts those exact matches by relevance</li><li><strong>Win:</strong> You get exact matches, ranked intelligently</li></ol><p>Think of it as “give me everything with ‘episode 281’, then show me the best ones first.”</p><h3>The Code That Made It Work</h3><h3>Schema Design</h3><blockquote><strong>Important:</strong> We disabled stop words entirely, as terms like “The Office” and “Office” represent distinct entities in our content domain.</blockquote><pre>export function getExactMatchFields(): FieldType[] {<br>  return [<br>    {<br>      name: &quot;id&quot;,<br>      data_type: DataType.VarChar,<br>      is_primary_key: true,<br>      max_length: 100,<br>    },<br>    {<br>      name: &quot;text&quot;,<br>      data_type: DataType.VarChar,<br>      max_length: 1000,<br>      enable_analyzer: true,<br>      enable_match: true,  // This is the magic flag<br>      analyzer_params: {<br>        tokenizer: &#39;standard&#39;,<br>        filter: [<br>          &#39;lowercase&#39;,<br>          {<br>            type: &#39;stemmer&#39;,<br>            language: &#39;english&#39;,  // &quot;running&quot; matches &quot;run&quot;<br>          },<br>          {<br>            type: &#39;stop&#39;,<br>            stop_words: [],  // Keep ALL words (even &quot;the&quot;, &quot;a&quot;)<br>          },<br>        ],<br>      },<br>    },<br>    {<br>      name: &quot;sparse_vector&quot;,<br>      data_type: DataType.SparseFloatVector,<br>    },<br>  ]<br>}</pre><h3>BM25 Function Setup</h3><pre>export const FUNCTIONS: FunctionObject[] = [<br>  {<br>    name: &#39;text_bm25_embedding&#39;,<br>    type: FunctionType.BM25,<br>    input_field_names: [&#39;text&#39;],<br>    output_field_names: [&#39;sparse_vector&#39;],<br>    params: {},<br>  },<br>]</pre><h3>Index Config</h3><blockquote>These bm25_k1 and bm25_b parameters were tuned against our production dataset for optimal performance.</blockquote><blockquote><strong>bm25_k1</strong>: Higher values (up to ~2.0) give more weight to repeated term occurrences, while lower values reduce the impact of term frequency after the first few occurrences.</blockquote><blockquote><strong>bm25_b</strong>: Values closer to 1.0 heavily penalize longer documents, while values closer to 0 ignore document length entirely.</blockquote><pre>index_params: [<br>  {<br>    field_name: &#39;sparse_vector&#39;,<br>    index_type: &#39;SPARSE_INVERTED_INDEX&#39;,<br>    metric_type: &#39;BM25&#39;,<br>    params: {<br>      inverted_index_algo: &#39;DAAT_MAXSCORE&#39;,<br>      bm25_k1: 1.2,  // How much does term frequency matter?<br>      bm25_b: 0.75,  // How much does document length matter?<br>    },<br>  },<br>],</pre><h3>The Search Query That Started Working</h3><pre>await this.milvusClient.search({<br>  collection_name: &#39;my_collection&#39;,<br>  limit: 30,<br>  output_fields: [&#39;id&#39;, &#39;text&#39;],<br>  filter: `TEXT_MATCH(text, &quot;episode 281&quot;)`,  // Exact match filter<br>  anns_field: &#39;sparse_vector&#39;,<br>  data: &#39;episode 281&#39;,  // BM25 ranking query<br>})</pre><p>For multi-term exact matches:</p><pre>filter: `TEXT_MATCH(text, &quot;foo&quot;) and TEXT_MATCH(text, &quot;bar&quot;)`</pre><h3>The Mistakes We Made (So You Don’t Have To)</h3><h3>Dynamic Fields: Critical for Production Flexibility</h3><p>Initially, we didn’t enable dynamic fields, which was problematic. Schema modifications required dropping and recreating collections in production environments.</p><pre>await this.milvusClient.createCollection({<br>  collection_name: collectionName,<br>  fields: fields,<br>  enable_dynamic_field: true,  // DO THIS<br>  // ... rest of config<br>})</pre><h3>Collection Design: Maintain Clear Separation of Concerns</h3><p>Our architecture uses dedicated collections per feature domain. This modular approach minimizes the impact of schema changes and improves maintainability.</p><h3>Memory Usage: Optimize with MMAP</h3><p>Sparse indexes require significant memory allocation. For large text datasets, we recommend configuring MMAP to utilize disk storage. This approach requires adequate I/O capacity to maintain performance characteristics.</p><pre>// In your Milvus configuration<br>use_mmap: true</pre><h3>Production Impact and Results</h3><p>Following the June 2025 deployment of exact match functionality, we observed measurable improvements in user satisfaction metrics and reduced support volume for search-related issues. Our dual-mode approach enables semantic search for exploratory queries while providing precise matching for specific content retrieval.</p><p>The key architectural benefit: maintaining a single database system that supports both search paradigms, reducing operational complexity while expanding functionality.</p><h3>What’s Next?</h3><p>We’re experimenting with <strong>hybrid queries combining semantic and exact match in a single search.</strong> Imagine: “Find funny clips from episode 281” where “funny” uses semantic search and “episode 281” uses exact match.</p><p>The future of search isn’t picking between semantic AI and exact matching. It’s using <strong>both</strong> intelligently in the same system.</p><p><strong>Questions?</strong> Drop them in the comments. Our team loves talking about search optimization.</p><h3>Join Our Team</h3><p>If this deep dive into performance engineering resonates with you and you’re passionate about solving complex technical challenges at scale, we’d love to hear from you.</p><p>Check out our open positions: <a href="https://www.opus.pro/careers">opus.pro/careers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa1098a9888b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opus-engineering/how-opussearch-built-exact-matching-for-enterprise-rag-with-milvus-bm25-aa1098a9888b">How OpusSearch Built Exact Matching for Enterprise RAG with Milvus BM25</a> was originally published in <a href="https://medium.com/opus-engineering">OpusClip AI Engineering &amp; Research</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Achieved 4x Faster Google Cloud Storage Transfers]]></title>
            <link>https://medium.com/opus-engineering/supercharge-your-google-cloud-storage-4x-faster-file-transfers-with-these-simple-optimizations-02cab52c0e40?source=rss----2fafb4e68ba5---4</link>
            <guid isPermaLink="false">https://medium.com/p/02cab52c0e40</guid>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[video-processing]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[cloud-storage]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[OpusClip AI & Engineering Team]]></dc:creator>
            <pubDate>Wed, 09 Jul 2025 22:08:51 GMT</pubDate>
            <atom:updated>2025-07-26T17:36:53.141Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Written by Mark Zhu, Engineering Lead at OpusClip.</em></p><p><em>Moving 2 GB videos in under 30 seconds is critical for OpusClip’s AI pipeline — but standard GCS transfers took 4 minutes. </em>At <a href="https://www.opus.pro//"><strong>Opus</strong></a>, we process <strong>tens of thousands of video projects daily</strong>, spanning from import to editing to export. These workflows heavily rely on fast and reliable file I/O with <strong>Google Cloud Storage (GCS)</strong>.</p><p>One critical bottleneck in our pipeline is <strong>video import</strong>, where large files are fetched from authenticated third-party platforms (like YouTube or Google Drive, or local uploaded videos) and temporarily stored on GCS. These files are then downloaded by our importer and passed through various stages like decoding, resizing, and transcription.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_wSOhUYiKcWJYJG6MszTkA.png" /><figcaption>GCS serves as the critical file storage backbone for Opus’s video processing pipeline</figcaption></figure><h3>Why Standard GCS Transfers Are Slow</h3><h4>Problem 1. Network Infrastructure Limitations</h4><p>The foundation of GCS <strong>performance</strong> lies in understanding Google Cloud Platform’s network architecture. VM instances operate within bandwidth constraints that vary dramatically based on machine type and configuration.</p><p>A e2-micro instance, while cost-effective, may only provide a few hundred Mbps of egress bandwidth—inadequate for transferring <strong>multi-gigabyte files</strong> efficiently. Meanwhile, higher-tier instances like n2-standard-16 unlock significantly more network throughput, but simply throwing <strong>more compute power</strong> at the problem isn&#39;t always the most elegant solution.</p><p>The network bottleneck becomes particularly pronounced when dealing with sustained data transfers. GCP’s shared network infrastructure means that your VM’s available bandwidth fluctuates based on overall network utilization, creating unpredictable performance characteristics that can frustrate developers and users alike.</p><h4>Problem 2. The Concurrency Trap</h4><p>One of the most overlooked performance killers in GCS operations is file contention. When multiple processes attempt to read from the same large file simultaneously — a common scenario when implementing <strong>parallel chunk uploads</strong> — the underlying disk I/O subsystem becomes the limiting factor. This creates a cascading effect where CPU cycles are wasted waiting for disk operations, network bandwidth remains underutilized, and overall system performance degrades significantly.</p><p>Traditional approaches to file handling often overlook this reality. Developers might implement seemingly sophisticated multi-threaded upload systems, only to discover that the bottleneck has simply moved from network to storage, with minimal performance gains to show for the added complexity.</p><h4>Problem 3. Single-Threaded Legacy Patterns</h4><p>The default behavior of many GCS tools and SDKs reflects older, simpler networking models. Standard gsutil cp operations and many SDK implementations (including Node.js&#39;s @google-cloud/storage) default to <strong>single-threaded</strong>, serialized operations. While this approach ensures reliability and simplicity, it fundamentally <strong>underutilizes</strong> modern network infrastructure.</p><p>This serialization becomes particularly problematic with large files. A 2GB file transfer that could theoretically complete in seconds instead takes minutes, not because of inherent limitations, but because the transfer mechanism isn’t designed to exploit available parallelism.</p><h3>Our Optimization Strategies</h3><h4>Strategy 1. Composite Upload Architecture</h4><p>The breakthrough in GCS upload performance comes from understanding Google’s composite upload mechanism. By configuring gsutil with parallel composite uploads, we can fundamentally change how large files are processed:</p><pre>gsutil -o &quot;GSUtil:parallel_composite_upload_threshold=150M&quot; -m cp file.tar gs://bucket/</pre><p>This seemingly simple command enables a sophisticated upload strategy. Files exceeding 150MB are automatically segmented into smaller chunks, each uploaded in parallel. Google’s infrastructure then reassembles these chunks server-side, eliminating the client-side bottleneck that typically limits upload performance.</p><p>The 150MB threshold isn’t arbitrary — it represents the sweet spot where the overhead of chunk management is offset by the parallelization benefits. Smaller thresholds create excessive overhead, while larger thresholds fail to maximize parallelization opportunities.</p><h4>Strategy 2. FUSE-Optimized Downloads</h4><p>Download optimization requires a different approach entirely. Rather than pulling data through traditional API calls, mounting GCS as a <a href="https://cloud.google.com/storage/docs/cloud-storage-fuse/overview">FUSE</a> filesystem and using rsync creates a more efficient data path:</p><pre>rsync -aH --progress /mnt/gcs/folder/file ./local_dir/</pre><p>This approach leverages rsync&#39;s sophisticated algorithms for data transfer, including delta compression, efficient streaming, and intelligent caching. The FUSE layer abstracts the remote storage complexity while rsync handles the optimization details, resulting in significantly improved download performance.</p><h4>Strategy 3. Infrastructure Right-Sizing</h4><p>Performance optimization isn’t just about algorithm improvements — it’s also about matching infrastructure to workload requirements. Upgrading from basic VM instances to n2-standard-8 or higher provides the network bandwidth headroom necessary for high-throughput operations. However, this must be balanced against cost considerations and actual utilization patterns.</p><p>The key insight is that network performance often scales non-linearly with instance size. A modest increase in compute resources can yield disproportionate improvements in transfer performance, making strategic upgrades highly cost-effective.</p><h3>Real-World Performance Analysis</h3><h4>Benchmark Methodology</h4><p>To quantify these optimizations, we conducted controlled testing using identical n2-standard-4 instances, transferring 1.5GB files under various configurations. This methodology isolates the impact of optimization techniques from infrastructure variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BkSwE23txwSO8-zF3nMq1A.png" /><figcaption>Benchmark Results: Standard vs. Optimized SDK. July 1st, 2025.</figcaption></figure><h4>Upload Performance Results</h4><p>The contrast between traditional and optimized upload methods is striking:</p><ul><li><strong>TypeScript SDK (baseline)</strong>: ~30 Mbps average throughput</li><li><strong>Optimized gsutil with composite uploads</strong>: ~280 Mbps average throughput</li></ul><p>This represents a 9x performance improvement through configuration changes alone. The optimized approach not only transfers data faster but also provides more consistent performance characteristics, reducing the variance that can impact user experience.</p><h4>Download Performance Comparison</h4><p>Download optimization showed similar dramatic improvements:</p><ul><li><strong>Standard API-based downloads</strong>: ~60 Mbps average throughput</li><li><strong>FUSE + rsync optimization</strong>: ~160 Mbps average throughput</li></ul><p>The 2.7x improvement in download performance demonstrates that optimization benefits extend beyond uploads. The FUSE approach also provides better error handling and resume capabilities, improving reliability alongside performance.</p><h3>Implementation Considerations and Trade-offs</h3><h4>Temporary Storage Overhead</h4><p>Composite uploads create temporary chunks in your GCS bucket during transfer operations. While these chunks are automatically cleaned up after successful uploads, they do represent a short-term increase in storage utilization. For most applications, this overhead is minimal and acceptable given the performance benefits.</p><h4>Code Integration Strategies</h4><p>Implementing these optimizations requires careful integration with existing codebases. The most effective approach involves creating abstraction layers that encapsulate the optimization logic while maintaining simple interfaces for application developers.</p><p>For example, utility functions like getFile/readGSFunc() for downloads and uploadImage/uploadUtil() for uploads can hide the complexity of FUSE mounting and composite upload configuration while providing optimized performance transparently.</p><h4>Monitoring and Observability</h4><p>Performance optimization is an ongoing process that requires continuous monitoring. Implementing metrics collection for transfer speeds, error rates, and resource utilization enables data-driven optimization decisions and helps identify performance regressions before they impact users.</p><h3>Conclusion: The Path Forward</h3><p>This round of GCS acceleration improvements delivered faster importer execution, more reliable uploads through exponential backoff and regional fallback, now fully deployed across core services (importer, process-media, refine-render) to ensure stability and scalability as Opus scales.</p><p>Optimizing GCS performance requires a holistic approach that considers network infrastructure, concurrency patterns, and modern cloud architectures. The techniques outlined here — composite uploads, FUSE-optimized downloads, and strategic infrastructure sizing — can provide 3–4x performance improvements with relatively minimal implementation complexity.</p><p>The key insight is that cloud storage performance optimization is not just about individual techniques but about understanding the entire data path and systematically addressing each bottleneck. As cloud infrastructure continues to evolve, these optimization strategies will remain relevant principles for building high-performance, scalable applications.</p><p>For teams dealing with large-scale data transfer requirements, investing in these optimization techniques is not just about improving performance — it’s about creating a foundation for scalable, efficient cloud-native applications that can grow with your business needs.</p><h3>Join Our Team</h3><p>If this deep dive into performance engineering resonates with you and you’re passionate about solving complex technical challenges at scale, we’d love to hear from you.</p><p>Check out our open positions: <a href="https://www.opus.pro/careers">opus.pro/careers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=02cab52c0e40" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opus-engineering/supercharge-your-google-cloud-storage-4x-faster-file-transfers-with-these-simple-optimizations-02cab52c0e40">How We Achieved 4x Faster Google Cloud Storage Transfers</a> was originally published in <a href="https://medium.com/opus-engineering">OpusClip AI Engineering &amp; Research</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>