<?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 Modita Behl on Medium]]></title>
        <description><![CDATA[Stories by Modita Behl on Medium]]></description>
        <link>https://medium.com/@b.modita?source=rss-eed82f08cfb5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jYA4r6q2VI3yMgHWENpXRg.png</url>
            <title>Stories by Modita Behl on Medium</title>
            <link>https://medium.com/@b.modita?source=rss-eed82f08cfb5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 14:11:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@b.modita/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[I Taught AI to Create Better YouTube Shorts Than I Can — Here’s What Happened]]></title>
            <link>https://medium.com/@b.modita/i-taught-ai-to-create-better-youtube-shorts-than-i-can-heres-what-happened-ba9484674b7e?source=rss-eed82f08cfb5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba9484674b7e</guid>
            <dc:creator><![CDATA[Modita Behl]]></dc:creator>
            <pubDate>Wed, 17 Sep 2025 05:02:34 GMT</pubDate>
            <atom:updated>2025-09-17T09:34:14.212Z</atom:updated>
            <content:encoded><![CDATA[<h3>I Taught AI to Create Better YouTube Shorts Than I Can — Here’s What Happened</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ScVds2K6DorjCGvuATWEtg.png" /></figure><p><em>Automating content creation with multiple strategies and smart quality evaluation</em></p><p>Creating engaging YouTube Shorts from longer content is one of the biggest challenges facing content creators today. You have a 2-hour podcast, a 45-minute lecture, or a 90-minute interview, and you need to extract the most compelling 45–60 second clip that will grab viewers’ attention and keep them engaged.</p><p>The traditional approach is painful: manually scrubbing through hours of content, making subjective decisions about what’s “good,” hoping you picked the right moment, and spending hours on content that might not perform well.</p><p>What if we could automate this process and generate multiple options, then let AI pick the best one?</p><h3>The Solution: Multi-Strategy Clip Generation</h3><p>I built a Python script that uses 5 different strategies to find the most engaging content and automatically selects the best clip based on objective quality metrics. Here’s how it works and what I learned building it.</p><h4>The 5 Strategies That Changed Everything</h4><p>🤖 AI Analysis — Uses Ollama (free local AI) to find the most impactful moment<br>🌅 Early Content — Extracts from the first 20% of your audio (hook content)<br>🎯 Middle Content — Takes content from 30–70% of your audio (meat of the content)<br>🌆 Later Content — Captures content from 60–90% of your audio (conclusions)<br>📊 High Density — Finds segments with the most words per second (information-rich)</p><p>Instead of putting all our eggs in one basket, we explore multiple approaches and let data decide which works best.</p><h3>The Technical Deep Dive</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XYdZGvlE5izbKRiIg1q0Ew.png" /></figure><h4>Step 1: Audio Processing &amp; Transcription</h4><pre>def transcribe(audio_path, model_size=&quot;base&quot;):<br>    &quot;&quot;&quot;Run Whisper and return its list of segments.&quot;&quot;&quot;<br>    model = whisper.load_model(model_size)<br>    result = model.transcribe(audio_path, verbose=False)<br>    return result[&quot;segments&quot;]</pre><p>The foundation starts with OpenAI’s Whisper, which gives us precise timestamps for each word and sentence. This granular timing data is crucial for creating clean cuts that don’t interrupt mid-sentence.</p><h4>Step 2: Multi-Strategy Clip Generation</h4><pre>def generate_multiple_clips(segments, num_clips=5, min_duration=45, max_duration=60):<br>    clips = []<br>    <br>    # Strategy 1: AI Analysis<br>    clip1 = select_impactful_clip_with_ollama(segments, min_duration, max_duration)<br>    clips.append(clip1)<br>    <br>    # Strategy 2-4: Region-based extraction<br>    early_clip = select_clip_from_region(segments, early_start, early_end)<br>    mid_clip = select_clip_from_region(segments, mid_start, mid_end)<br>    late_clip = select_clip_from_region(segments, late_start, late_end)<br>    <br>    # Strategy 5: Density-based selection<br>    dense_clip = select_dense_clip(segments, min_duration, max_duration)<br>    <br>    return clips</pre><p>Each strategy targets a different type of engaging content. Early content often contains hooks designed to capture attention. Middle content usually has the core insights. Later content provides conclusions and calls-to-action. Dense content maximizes information per second.</p><p>Step 3: Smart Quality Evaluation</p><p>This is where the magic happens. Each clip gets scored based on multiple factors:</p><pre>def evaluate_clip_quality(clip, segments):<br>    score = 0<br>    <br>    # Duration (closer to target 52.5s is better)<br>    duration_score = 1 - abs(duration - target_duration) / target_duration<br>    score += duration_score * 0.2<br>    <br>    # Word count (more content is better)<br>    word_score = min(word_count / 100, 1.0)<br>    score += word_score * 0.3<br>    <br>    # Sentence completeness<br>    if text.endswith((&#39;.&#39;, &#39;!&#39;, &#39;?&#39;)):<br>        score += 0.2<br>    <br>    # Content variety (different words)<br>    variety_score = min(unique_words / 50, 1.0)<br>    score += variety_score * 0.2<br>    <br>    # Position preference (slight preference for middle)<br>    position_score = 1 - abs(position - 0.5) * 2<br>    score += position_score * 0.1<br>    <br>    return score</pre><p>These weights came from analyzing hundreds of successful YouTube Shorts and identifying common patterns in high-performing content.</p><h4>The AI Integration: Using Ollama Instead of Expensive APIs</h4><p>Instead of relying on expensive cloud APIs, I integrated Ollama — a free, local AI that runs on your machine:</p><pre>def select_impactful_clip_with_ollama(segments, min_duration=45, max_duration=60):<br>    prompt = f&quot;&quot;&quot;You are an expert at finding the most engaging moments in audio content for social media.</pre><pre>Find the SINGLE most impactful clip from this transcript that is UP TO {max_duration} seconds long.</pre><pre>CRITICAL REQUIREMENTS:<br>- The clip MUST end at a complete sentence or natural pause<br>- NEVER cut in the middle of a sentence<br>- Look for content that is emotionally engaging or surprising<br>- Has clear value for viewers<br>- Would make people want to engage</pre><pre>Return ONLY a JSON object in this exact format:<br>{{&quot;start&quot;: 12.3, &quot;end&quot;: 57.8, &quot;text&quot;: &quot;the transcript text&quot;, &quot;reason&quot;: &quot;why this is impactful&quot;}}<br>&quot;&quot;&quot;<br>    <br>    response = requests.post(&quot;http://localhost:11434/api/generate&quot;, json={<br>        &quot;model&quot;: &quot;llama3.2:3b&quot;,<br>        &quot;prompt&quot;: prompt,<br>        &quot;stream&quot;: False,<br>        &quot;options&quot;: {&quot;temperature&quot;: 0.3, &quot;num_predict&quot;: 500}<br>    })</pre><p>Using Ollama means no API costs, no rate limits, and complete privacy — your content never leaves your machine.</p><h4>Seeing the Magic in Action</h4><p>Here’s what the script outputs during execution:</p><pre>🎬 Generating 5 different clips...<br>🎯 Generating clip 1/5 with AI analysis...<br>🎯 Generating clip 2/5 from beginning...<br>🎯 Generating clip 3/5 from middle...<br>🎯 Generating clip 4/5 from later section...<br>🎯 Generating clip 5/5 with high content density...</pre><pre>📊 Evaluating 5 clips to find the best one...<br>📊 Clip 1 score: 0.847 - The most important thing to remember is that...<br>📊 Clip 2 score: 0.723 - When we think about this problem...<br>📊 Clip 3 score: 0.891 - Here&#39;s what you need to know about...<br>📊 Clip 4 score: 0.654 - Finally, let&#39;s consider the implications...<br>📊 Clip 5 score: 0.789 - This approach has several key advantages...</pre><pre>🏆 Best clip selected: Clip 3 (score: 0.891)</pre><pre>🎬 Creating the best YouTube short...<br>✅ Best YouTube short created: youtube_short.mp4</pre><p>The transparency is crucial — you can see exactly why each clip was scored the way it was, making the process explainable and trustworthy.</p><h3>Technical Challenges</h3><h4>Challenge 1: Ensuring Complete Sentences</h4><p>Problem: AI might cut mid-sentence, creating awkward clips.</p><p>Solution: Implemented sentence validation that finds the last complete sentence within the desired timeframe and adjusts accordingly.</p><h4>Challenge 2: Avoiding Duplicate Clips</h4><p>Problem: Multiple strategies might select overlapping content.</p><p>Solution: Implemented overlap detection that identifies clips sharing more than 50% of their content and keeps only the highest-scoring version.</p><h4>Challenge 3: Handling AI Failures</h4><p>Problem: Ollama might fail or return invalid responses.</p><p>Solution: Robust fallback mechanisms that gracefully degrade to heuristic selection when AI fails.</p><h4>The Results: Why This Approach Actually Works</h4><h4>1. Better Quality Through Variety</h4><p>Instead of picking one moment and hoping it’s good, we explore multiple angles and let data decide what works best.</p><h4>2. Objective Quality Metrics</h4><p>The evaluation system removes subjectivity with weighted scoring:</p><ul><li>Duration Score (20%): Prefers clips closer to 52.5 seconds</li><li>Content Score (30%): Rewards more words and information</li><li>Completeness Score (20%): Rewards complete sentences</li><li>Variety Score (20%): Rewards diverse vocabulary</li><li>Position Score (10%): Slight preference for middle content</li></ul><h4>3. Automated Decision Making</h4><p>No more manual review needed — the AI picks the best clip based on proven metrics.</p><h4>4. Transparent Process</h4><p>You can see exactly why decisions were made, making the process explainable and improvable.</p><h4>Performance and Real-World Usage</h4><ul><li><strong>Transcription:</strong> ~30–60 seconds for a 30-minute audio</li><li><strong>Clip Generation:</strong> ~5–10 seconds for 5 clips</li><li><strong>Video Creation:</strong> ~30–45 seconds per short</li><li><strong>Total Time:</strong> ~2–3 minutes end-to-end for a 30-minute video</li></ul><p>Simple Command Line Usage:</p><pre># Generate 5 clips and pick the best one<br>python3 create_shorts_custom.py your_audio.mp3 your_image.png --use-ollama</pre><pre># Keep all generated clips for comparison<br>python3 create_shorts_custom.py your_audio.mp3 your_image.png --keep-all --use-ollama</pre><h4>The Impact on Content Creation</h4><p>This tool transforms how creators approach YouTube Shorts:</p><p>For Individual Creators:</p><ul><li>Save hours of manual work</li><li>Get better results through data-driven selection</li><li>Maintain consistent quality</li><li>Scale content production</li></ul><p>For Content Teams:</p><ul><li>Standardize the selection process</li><li>Speed up production workflows</li><li>Make decisions explainable and collaborative</li><li>Reduce the risk of missing great content</li></ul><h4>What’s Next: Future Enhancements</h4><p>The current version is just the beginning. Future improvements could include:</p><ul><li>Advanced AI Models: Integration with GPT-4 or custom fine-tuned models</li><li>Content-Specific Optimization: Different strategies for podcasts vs lectures vs interviews</li><li>Batch Processing: Handle multiple audio files simultaneously</li><li>Creating a scalable MCP server that does the job of generating shorts</li></ul><h4>Getting Started</h4><p>Prerequisites:</p><pre># Install Ollama<br>brew install ollama  # macOS<br>curl -fsSL https://ollama.ai/install.sh | sh  # Linux</pre><pre># Pull the required model<br>ollama pull llama3.2:3b</pre><pre># Install Python dependencies<br>pip install whisper requests srt</pre><p>Basic Usage:</p><pre>python3 create_shorts_custom.py your_audio.mp3 your_image.png --use-ollama</pre><h4>The Future of Automated Content Creation</h4><p>This project demonstrates the power of combining multiple AI strategies with objective quality metrics. Instead of relying on a single approach or subjective decisions, we’re using data-driven methods to consistently generate high-quality content.</p><p>As AI continues to evolve, tools like this will become increasingly sophisticated, helping creators focus on what they do best: creating great content, while AI handles the optimization and selection tasks.</p><p>The key insight? Don’t put all your eggs in one AI basket. Generate multiple options, evaluate them objectively, and let the data decide what works best.</p><h4>What’s Next</h4><p>This is just the beginning. I’ll be iteratively working on better evaluation strategies to improve the quality of generated shorts and will update this article with new findings and improvements as the system evolves.</p><p>The current 5-factor scoring system provides a solid foundation, but there’s always room for refinement based on real-world performance data and user feedback.</p><p>The ultimate aim is to build an MCP server that does this job — transforming this Python script into a scalable, API-driven microservice that can handle multiple requests, integrate with various AI assistants, and provide standardized access to YouTube Shorts generation capabilities through the Model Context Protocol.</p><p>Stay tuned for updates!</p><p><em>What do you think? Would you use a tool like this for your content creation? I’d love to hear your thoughts and experiences with automated content generation.</em></p><p>Resources:</p><ul><li><a href="https://github.com/ollama/ollama/tree/main/docs">Ollama Documentation</a></li><li><a href="https://github.com/openai/whisper">Whisper Documentation</a></li><li><a href="https://ffmpeg.org/documentation.html">FFmpeg Documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba9484674b7e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rethinking Observability in GenAI World]]></title>
            <link>https://medium.com/@b.modita/rethinking-observability-in-genai-world-7c62ec6d9609?source=rss-eed82f08cfb5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c62ec6d9609</guid>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[gen-ai-revolution]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-infrastructure]]></category>
            <dc:creator><![CDATA[Modita Behl]]></dc:creator>
            <pubDate>Tue, 24 Jun 2025 14:45:45 GMT</pubDate>
            <atom:updated>2025-06-24T14:45:45.092Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kA5J5mC58_qRQbFtLSPINg.png" /><figcaption>Image courtsey ChatGPT 4.0</figcaption></figure><p>Observability has always been a foundational pillar of modern software systems — be it a backend service, SaaS application, or large-scale platform. It acts as a “third eye” into what’s really happening inside a system: how well it’s performing, how scalable it is, and how it behaves under load. Observability helps us answer critical questions like: <em>How many requests are failing? What’s the latency? Where are the bottlenecks?</em></p><p>Software development is an iterative process, and observability is the compass that guides us through these iterations. While traditionally considered the domain of operations and engineering teams, good observability benefits customers too, often indirectly through reliability and performance, and in enterprise settings, even directly by enabling self-diagnosis and reducing time spent on support calls.</p><p>A<a href="https://www.splunk.com/en_us/newsroom/press-releases/2022/state-of-observability-2022-report-reveals-organizations-with-mature-observability-practices-significantly-reduce-costs-while-increasing-innovation.html"> Splunk report on observability</a> shows that mature observability practices significantly cut costs and increase innovation.</p><h3><strong>How GenAI Changes the Observability Landscape</strong></h3><p>With the rise of Generative AI, observability has entered a new paradigm. While many foundational observability principles still apply (e.g., latency, error rates, throughput), GenAI applications bring unique behaviors, new failure modes, and a rich stack of evolving components, from model orchestration to token usage tracking.</p><p>Let’s explore how observability needs to evolve in the world of GenAI and how we can bucket the relevant metrics.<br>In this blog I have a different take on how we can view GenAI stack as complex involving multiple layers. Each layer is relevant in its own way and concerns different stakeholders. It is also more intuitive and aligned with how these systems are built and debugged.</p><h4>Infrastructure Layer</h4><blockquote>Monitors the physical and cloud hardware resources used for model training and inference.</blockquote><p><strong>Traditional Examples:</strong> CPU, RAM, disk I/O, network throughput.</p><p>In GenAI systems, infrastructure observability takes on added complexity due to the heavy reliance on GPUs. GPU utilization, memory consumption especially for on-premise deployments.</p><p><strong>New Considerations:</strong></p><ul><li>GPU usage and saturation</li><li>Disk and network I/O during model load</li><li>Model size and version tracking</li></ul><h4>Model Serving Engine Metrics</h4><blockquote>Focuses on the serving engine (e.g., vLLM, Triton, HuggingFace Inference Server) that processes inference calls.</blockquote><p>This category includes detailed metrics about how the model itself is serving requests.</p><p><strong>Unique GenAI Metrics:</strong></p><ul><li><strong>TTFT (Time to First Token):</strong> Time taken to generate the first output token after receiving a prompt.</li><li><strong>TPOT (Time per Output Token):</strong> Speed of token generation.</li><li>Number of requests waiting and running</li><li>KV cache related metrics</li></ul><p>Here is a comprehensive list of metrics provided by <a href="https://docs.nvidia.com/nim/large-language-models/latest/observability.html">NVIDIA NIMs</a> and <a href="https://docs.vllm.ai/en/v0.8.5/design/v1/metrics.html">vLLM</a>. These metrics are critical for understanding not just performance but also user experience in interactive AI applications.</p><h4>Inference Endpoint Metrics</h4><blockquote>Observability for the API gateway/microservice that exposes models to clients.</blockquote><p>These metrics are associated with the HTTP endpoints through which inference requests are made, similar to any microservice.</p><p><strong>Key Metrics:</strong></p><ul><li>Latency (overall and per stage)</li><li>Throughput (requests per second)</li><li>Error rate (by type and status code)</li><li>Request queue depth</li><li>Timeout rates</li></ul><h4>Agent and Orchestration Layer Metrics</h4><blockquote>Applies to agentic frameworks (LangChain, LlamaIndex) or orchestrators chaining multiple steps/tools.</blockquote><p>Frameworks like <strong>LangChain</strong>, <strong>LlamaIndex</strong>, and <strong>Haystack</strong> introduce a new orchestration layer where an agent may:</p><ul><li>Break down a task into multiple sub-tasks</li><li>Call external tools (search, database, APIs)</li><li>Chain multiple LLM invocations</li></ul><p>Important Observability Needs:</p><ul><li><strong>Traceability of steps taken by the agent</strong></li><li><strong>Latency per chain/tool call</strong></li><li><strong>Cost breakdown per step or per tool</strong></li><li><strong>Failure rates in chain execution</strong></li><li><strong>Token usage per agent task</strong></li></ul><p>Agent observability is critical for debugging complex prompt flows and cost optimization.</p><h4>Application-Level Metrics</h4><blockquote>Captures metrics from the user-facing app built on top of the GenAI pipeline.</blockquote><p>This represents the topmost layer — your actual product or GenAI-powered application, such as a chatbot UI.</p><p><strong>What to track:</strong></p><ul><li>Frontend errors</li><li>API error propagation</li><li>Feature usage analytics</li><li>Session drop-offs and retries</li><li>Integration health (e.g., vector DB, embedding APIs)</li></ul><p>These metrics help ensure the application that wraps your AI stack is performing as expected.</p><h4>Usage and Cost Monitoring</h4><blockquote>Tracks consumption patterns and quotas for billing or internal cost optimization.</blockquote><p>Tokens are the new currency. Especially in SaaS GenAI platforms, usage observability is crucial for managing quotas and cost controls.</p><p>To enable effective tracking and governance, monitor usage at multiple levels:</p><ul><li>User/team/organization</li><li>Endpoint</li><li>Model version</li><li>Session or conversation</li></ul><p><strong>Few metrics that can be tracked:</strong></p><ul><li>Tokens input/output</li><li>Total cost per session</li><li>Tokens per user</li><li>Monthly usage trends</li><li>Quota limits and threshold alerts</li></ul><h4>Model Evaluation and Quality Metrics</h4><blockquote>Evaluates how well the model performs in terms of helpfulness, correctness, and alignment.</blockquote><p>Traditional systems often rely on pass/fail or error rates. In GenAI, correctness is fuzzy and contextual. Thus, qualitative evaluation becomes essential.</p><p><strong>Evaluation Techniques:</strong></p><p>A. Using a stronger LLM to evaluate responses for:</p><ol><li>Helpfulness</li><li>Harmfulness</li><li>Hallucination detection</li><li>Groundedness in facts</li></ol><p>B. Embedding-based similarity scores (semantic similarity)</p><p>C. Human feedback loops (RLHF-inspired feedback collection)</p><p>These metrics are critical to ensure GenAI systems generate not just output, but correct and safe output.</p><h3><strong>Why this layered take on the metrics make sense?</strong></h3><ol><li><strong>It reflects system architecture:</strong></li></ol><p>At the foundation lies the infrastructure (hardware) layer, followed by model loading and serving. Above that are the APIs, agents or chains, and evaluation components. At the very top sits the application layer — the interface the end user interacts with.</p><p>Structuring observability around these layers aligns with this mental model, making it easier for teams to pinpoint issues and correlate them with the appropriate system component.</p><p><strong>2. It helps pinpoint issues quickly</strong></p><p>Imagine you’re debugging latency in your chatbot, If the UI is fast, move down to the agent orchestration layer, if that’s fine, check the inference endpoint, if that’s okay too, look at model serving metrics (maybe high TTFT), maybe the real culprit is GPU saturation at the infra layer.</p><p>This top-down drill-down is only possible when metrics are structured by layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*meTZikqySjM5mXeKKvj4PQ.png" /></figure><p><strong>3. It separates concerns by team</strong></p><p>Different layers often belong to different owners:</p><ol><li>Infra team cares about GPU, CPU, storage.</li><li>AI/ML Platform team owns model servers and endpoints.</li><li>App/UX teams own the frontend.</li><li>AI/LLM evaluation team may own hallucination &amp; quality metrics.</li></ol><p>A layered model helps each team focus on their scope, while still contributing to end-to-end observability.</p><h3><strong>Conclusion</strong></h3><p>Observability in GenAI goes beyond traditional logs and metrics, it’s a layered system covering everything from hardware to hallucinations. Layering metrics from hardware to application provides a clear, navigable map of the GenAI stack, making monitoring, debugging, cost control, and reliability easier, faster, and more systematic.</p><p>In future posts, we’ll dive deeper into each category, exploring sample dashboards, alerting best practices, tracing and open-source tools to instrument GenAI observability effectively.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c62ec6d9609" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>