<?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 Emeric Trossat on Medium]]></title>
        <description><![CDATA[Stories by Emeric Trossat on Medium]]></description>
        <link>https://medium.com/@etrossat?source=rss-77c6706599fd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3aKcTgXZgNOgx9v7F8F5ZA.png</url>
            <title>Stories by Emeric Trossat on Medium</title>
            <link>https://medium.com/@etrossat?source=rss-77c6706599fd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 07:07:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@etrossat/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[How to get Reliable JSON from LLMs?]]></title>
            <link>https://medium.com/@etrossat/how-to-get-reliable-json-from-llms-71083cf7de1c?source=rss-77c6706599fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/71083cf7de1c</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Emeric Trossat]]></dc:creator>
            <pubDate>Mon, 10 Aug 2026 21:14:47 GMT</pubDate>
            <atom:updated>2026-08-10T21:14:47.983Z</atom:updated>
            <content:encoded><![CDATA[<h4>Data Contracts and Pydantic to leverage the latest Structured Output capabilities.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8XNB1ttbg3DVwWAoFPf6Lg.png" /></figure><p>This was me in 2024 trying to build a sentiment classifier using the ChatGPT API.</p><p>I was discovering the power of LLMs for classification tasks. But not so long ago, it was really painful to get a consistent, structured output from ChatGPT.</p><p>Fortunately, thanks to the industry-wide push for <strong>grounded</strong> AI, this process is now much easier.</p><p>In this article, I will first cover how the frontier lab models evolved to tackle that issue, especially with the new <strong>Structured Outputs</strong> feature.</p><p>Then we will focus on <strong>Pydantic</strong>, the go-to Python library for data validation. This component is more essential than ever in agentic software.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FbaY3SaIhfl0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DbaY3SaIhfl0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FbaY3SaIhfl0%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/62869866838c6b46310ac28a4608fdfc/href">https://medium.com/media/62869866838c6b46310ac28a4608fdfc/href</a></iframe><p><em>This video went viral in the tech community in 2021, playfully teasing the love-hate relationship between devs and QA testers.</em></p><p><em>Credit goes to the talented actor: Alison Burke; </em><a href="https://www.tiktok.com/@tired_actor/video/6912855387788102918"><em>see her TikTok</em></a></p><h3>I.From AI chatbot to Reasoning model</h3><p>The initial OpenAI models were optimized for fast, fluid, and creative conversational text. OpenAI blew up through the ChatGPT experience.</p><p>Since then, AI labs started addressing the need for models that can reliably drive operational workflows. They are now releasing two kinds of models.</p><p><em>All of the following applies to OpenAI, Gemini, and Anthropic models. And likely to other vendors. I have only fact-checked these three providers.</em></p><h4><strong>1. The initial classic generation models</strong></h4><p>Here are the model parameters for initial GPT models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*YLwoCJS4N9gg9TQJX0hR3Q.png" /><figcaption>Model output you can tune in the <a href="https://platform.openai.com/chat/edit?models=gpt-4.1">openAI API sandbox</a> for GPT-4.1 (released in april 2025)</figcaption></figure><p>Initially, OpenAI gave you control only over the <strong>prose </strong>of ChatGPT output.</p><p>The promise was to let you control the tradeoff between predictability and creativity.</p><p>Through top-p and temperature tuning, you can gain some control over how the next token (word/sub-word) is generated.</p><h4><strong>2. People hacked it into a deterministic data science pipeline</strong></h4><p>Let’s take a sentiment analysis task as an example.</p><p>What was at that time a difficult task reserved for NLP practitioners became accessible to many people.</p><p>You just had to connect your data with the OpenAI API and use that kind of prompt.</p><blockquote>“Classify this tweet into one of [POSITIVE, NEGATIVE, NEUTRAL]. Output JSON only.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I4kZpMKCWfSnxi2YUfoyeA.png" /><figcaption>JSON output example</figcaption></figure><p>But initial OpenAI models struggled to respect this output. They could :</p><ul><li>Add “here is your answer” in front of the JSON</li><li>Modify your variable name: turning “tweet” into “Tweet”</li><li>Add a fourth label: “polemic”</li></ul><p>However, after the initial breakthrough of ChatGPT, Frontier Labs are releasing another kind of model.</p><h4><strong>3. Frontier Labs gave us Reasoning Models</strong></h4><p>Frontier Labs have been working on reasoning models optimized to follow instructions and apply multi-step reasoning.</p><p>Here are the model parameters for GPT-5.4</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*84121VkFi-loASTzT2cL3w.png" /></figure><p>You have more control over the reasoning effort.</p><ul><li>You can tune the <strong>reasoning effort </strong>and get billed for <strong>thinking tokens. </strong>The main billing parameters remain the size of your input and output (aka number of tokens in and out of the model)</li><li>Ask for details of the reasoning in the api</li></ul><p>You want to know more? Check <a href="https://ai.google.dev/gemini-api/docs/thinking">Gemini docs</a>, <a href="https://developers.openai.com/api/docs/guides/reasoning">OpenAI docs</a>, <a href="https://platform.claude.com/docs/en/build-with-claude/effort">Anthropic docs</a>.</p><h4>4. A promise of consistent JSON output?</h4><p>From now on, they support this output parameter in the API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*S7ELGTp-xQdO7QobA80obQ.png" /><figcaption>Screenshot from <a href="https://platform.openai.com/chat/edit?models=gpt-4.1">openAI API sandbox</a></figcaption></figure><p>What is the difference between <strong>json_object</strong> and <strong>json_schema</strong>?</p><h3>II. JSON output: from best effort obligation to strict liability?</h3><h4>1. “Best effort “, JSON Object</h4><p>You will get a JSON output. This ensures that you can use the answer with code that parses the JSON without failure.</p><p>But it does not guarantee that 100% of the time the schema you want will be respected.</p><p>However, if you can accept a non-deterministic environment, it remains reliable enough for many internal production use cases.</p><p>Indeed, the key challenge remains testing and monitoring the quality of the answer. Schema errors can be monitored, and you can set up fallbacks.</p><h4>2. “Strict liability “, guaranteed consistency, Structured Outputs</h4><p>Frontier Labs recently introduced <strong>structured output.</strong></p><p>The promise is consistent JSON output that respects your specification.</p><p>It can come with tradeoffs depending on your use case: cost, reasoning quality drop.</p><p>Indeed, it is implemented at the inference layer. It is more than a correction wrapper on top of their model. The structural rules are baked right into the model’s decision-making process while it is thinking :</p><ul><li>The model calculates probabilities for possible next tokens</li><li>Before a token is chosen, the inference engine looks at your JSON schema</li><li>The model is forced to choose only valid options.</li></ul><p>Concretely :</p><ul><li>If you want to analyze one tweet, it is likely going to be more expensive and slower.</li><li>If you are processing 1000 tweets, the incremental cost is going to be minimal, linear, and forecastable.</li></ul><p>You want to know more about structured output? Check <a href="https://ai.google.dev/gemini-api/docs/structured-output">Gemini docs</a>, <a href="https://developers.openai.com/api/docs/guides/structured-outputs#supported-schemas">OpenAI docs</a>, <a href="https://platform.claude.com/docs/en/build-with-claude/structured-outputs">Anthropic doc.s</a></p><p>Before closing the Frontier Lab chapter and jumping to Pydantic, let me briefly highlight the tools available to optimize your agentic pipeline at scale.</p><h3><strong>III. Pro-tips: Scaling Structured Outputs with Caching and Batching</strong></h3><p>Let’s illustrate that with the OpenAI rate card. (Pricing structure is similar for Gemini and Anthropic)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z06XUxGuq7-7C91GPQqq_Q.png" /><figcaption><a href="https://developers.openai.com/api/docs/pricing?latest-pricing=standard#text-tokens">gpt-5.6-sol pricing (short context &amp; standard)</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B6tPKdO275pDM36ORpZk8g.png" /><figcaption><a href="https://developers.openai.com/api/docs/pricing?latest-pricing=batch#text-tokens">gpt-5.6-sol pricing (short context &amp; batching)</a></figcaption></figure><ul><li>Batching is half the price</li><li>Cached input is 10 times cheaper (once you paid the “cache writes price)</li></ul><p>There is a lot of space for latency and query optimization!</p><h3>IV. Declare your data schema in Pydantic</h3><p>While model-level constraints are powerful, enforcing these structures at the code level requires robust frameworks. This is where Pydantic shines.</p><p>Pydantic is a popular Python library for data validation and parsing. As we will see, it is supported by OpenAI, Gemini, and Anthropic.</p><p>It became such a key library in agentic frameworks that Pydantic is providing its own GenAI Agent Framework: <a href="https://pydantic.dev/docs/ai/overview/">Pydantic AI</a>!</p><p>For those writing applications in TypeScript/Node.js, <a href="https://zod.dev/">Zod</a> serves the same purpose. (Beware, I haven’t fact-checked anything about Zod !)</p><h4>1. Illustration — Pydantic class for our Sentiment Tweet analysis</h4><p>Here is an example of Pydantic classes we could create for our tweet classifier</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YrDs-vfIuKXHeKyvFVhhEQ.png" /></figure><p>Pydantic provides syntax that lets you enforce data types:</p><ul><li>tweet and explanation are going to be <em>strings, </em>i.e., <strong>str</strong></li><li>confidence score<strong> </strong>is a <em>decimal, i.e., </em><strong>float</strong></li></ul><p>With Pydantic, you can also apply value control here :</p><ul><li><strong>sentiment </strong>is expected to be POSITIVE/NEGATIVE/NEUTRAL (ie a Nominal Variable)</li><li><strong>confidence </strong>is going to be between 0 and 1, inclusive</li></ul><p>Once you define your Pydantic classes, local data validation becomes a breeze. But it gets even better:</p><h4>2. OpenAI, Gemini, Anthropic models support Pydantic</h4><p>You can provide a <strong>Pydantic</strong> class to the <strong>structured output protocol</strong>.</p><p>Remember the i<strong>nference engine </strong>we discussed in Section II? You can pass some Pydantic data structure and validation rules to your model.</p><p>Be aware of what is <strong>enforced</strong> vs <strong>non-blocking :</strong></p><ul><li><strong>JSON structure</strong> is 100%<strong> enforced</strong> at the inference layer</li><li><strong>Pydantic constraints </strong>are treated as <strong>non-blocking </strong>prompts at the<strong> </strong>inference layer. They are, however, <strong>validated locally </strong>by the SDK.</li></ul><p>Despite this limitation, Pydantic constraints remained powerful! You centralize in one single place the rules that are :</p><ul><li>1. Passed to the LLMs (after SDK parsing)</li><li>2. On which you can run data validation tests</li></ul><p>As usual, check AI labs documentation to get into the details! <a href="https://ai.google.dev/gemini-api/docs/structured-output#json-schema-support">Gemini</a>, <a href="https://developers.openai.com/api/docs/guides/structured-outputs#supported-schemas">OpenAI</a>, <a href="https://platform.claude.com/docs/en/build-with-claude/structured-outputs#important-considerations">Anthropic</a></p><h4>4. The Python ecosystem is built around Pydantic</h4><p>Most popular Python libraries needed to build a web service and agentic workflow are built or support Pydantic.</p><p><strong>Your Pydantic class can define :</strong></p><ul><li>Your database model</li><li>Your REST API endpoints</li><li>Structured output from LLMs</li><li>Inputs for tool calling (if your agent is allowed to use some tools)</li><li>Memory / Agent State (if you have several agents working and communicating)</li></ul><h3>Conclusion — It’s all about data contract</h3><p>I am concluding this article by dropping a niche buzzword that has been around since 2000 :</p><blockquote>A <strong>data contract</strong> is a design pattern and formal agreement between data producers and downstream consumers.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/0*AgISAey-YyzS8DLI.jpg" /></figure><p>Integrating LLMs into your applications is about going back to engineering basics.</p><p>GenAI scales up fundamental quality practises. In the past, we were often too busy writing boilerplate code to fully commit to strict data contracts.</p><p>Today, however, there is a direct ROI on that tedious task: building reliable AI systems at scale.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71083cf7de1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Software documentation in the Age of Agentic Coding]]></title>
            <link>https://medium.com/@etrossat/software-documentation-in-the-age-of-agentic-coding-bda75319e06a?source=rss-77c6706599fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/bda75319e06a</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[documentation]]></category>
            <dc:creator><![CDATA[Emeric Trossat]]></dc:creator>
            <pubDate>Tue, 04 Aug 2026 23:15:10 GMT</pubDate>
            <atom:updated>2026-08-04T23:28:37.259Z</atom:updated>
            <content:encoded><![CDATA[<p>What vibe coding taught me: my documentation playbook</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JV57DHymtx5wgVNOIT51aw.jpeg" /><figcaption>Leonardo da Vinci Vitruvian Man collage</figcaption></figure><h3>I. The code is the documentation</h3><p>Documenting code has always been a tedious and difficult task to define.</p><p>GenAI has completely transformed the perspective on the famous joke:</p><blockquote><em>The code is the documentation</em></blockquote><figure><img alt="“Documentation is the code” 2023 vs 2026" src="https://cdn-images-1.medium.com/max/687/1*L1vktDCrSN5Nbuwjeu2ErA.jpeg" /></figure><p>Given that :</p><ul><li>Your favorite AI-coding tool can now generate documentation for you.</li><li>Any <strong>Power User </strong>can now understand a code base far more easily thanks to agentic coding tools.</li></ul><p>We should focus on what the doc is not saying.</p><p>Code tells you HOW something works, but it does not explain WHY it was built that way.</p><p>This is where the need for documentation resides.</p><h3>II. Document “Product Intent” and “Design Decisions”</h3><p>The code is a description of what the system is eventually doing at the end of the development process.</p><p>But it does not describe how we got here.</p><p>I am sharing how <a href="https://openspec.dev/">openspec </a>framework is approaching that :</p><p>Openspec is</p><blockquote>A lightweight spec-driven framework</blockquote><p>their motto</p><blockquote>Review intent, not just code</blockquote><h4>1. Document <strong>intents </strong>at the project level</h4><p>Let’s have a look at their example</p><p><em>I shortened the example with &lt;…&gt;, on on this page from their </em><a href="https://github.com/Fission-AI/OpenSpec/blob/main/docs/concepts.md"><em>github</em></a><em> to review the full example</em></p><pre># Auth Specification<br><br>## Purpose<br>Authentication and session management for the application.<br><br>## Requirements<br><br>### Requirement: User Authentication<br>The system SHALL issue a JWT token upon successful login.<br><br>#### Scenario: Valid credentials<br>- GIVEN a user with valid credentials<br>- WHEN the user submits login form<br>- THEN a JWT token is returned<br>- AND the user is redirected to dashboard<br><br>#### Scenario: Invalid credentials<br><br>&lt;...&gt;<br><br>### Requirement: Session Expiration<br><br>&lt;...&gt;<br><br>#### Scenario: Idle timeout<br><br>&lt;...&gt;</pre><p>Storing that in your git enables you to use that during the different steps or your developement workflows :</p><ol><li>Conception</li><li>Testing</li></ol><p>Generating accurate scenarios enables you to :</p><ul><li>Provide one approach to AI to check its work</li><li>Provide a base to generate automated / generated testing</li></ul><h4>2. Document decisions through dedicated “proposal files” at the “change” level</h4><p>A change equals for example an iteration</p><p><em>Source : openspec documentation</em></p><pre># Proposal: Add Dark Mode<br><br>## Intent<br>Users have requested a dark mode option to reduce eye strain<br>during nighttime usage.<br><br>## Scope<br><br>&lt;...&gt;<br><br>## Approach<br>Use CSS custom properties for theming with a React context<br>for state management.<br><br># Design: Add Dark Mode<br><br>## Technical Approach<br>Theme state managed via React Context to avoid prop drilling.<br>CSS custom properties enable runtime switching without class toggling.<br><br>## Architecture Decisions<br><br>### Decision: Context over Redux<br>Using React Context for theme state because:<br>- Simple binary state (light/dark)<br>- No complex state transitions<br>- Avoids adding Redux dependency<br><br>### Decision: CSS Custom Properties<br>Using CSS variables instead of CSS-in-JS because:<br>- Works with existing stylesheet<br>- No runtime overhead<br>- Browser-native solution<br><br>## Data Flow<br><br>&lt;...&gt;<br><br>## File Changes<br><br>&lt;...&gt;</pre><p>On top of providing context to a human, your AI coding tool will be able to reuse this context in its future architecture choice or suggestion.</p><p>Let’s have a look at my favourite ways of creating documentation.</p><h3>III. Use Visuals and Diagrams !</h3><p>Infographies are a powerful way to transmit complex ideas :</p><ul><li>To your AI agentic tool</li><li>The humans you want to keep in the loop</li></ul><p>I find very efficient to document :</p><ul><li>Existing system vs goals</li><li>Business / user scenarios</li><li>Architecture</li></ul><p>I either use a white board or <a href="https://app.excalidraw.com/">https://app.excalidraw.com/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*rSRdi0WGDGss-YOs9t8YAQ.png" /><figcaption>Source : excalidraw website</figcaption></figure><p>Then I turn them into “code” by using the <a href="https://mermaid.js.org/">mermaid format</a></p><p>Mermaid provides a <strong>text-based syntax</strong> (DSL) and a <strong>rendering engine</strong> (parser) to generate and display diagrams from code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*QmeSCHLeCSBRo_O3xfjmGQ.png" /><figcaption>Source : mermaid website</figcaption></figure><p>Mermaid’s advantage is to be both <em>Human &amp; AI readable </em>in a deterministic way.</p><p>It is 100% <strong>WYSIWYG </strong><em>“What You See Is What You Get.” </em>unlike</p><p>I cross-check them manually. The leverage of having high quality specification in the development process makes it worth it.</p><h3>IV. Create tailored documents if you need someone to act</h3><p>Very often you will need inputs from key people to remove blockers during a project.</p><p>Executive, operator, expert,… what these people have in common is that your project represents only a small part of their mental bandwidth.</p><p>So what you can do is providing actionable documentation that will connect with their mental model and enable them to take their decision quicker.</p><p>Structure, filter, add storytelling tailored for your audience and the action they need to take.</p><h3>V. A static website created from markdown files</h3><h4>1. Creating my documentation using <a href="https://www.markdownguide.org/">Markdown</a> format</h4><p>Markdown is a plain-text markup language with features similar to Notion, Google Docs, Confluence,…</p><p>You can easily manage titles, subtitles, basic tables, quotation, codes. And it fits nicely in your git repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cUuQeeCtBdHlgp4d6Mf9-A.png" /><figcaption>Source : Markdown official website</figcaption></figure><p>To ensure a seamless experience for non-technical readers I apply a coat of paint by generating a clean html webpage with a consistent design system.</p><h4>2. I create a webpage to enhance it</h4><p>Let’s take some example from <a href="https://emerictrossat.com/">my personal website</a> :</p><p><strong>Example 1 : markdown file to html</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FgsOim97jR-uUdehhlxkBA.png" /><figcaption>Excerpt from a mardown file in my code base</figcaption></figure><p>becomes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*FwzbBMvR0GcIwc7jPr9g6g.png" /></figure><p><strong>Example 2 : json to html</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_MzghjJfKizzoh1L6po6GA.png" /><figcaption>Excerpt from a json in my code base</figcaption></figure><p>becomes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dDP02QNGaef7BuUK1XYWFA.png" /></figure><p>In these two examples :</p><ul><li>Content is stored in markdown and json files</li><li>Html webpages are generated using <em>next.js</em> combined with UI components (<em>shadcn/ui &amp; Tailwind CSS</em>)</li><li>The technical configuration files (css and typescript) are AI generated based on my requirement.</li></ul><p>A good approach is to maintain a <strong>design system file </strong>in your code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0t7VVXWGQyXAxR5HoEdOVQ.png" /><figcaption>Excerpt 1 from the design.md of my website</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HDiUBzWkAm9P0L5w5f4-9A.png" /><figcaption>Excerpt 2 from the design.md of my website</figcaption></figure><h3>Conclusion: Documentation is the new leverage</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VbtwppKmxuPZTfoLjoKJag.png" /></figure><p>The rise of <strong>agentic coding</strong> is finally “dusting off” documentation. Far from making it obsolete, this new era rewards clarity.</p><p>The more we involve stakeholders and document their intents and decisions, the more autonomous and efficient our AI agents become.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bda75319e06a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prototyping an AI Assistant for Jill the Plumber: Notes from a Fast-Paced Hackathon]]></title>
            <link>https://medium.com/@etrossat/the-power-of-a-hackathon-to-prototype-a-frictionless-ai-assistant-for-a-plumber-f3803a642486?source=rss-77c6706599fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3803a642486</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[chatbots]]></category>
            <dc:creator><![CDATA[Emeric Trossat]]></dc:creator>
            <pubDate>Tue, 02 Jun 2026 03:51:07 GMT</pubDate>
            <atom:updated>2026-06-04T02:31:05.924Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A4gpil6uQCdLChum6O8mbg.png" /></figure><p>Last week, I participated in the <a href="https://www.linkedin.com/company/toronto-machine-learning-summit/"><strong>TMLS (Toronto Machine Learning Summit) Hackathon</strong></a>, and it completely changed my perspective on how fast a remote, cross-functional team can ship an AI product.</p><ul><li>How does agentic coding enable collaborative prototyping ?</li><li>What are the challenges behind building a “customer service” type assistant ?</li></ul><p>Here is what I learned from building a vocal assistant under pressure, and why agentic workflows are a game-changer for collaborative prototyping.</p><h3>0. Introduction -What did we build ?</h3><p>We designed a personal AI assistant for “Jill the plumber”.</p><p>You want to contact Jill, a trusted plumber, but she is not answering his phone ! Can Jill let you connect with his AI assistant without creating any frustration ?</p><p>Here is our amazing video demo :</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F0nmJgc7JCvU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0nmJgc7JCvU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F0nmJgc7JCvU%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e814cc3e596ef44a1473664b21c2298/href">https://medium.com/media/9e814cc3e596ef44a1473664b21c2298/href</a></iframe><p>The demo is still running <a href="https://frontend-689084127939.northamerica-northeast2.run.app/">here</a></p><h3>1. The backstory</h3><p>Our team consisted of 5 strangers. Our common ground : a taste for working on a concrete business workflow.</p><p>Here is how we went from zero to live in a few days — all while balancing our busy day-to-day lives.</p><p><strong>Monday — the full onsite day</strong></p><p><strong>10:00 AM:</strong> Team was set. We started brainstorming.</p><p><strong>11:00 AM:</strong> We aligned on an idea, the vision and split the specification works based on our strengths:</p><ul><li><strong>Functional Design:</strong> Mapping out visual workflows and user scenarios.</li><li><strong>UI/UX:</strong> Designing the wireframes.</li><li><strong>Technical Architecture:</strong> Choosing the frameworks, tech stack, and LLM models.</li></ul><p><strong>Tuesday — First iteration went live</strong></p><p><strong>10:00 AM : </strong>Alignment during a one-hour video call</p><p><strong>11:00 AM :</strong> I started the code production phase using <strong>Claude Code</strong>.</p><p>My challenge was :</p><ul><li>Shipping an actionable prototype</li><li>Taking decisions in case of conflicts or gaps in the initial specifications, while preserving the unique, personal substance of everyone’s contribution.</li></ul><p>By <strong>2:30 PM</strong>, the first version was live.</p><p>Over the next two days, we tested, iterated, and refined the product completely remotely.</p><h3>2. 💡 The Key Success Factor: Nitty-Gritty Workflows</h3><p>I share here one example of specification that was key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ExZlVl4c45RRA_mu4QFCDQ.png" /><figcaption>Extract from our visual workflow</figcaption></figure><ul><li>It was originally drawn on a White Board</li><li>Then turned into a <a href="https://mermaid.js.org/">mermaid diagram</a></li></ul><blockquote>Mermaid diagrams are code-based diagrams that represent structures and processes, generated using Markdown-inspired text definitions that are easy to write and modify</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*atZuSd64hN-FD1nyD8N25g.png" /></figure><p>By pasting this Mermaid code directly into Claude Code, the agent instantly understood the logical flows and edge cases, writing the core logic in minutes instead of hours</p><p>Having a code representation of a workflow is the perfect way to feed complex product requirements to an Agentic Tool.</p><p>We combined it with tests detailed test scenarios in text files.</p><h3>3. To gather user feedback — ditching the Traditional Pitch for a “Science Fair” demo style</h3><p>One of the best ideas from the TMLS organizers was the judging format.</p><p>Instead of a one-off presentation and short Q&amp;A in front of a silent jury and/or public, they organized a <strong>Science Fair-style demo session</strong>.</p><p>This was a goldmine for <strong>implicit feedback</strong>.</p><blockquote>Implicit feedback is inferred indirectly by observing user actions and interactions, without the user explicitly stating their preferences.<br> It captures true usage patterns rather than just opinions.</blockquote><p>I was able to watch dozens of live users interact with our vocal assistant in real-time. Seeing where they stumbled, where they hesitated, and what they expected gave us insights that no theoretical framework could ever provide.</p><p>See in the next paragraph what I learnt.</p><h3>4. Designing a “Frictionless” Vocal Experience: The Real Challenges</h3><p>Here is the pattern we used :</p><ol><li><strong>A Triage Agent:</strong> To quickly assess the urgency of the call (e.g., a flooded kitchen vs. a leaky faucet).</li><li><strong>A Specialist Sub-Agent:</strong> In non-urgent cases, this agent took over to qualify the need and generate an initial quote.</li></ol><p>However, the reality of live testing revealed two major friction points:</p><h3>Lesson 1: Avoid the “Interrogation Room” Trap</h3><p>I realized during the “Science fair” that a purely unsupervised, open-ended conversational interview leads to a long, inefficient, and frustrating back-and-forth.</p><p>he fix? We should have combined the open-ended chatbot experience with classical, efficient UI components — like generating dynamic checkbox questions on the fly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SRfhIIB4sMubB6kw1LWbsg.png" /><figcaption>Checkbox questions</figcaption></figure><p>With modern AI, it is incredibly easy to generate <em>dynamic, on-the-fly custom forms</em> based :</p><ul><li>Specific Plumbing procedures and knowledge in prompts</li><li>On the conversation</li></ul><h3>Lesson 2: Breaking the vocal “Ping-Pong” Conversation Barrier</h3><p>To build a truly natural vocal assistant, we must break away from the rigid, step-by-step loop:</p><ol><li>User talk</li><li>Agent think (10 seconds)</li><li>Agent answers (10 seconds)</li></ol><p>=&gt; User is frustrated 🤬</p><p>This lag destroys the illusion of human interaction. This is exactly what the <a href="https://developers.openai.com/api/docs/guides/realtime"><strong>OpenAI Realtime API</strong></a> is designed to solve.</p><p>The agent can listen, process context in the background, and instantly stop speaking the moment the user cuts in — creating a fluid, human-like cadence.</p><p>Does it work? I can’t tell yet, as we weren’t able to fully implement and test the Realtime API during the short window of the hackathon.</p><h3>Conclusion</h3><p>This was a very productive Hackathon. I have a better understanding of:</p><ul><li>What UX / technical challenges lie behind an AI chatbot ?</li><li>How to improve rapid prototyping by combining human collaboration and AI tools ?</li></ul><p>I will definitely try to team up more in the future either for side projects or for enterprise work.</p><p>Thanks to my teammates : Calen Lau, <a href="https://www.linkedin.com/in/joe-kagumba/">Joe Kagumba</a>, <a href="https://www.linkedin.com/in/mateen-ismail-a8ba29205/">Mateen Ismail</a>, <a href="https://www.linkedin.com/in/jen-barnes-nolan/">Jen Barnes-Nolan</a></p><h3>Few words about Toronto Machine Learning Summit</h3><blockquote>This hackathon was organized by the Toronto Machine Learning Society (TMLS), one of North America’s largest ML communities. TMLS hosts the annual Toronto Machine Learning Summit (June 16–19, 2026), bringing together practitioners, researchers, and industry leaders. Learn more at <a href="https://torontomachinelearning.com/">torontomachinelearning.com</a></blockquote><p>This is not an affiliation link, nor a sponsored article ;-)</p><p>Follow them, as they plan to organize more hackathons. For this first one, they managed to gather about 20 teams.</p><p>Also, check out the agenda of the summit: this is serious business!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3803a642486" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Social Prose in the Age of genAI]]></title>
            <link>https://medium.com/@etrossat/social-prose-in-the-age-of-genai-cf0efcafa163?source=rss-77c6706599fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf0efcafa163</guid>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[content-writing]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Emeric Trossat]]></dc:creator>
            <pubDate>Mon, 18 May 2026 22:45:30 GMT</pubDate>
            <atom:updated>2026-05-19T12:42:06.777Z</atom:updated>
            <content:encoded><![CDATA[<p>2026… 3 years after the ChatGPT boom. Debates are raging on Twitter on the negative and positive impacts of genAI on content generation on social networks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FwRLdYvu-5Qi83cf_RREKg.png" /><figcaption>AI generated (banana 2)</figcaption></figure><p>As a seasoned Twitter and LinkedIn reader, I will share some of my opinions on that hot topic.</p><p><em>I joined Twitter 16 years ago, at a time where tweets character count were limited to 140. It doubled in 2017. Today, the limit has expanded to 25,000 characters for premium subscribers.</em></p><h3>I. I miss Brevity</h3><p>Nowadays on LinkedIn most posts are <strong>too long </strong>compared to their real <strong>substance</strong>.</p><p>And sadly it started to be the same on Twitter.</p><p>As Blaise Pascal wrote in a letter in 1657 :</p><blockquote>I have made this longer than usual because I have not had time to make it shorter</blockquote><p><em>(</em><a href="https://quoteinvestigator.com/2012/04/28/shorter-letter/"><em>source</em></a><em>)</em></p><p><strong>Respecting the audience</strong>’s time when we produce a text should be a social norm.</p><p>Just like in efficient corporate environments. We train ourselves to communicate effectively to facilitate quick decision making or actions by stakeholders. Especially if they are far from the project.</p><p>Although genAI enable more people to format and share their thoughts, sadly they don’t use it enough to <strong>condense</strong> it.</p><h3>II. Aim for b<strong><em>revity </em></strong>to stress test your reasoning</h3><p>Some of the brightest physicists were also excellent popularizers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/0*MeL9OrYNGp-xvbkz.jpg" /><figcaption><a href="https://www.biography.com/scientists/albert-einstein">Albert Einstein</a></figcaption></figure><p><strong>Albert Einstein on clarity</strong></p><blockquote>If you can’t explain it to a six-year-old, you don’t understand it yourself</blockquote><p><strong>Ernest Rutherford on simplification</strong></p><blockquote>A physical theory is not over-satisfactory unless it is so simple that even a barmaid can understand it</blockquote><p>A lot of people should post less and use AI to optimize for <strong>quality</strong> and not for productivity when it comes to writing an article.</p><p>In addition to respecting their audience, they will sharpen their understanding of the topic they want to write about</p><h3><strong>III. Using AI to aim for sharp Brevity</strong></h3><p>As a concrete example, being a non-native speaker, I used AI while writing this article to get inspirations for expressions and titles, subtitles with one goal in mind :</p><p><strong>Shortening my sentences. Keep it simple.</strong></p><p>What I did was:</p><ul><li>Fed to gemini my goal, draft of sentences which are a mixt of english and french (which is my mother tongue)</li><li>And then picked an expression among many suggestions</li></ul><p>I pick an expression only if :</p><ul><li>It feels right to me</li><li>I am able to defend every subtle choice of word</li></ul><h3>IV. Me too I have an LLM…, bring me something it can’t replicate</h3><p>If I want to go deep on generic concepts, I will just consult my Gemini subscription.</p><p>I keep watching my Twitter / LinkedIn feeds to :</p><ul><li>Get a <strong>personal</strong> perspective on a topic which was shaped by the writer’s <strong>unique background</strong> and <strong>lived experience</strong>.</li><li>Read an opinion that <strong>sparks my curiosity </strong>about a hot topic.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tT06hA8fILyxjoLQjCGUzA.png" /><figcaption>AI generated (banana 2)</figcaption></figure><p>Besides, tweet and linkedin posts lack features that would facilitate communication of complex topics :</p><ul><li>Lack of rich <strong>formatting</strong> (headers, subheaders)</li><li><strong>Images</strong> : it is not possible to use one on Twitter while on LinkedIn, you can only use one as some kind of cover.</li></ul><h3><strong>V. AI is the endgame of platform-driven content</strong></h3><p>We already started writing for algorithms. AI is just automating the echo.</p><p>Right now genAI tools are imitating writing styles developed to game engagement metrics on LinkedIn.</p><p>What we see on our social feeds is indeed the result of human engagement choices, but it is nudge by Social media pattern. That’s why i am blaming LinkedIn.</p><p>LinkedIn promoted :</p><ul><li>“Dwell Time” over concision</li><li>“See more” clicks and thus clickbait titles</li></ul><p>LinkedIn hasn’t given us :</p><ul><li>Easy way to “vote down” publications</li><li>Ways to filter what we want to see in your Linkedin feed</li></ul><h3>An optimistic conclusion</h3><p>We are all learning, thanks to AI, people are <strong>trying new roles, </strong>and we are making mistakes :</p><ul><li>Take me sharing these opinions in english</li><li>People trying growth hacking on social networks</li><li>Non tech people discovering by trial and mistake the harsh reality behind vibecoding a tech product</li></ul><p>Based on what I see on LinkedIn and Twitter people keep appreciating human authenticity and will enjoy even more asperities and authenticity than before.</p><p>Thank you to <a href="https://x.com/raphaeldoan"><strong>Raphaël Doan</strong></a>, whose <a href="https://raphaeldoan.substack.com/p/du-savoir-vivre-dans-lusage-de-lintelligence">article</a> inspired me to write this prose</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf0efcafa163" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Webedia identifies socio-demographic audiences on its media websites]]></title>
            <link>https://webedia.io/how-webedia-identifies-socio-demographic-audiences-on-its-media-websites-19d60ee0594?source=rss-77c6706599fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/19d60ee0594</guid>
            <category><![CDATA[medium]]></category>
            <category><![CDATA[advertising]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[web-analytics]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Emeric Trossat]]></dc:creator>
            <pubDate>Thu, 04 Nov 2021 09:38:24 GMT</pubDate>
            <atom:updated>2021-11-05T10:18:41.694Z</atom:updated>
            <content:encoded><![CDATA[<p>2018 was a key year for data privacy on the internet. The Cambridge Analytica scandal brought this issue to the attention of the public worldwide. In Europe the GDPR started to be implemented.</p><p>Since then, driven by both the evolution of the regulation and the technical ecosystem, publishers have had to adapt their media targeting offer. I will share with you through a concrete use case how the market practices are evolving.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wdLBfoiPIUqvJz6G-yibyg.jpeg" /><figcaption>A digital marketer looking for a marmot in a post cookie world</figcaption></figure><h3>Advertisers challenge us on socio-demographic data</h3><p>Webedia has websites specializing in movie, series, gaming, food, tech and celebrities. For advertisers with brands in these sectors, we can easily create relevant targetings. Indeed our editorial teams apply granular tagging to all the contents they generate, whether it’s a movie page, a recipe or a news article.</p><p>We have an offer well suited to these advertisers, but addressing non-endemic customer’s needs is more challenging. Sometimes we have to demonstrate the link between our audiences and their marketing needs. But most of the time the process is more straightforward : they ask for socio-demographic targeting.</p><p>Let’s see first how advertisers usually assess the quality of socio-demographic targeting.</p><h3>In France, Mediametrie and Nielsen are associated to assess the quality of socio-demographic targeting of digital campaigns</h3><p>The two reference research institutes offer in France an independent measurement called ”Digital Ad Ratings”, based on panels, whose objective is to verify if a campaign has reached the desired target.</p><p>Thanks to the implementation of a tracking in the advertising formats, when an advertiser runs a campaign on a given website it gets the coverage figure for the target of its campaign (for instance “women 25–49 y.o.”).</p><p>The advertiser can then compare this figure to the “Digital Ad Ratings” standards made public each year by Médiamétrie (an aggregate of all the tests they run on digital campaigns for each target) and form its opinion about its media choices.</p><p>Publishers can also use “Digital Ad Ratings” to validate their methodological approach to targeting.</p><h3>Webedia switches back to a content-based approach</h3><p>The main methodology used in 2019 was to try to reconcile declarative age/gender data and navigation data at a user level. A machine learning model would then try to identify navigation patterns across the web.</p><p>A media company could take this approach either with its first-party data or by buying qualified cookies to “data brokers”. But the “third-party cookies” approach was becoming less and less effective due to the application of GDPR principles and the features web browsers developed to protect privacy.</p><p>At Webedia, when we first looked at our users’ navigation patterns, we realized that by applying too sophisticated approaches, a broad part of our inventory would remain unqualified. However we noticed that our content was highly segmented in terms of socio-demographic data. We got this insight from our panel data sources, including declarative socio-demographic data from our sign-in users.</p><p>As a consequence, we worked on better qualifying our context at a very granular level thanks to our panel data sources. The goal was to then create audiences based on simple contextual rules, thus allowing us to get greater reach.</p><p>We validated this approach by analyzing our “Digital Ad Ratings” results versus the Médiamétrie standards. We found that while our content-based approach would certainly be less accurate than audience-based methods, it could beat Mediametrie’s standards for some targets while offering greater reach in terms of audience activation.</p><h3>Some rules were “cliché” and others derived from more subtle methods</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h0xxjvWsCdVxDFG-jWGjrA.jpeg" /><figcaption>reference to a famous french TV show in which Jean Dujardin played before becoming a hollywood star</figcaption></figure><p>We will give you two concrete examples of how we identify socio-demographic groups through content consumption.</p><p>On a celebrity news website we own, <a href="https://www.purepeople.com/">purepeople.com</a>, we used “personality” tags. They describe the key personality mentioned in a news article.</p><p>We used this type of tags for three reasons :</p><ul><li>It works well ! The examples are caricatural : we do not have the same socio-demographic audience on topics such as the English royal family, the French president’s wife or a former reality TV star;</li><li>It was easy to implement (we do not like over-engineering at Webedia);</li><li>Most importantly : audiences are concentrated on hot topics. We don’t have time to qualify a given article for a future audience. “Personality” tags enable us to target these audiences on articles that are suddenly trending.</li></ul><p>On <a href="https://www.allocine.fr/">AlloCiné</a>, the French n°1 website for movie and series, we had to opt for something more subtle : behaviors by movie / series genre or tags are less stereotyped.</p><p>For this website, the peak audience of a content occurs around its release date, but the pages related to movie and series are available several months in advance. We therefore have more time to qualify the content than on celebrity news websites, which allows us to work on this level.</p><h3>A change in the data activation tools made this project possible</h3><p>In 2019 when we decided to revamp our targeting methods, we identified a major bottleneck. Our media segmentation tools had two main limitations :</p><ul><li>Segmentations were slow to compute (it could take up to 24 hours);</li><li>It was based on third-party cookies (i.e. cookies that track users across the web) which are blocked by some web browsers.</li></ul><p>Therefore, in 2020, we deployed Mediarithmics, a DMP that would give us better reach :</p><ul><li>First, user tracking was based on first-party cookies (they are less blocked by browsers — but tracking is limited to the hostname level) and supplemented by third-party cookies for cross domain tracking.</li><li>Second, Mediarithmics had just implemented “edge targeting”, which stores user navigation logs in the browser (in local storage — user consent is still required for data collection). This feature is essential to activate our audience segments.</li></ul><p>This paradigm shift enables us to segment people in real time when they first interact with our websites. We can target the large audience that comes to our websites without any interaction history. This kind of technology is not specific to Webedia, publishers are adopting it all over the world.</p><h3>Our key take away on this project</h3><p>At Webedia, we believe that this kind of approach will keep prevailing in the future.</p><p>Even if the design of the Google Chrome Privacy Sandbox is still in progress, we are confident that we will be able to :</p><ol><li>Accurately qualify a small number of users : socio-demographic profile, purchasing behavior…;</li><li>Use them as a panel to generate rules that we will apply at a content level;</li><li>Follow the market standards for activation by collaborating with tech providers : Mediarithmics brought us the “edge” technology and they are now working on how to interact effectively with Chrome Privacy Sandbox.</li></ol><p>Some take away on the data side : this project illustrates well what you need to do to deliver projects that have impact :</p><ul><li>Define a goal and start with a simple approach : beat the DAR standards;</li><li>Develop domain knowledge : on the data team we had to become Ad tech specialists in order to be relevant;</li><li>Think industrialization : the data team took in charge the revamp of our DMP (from provider selection to deployment), so throughout the algorithm design phase, we had the industrialization constraint in mind</li></ul><p>To conclude, many thanks to all the contributors of this project at Webedia :</p><ul><li>Antoine Meunier and Marion Bories from Marketing &amp; Insights team for initiating the market needs, introducing us to Mediamétrie/Nielsen methodology;</li><li>Alban Clochet and his Ads Operation team for conducting the Digital Ad Ratings tests and running the delivery on a daily basis;</li><li>My colleagues from Webedia data team who implemented the mechanisms : Valentin Strach and our interns : Patrice Chanol, Augustin Yaich, Li-Fan Zhao</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19d60ee0594" width="1" height="1" alt=""><hr><p><a href="https://webedia.io/how-webedia-identifies-socio-demographic-audiences-on-its-media-websites-19d60ee0594">How Webedia identifies socio-demographic audiences on its media websites</a> was originally published in <a href="https://webedia.io/">Webedia I/O</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 SQL things I wish I knew as a data beginner]]></title>
            <link>https://medium.com/@etrossat/3-sql-things-i-wish-i-knew-as-a-data-beginner-78efe6ab775c?source=rss-77c6706599fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/78efe6ab775c</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[analytics]]></category>
            <dc:creator><![CDATA[Emeric Trossat]]></dc:creator>
            <pubDate>Wed, 29 Sep 2021 20:34:00 GMT</pubDate>
            <atom:updated>2022-09-14T13:16:58.049Z</atom:updated>
            <content:encoded><![CDATA[<p>At University, SQL is considered as a language very easy to learn. “You just need to know SELECT,FROM,GROUP BY,WHERE”. SQL has indeed a quick learning curve, it was design has a high-level programming language to query any relational database. Nowadays any Bigdata datawarehouse or framework include has a SQL connector.</p><p>However SQL can be tricky especially when you jump from theory to application on the field. Moreover some not well-known but powerfull operators extend what you can do with it.</p><p>Let me share you three things i learnt on the fields during my first years as a data engineer.</p><ol><li><strong>Use Common table expression (WITH)</strong></li></ol><p>Let’s say i have a table of ratings associated with a movie and i want to compute the average number of ratings by movie.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*Y1SlQ1eNs4zj3uNWAA4JZg.png" /></figure><p>To answer this questions, you compute in a first query the number of ratings by movie_id (like below) and take the Average.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/221/1*IaqQ6U3B4IjbqGEYJXn4Aw.png" /></figure><p>In term of syntax you have two approaches :</p><p><strong>Using a subquery</strong></p><pre>SELECT <br>   AVG(nb_ratings)<br>FROM (<br>SELECT<br>    movieId<br>    ,count(*) as nb_ratings<br>FROM `allocine-bq.movielens.ratings`<br>GROUP BY 1)</pre><p><strong>Using a CTE (common table expression)</strong></p><pre>WITH ratings_by_movie AS (<br>SELECT<br>     movieId<br>    ,count(*) as nb_ratings<br>FROM `allocine-bq.movielens.ratings`<br>GROUP BY 1)<br>SELECT <br>   AVG(nb_ratings)<br>FROM ratings_by_movie</pre><p><strong>Why use CTE instead of subquery ?</strong></p><p>It makes your code clearer : indeed the processing steps are exposed linearly and in order, instead of being encapsulated. The example above is simple, but it is particularly useful when you have query with long series of steps and much more fields in the SELECT.</p><p>Note that when you are working with RDMS like postgesql or mysql this command can come with some side effects on the performance side. This operator was originally implemented with an optimization purpose. It shoud not be the case on modern databases.</p><p><strong>2-a) Be aware of the effect of NULL value on arithmetic operations</strong></p><p>Here is the classic example that make loose time to a lot of SQL beginner the first time it occured : the below operation return a NULL value.</p><pre>DECLARE a INT64 DEFAULT 10;<br>DECLARE b INT64 DEFAULT NULL;</pre><pre>SELECT a + b</pre><p>Believe me when you are not aware of it, you can spend a lot of time debugging queries that compute complexe KPI.</p><p>You can use the IFNULL operator as a workaround :</p><p><em>IFNULL(expr, null_result) : if expr is NULL then return null_result else return expr</em></p><pre>SELECT a + IFNULL(b,0)</pre><p>Note that this property is very useful when doing divisions. The below operation return a NULL value and not a “division by zero”.</p><pre>DECLARE a INT64 DEFAULT 10;<br>DECLARE b INT64 DEFAULT NULL;</pre><pre>SELECT a / b</pre><p>So in some case you could want on purpose replace 0 value by NULL.</p><p><strong>2-b) Be aware of the effect of NULL value in aggregation functions</strong></p><p>In the same spirit NULL values are ignored by the AVG() functions, you need to replace it by a 0 if you want to take it into account.</p><p>As well COUNT(field_a) will count all the non NULL value for field_a.</p><p><strong>3) Have a look at analytical functions</strong></p><p>This pattern is a bit more complicated and enables you to compute advanced KPI like running_sum, moving average. I will introduce it below with a simpler example.</p><p>Let’s say you have a table of order by customer with revenue and you want to numerate by customer his orders based on the date. In ecommerce, it is the first step required to conduct acquisitions or retention analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*4eYw-IAT_IGCZB5RiEA6hw.png" /></figure><p>You can use this query</p><pre>SELECT<br>      *<br>     ,RANK() OVER (PARTITION BY customer_id ORDER BY date ASC) as order_number<br>FROM orders</pre><p>You said : for each customer, create a order rank iterating based on the date of the order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*F12SmlVBm3fdRXyULF3rVA.png" /></figure><p>This pattern is similar to an aggregation function :</p><ul><li>You replace GROUP BY with PARTITION BY</li><li>ORDER BY is necessary for using a ranking functions</li><li>OVER() declare the use of an analytics function</li></ul><p>An analytics function is the only way to use functions that require an ORDER BY operator</p><p>To finish with this example be aware of the difference between RANK() and ROW_NUMBER() :</p><ul><li>RANK() if 2 orders have been placed at the same date, they will have the same rank</li><li>ROW_NUMBER() they will have a different row_number (arbitrary one)</li></ul><p>I sometimes use Analytics functions to compute aggregation functions I could compute with a GROUP BY. If i want to use SUM() or AVG() operators but with different partitions, analytics functions will simplify my query by saving additional sub queries and join</p><p><strong>Many thanks to my collegues from Webedia data team </strong>that took part to a brainstorm on this article on a lunch break.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78efe6ab775c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Personalised recommendations for films and TV series: Webedia’s Data Science team explains how they…]]></title>
            <link>https://webedia.io/personalised-recommendations-for-films-and-tv-series-webedias-data-science-team-explains-how-they-62392537fb59?source=rss-77c6706599fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/62392537fb59</guid>
            <category><![CDATA[recommendation-system]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[movies]]></category>
            <dc:creator><![CDATA[Emeric Trossat]]></dc:creator>
            <pubDate>Fri, 10 Sep 2021 14:09:48 GMT</pubDate>
            <atom:updated>2021-09-10T14:18:13.491Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Personalised recommendations for films and TV series: Webedia’s Data Science team explains how they calculate the new affinity scores for AlloCiné</strong></h3><h3>Through its organisation “The Boxoffice Company”, which specialises in media, technology and data for the movie industry, the Webedia group has become one of the first digital media companies dedicated to the movie industry, with more than 74 million unique visitors in the world to its sites (allocine.fr in France, filmstarts.de and moviepilot.de in Germany, sensacine.com in Spain, sensacine.mx in Mexico, adorocinema in Brazil, beyazperde.com in Turkey) and YouTube channels.</h3><h3>Since March 2020, AlloCiné (leader in France with more than 14 million unique visitors per month / source: Médiamétrie/NetRatings, January 2020) has been using a unique recommendation algorithm to offer users affinity scores for movies and series.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*NJ4wcAeomABqO-LfNCjteQ.jpeg" /></figure><h3>What are the issues involved in recommending movies or series?</h3><p>The first step was to define what qualifies as a “good recommendation” and how to measure its accuracy. For an image recognition algorithm, no matter how complex the deep learning algorithm may be, the aim and its control variable are easy to define: can my algorithm recognise a cat? Using a training set with photos of cats, I developed my algorithm with the help of a confusion matrix.</p><p>We started with AlloCiné’s usage contexts to clarify what each algorithm would need to do:</p><p>● After a user watches a trailer, can we recommend a new item for the user to watch?</p><p>● When a user visits the page of a movie or series, can we quantify their affinity for the movie or series?</p><p>● When a user is searching for movies to watch, can we offer a list of movies using mechanisms that emphasise why we are recommending those specific items?</p><p>The second question is primarily a matter of implementing something into production while adapting to the architecture of AlloCiné and the cost structure of the media universe.</p><p>This article focuses on the movie-user affinity score, but we will tell you more about the other subjects soon.</p><h3>Calculating affinity scores for each movie for registered AlloCiné users</h3><p>To do this, we decided to explore <strong>collaborative filtering </strong>techniques. This groups users together depending on their taste, based on the ratings they have provided. The affinity score displayed to a user for a given movie or series is calculated based on ratings left by users with similar preferences.</p><p>This algorithm turned out to be very effective on AlloCiné. It is based on reviews left on more than 12,000 movies and series. There is so much data available that we are able to take into consideration a wide range of tastes, make very personalised recommendations and propose niche content to the relevant users.</p><p>This technique has already been explored by other players in the industry. In 2009, Netflix organised a contest to find the best collaborative filtering algorithm to apply to its data. The winner received 1 million dollars. GroupLens, a research group associated with the University of Minnesota, has also carried out significant work on this issue. Through an open site, they collected more than 11 million ratings on 8,500 movies, which they then made public. (<a href="https://en.wikipedia.org/wiki/MovieLens">https://en.wikipedia.org/wiki/MovieLens</a>)</p><h3>What is special about collaborative filtering algorithms?</h3><p>Very many movies and series, and even more users… If we were to create an affinity matrix for users and movies or series, with each row representing a user and each column representing a movie/series, there would be billions of boxes. But more than 99% of them would be empty. What is the goal of such a system? To be able to fill in the “missing data” using the 1% of existing ratings that have been provided by users.</p><p>We are thus dealing with two different challenges:</p><p>- managing thousands of user variables in order to predict each user’s affinity for every single movie or series</p><p>- limiting the calculation time: we cannot store billions of pieces of information (the 99% predicted values); who wants to wait more than 30 seconds to see their recommendation score?</p><p>The creation of a recommendation system is thus a problem of <strong>dimensionality reduction</strong>: we want to determine the taste of a user based on a limited number of characteristics.</p><p>We have at our disposal a way to evaluate the performance of the algorithm qualitatively: the ratings already submitted by a user. These are mainly used to feed the model and learn, but some are reserved for tests. The algorithm is optimised using these existing ratings. They also let us create a benchmark, as <a href="https://link.springer.com/chapter/10.1007%2F978-3-540-68880-8_32">Netflix did</a> for example with the creation of the famous <a href="https://en.wikipedia.org/wiki/Netflix_Prize">Netflix Prize</a>. Ratings are very subjective, which means that the algorithm’s relevance can be affected. That is why we also decided to qualitatively evaluate the accuracy of the algorithm with a panel of users.</p><h3>What was the purpose of this project?</h3><p>The project had 3 main goals:</p><p>- to offer relevant and sufficiently discriminatory affinity scores for movies and series on AlloCiné. Ratings submitted on the platform tend much more towards the positive than the negative, and it can be complicated to determine the movies and series that, despite having primarily positive ratings, are not to the taste of a specific user.</p><p>- to integrate into AlloCiné’s existing technical architecture</p><p>- to create an algorithm capable of handling a sufficient load to be able to remain responsive during peak connection hours in the evening.</p><h3>Why the requirement of 20 movies or series?</h3><p>We started by choosing to focus on our most active users. We prioritised quality over quantity: after conducting both quantitative tests (optimisation of functions and costs) and qualitative tests (questionnaires given to panels of users), <strong>we decided to require a minimum of 20 ratings before a user starts receiving affinity scores</strong>. Of course, at this threshold, the algorithm is not completely accurate. The more ratings a user provides, the more precise the algorithm will be.</p><p>We also studied the stability of movie or series scores and <strong>decided to display affinity scores to users only for movies and series that had received at least 100 ratings</strong>. In fact, ratings tend to stabilise after this threshold has been reached: a new user who rates a movie that has already been rated 100 times should not have much of an effect on the scores of other users.</p><p>To address the issue of the required threshold of data (commonly called a “cold start”,) AlloCiné used a technique offering each user a list of movies or series to rate (“speed-rating”) to reach 20 or more ratings.</p><h3>What algorithm was chosen?</h3><p>We chose to use a Spark framework with Python, with a <strong>collaborative filtering algorithm based on a latent factor model.</strong> The number of latent factors is the number of characteristics that explain the score offered by the algorithm, and is not a fixed value. The fact that an algorithm was put into production changed the configuration of our base. We therefore need to be careful to ensure that our cost function changes very little over time. If it increases, we carry out “hyperparameter retuning” to re-optimise the algorithm. We thus implemented an algorithm that automatically recalculates the optimal set of hyperparameters on the 1st of each month.</p><p>The primary drawback of this algorithm is that it can be slow to update: the addition of each new user or new movie or series requires the algorithm to be refreshed. To compensate, we send fairly small files to our API (the latent factors of users and movies or series), which means that even when the API is receiving numerous calls, it is generally able to respond within a few milliseconds. Other methods allow new ratings to be taken into account immediately, but they run the risk of not being able to handle the load.</p><h3>How does it work, technically speaking?</h3><p>We collect new ratings from users in almost-real time. Then the algorithm refreshes every 10 minutes: there is a certain delay before new users or movies or series can enter the system. However, once a user has joined the system (by rating at least 20 movies or series), he or she will never leave the system and will see recommendation scores for all eligible entities (those having received at least 100 user ratings). In addition, even users who have only rated movies can still have scores for series. The opposite is also true; users who have only rated series will still receive scores for movies.</p><p>This workflow uses the Google Cloud platform. For running the algorithm, we use BigQuery to prepare the data and then Dataproc to manage the Spark cluster that train the collaborative filtering algorithm. Recommendations can thus be displayed in real-time via an API hosted by the AppEngine service. The structure of the data in the API is quite specific: we do not store all recommendations for each and every user. We store the latent factor matrix, which lets us calculate the necessary recommendations “on the fly”.</p><p>For 1 million users and 10,000 movies, we would otherwise have to store a matrix with10 billion variables. It would have to be refreshed very frequently and most of the variables would not be used between each refresh. On the other hand, with the system we put in place, for a number of latent factors equal to 20, it comes down to refreshing a “user” matrix with twenty million variables and a “movie” matrix with two hundred thousand variables. We can thus store these items in RAM and calculate recommendations very quickly on the fly.</p><p>The use of a cloud platform greatly accelerated the implementation of the project. We needed to validate the effectiveness of the algorithms internally before implementing them. Google Cloud Platform allowed us to create a prototype of the algorithm for a very low cost in an environment similar to the one that is now used in production. Its tools BigQuery, Dataproc and AppEngine made it very easy for us to determine the dimensions of the server.</p><h3>What’s next?</h3><p>We are working with the product and technical teams of AlloCiné to design new personalised functionalities. They are intended to make it easier to explore the catalogue of movies through the use of recommendation algorithms and filtering systems. We hope to be able to offer users a more detailed explanation of why certain items are recommended to them.</p><p>In addition, models based on the statistics will also be used, notably to improve the order in which reviews on movies and series are displayed.</p><p><strong>Many thanks to anyone who participated in making it possible</strong> 👏, and especially to Marylise Oger, Valentin Strach, Rui teixeira, Sebastien Caumes and Mohamed Belmaaza</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62392537fb59" width="1" height="1" alt=""><hr><p><a href="https://webedia.io/personalised-recommendations-for-films-and-tv-series-webedias-data-science-team-explains-how-they-62392537fb59">Personalised recommendations for films and TV series: Webedia’s Data Science team explains how they…</a> was originally published in <a href="https://webedia.io/">Webedia I/O</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>