<?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 Praneeth Paikray on Medium]]></title>
        <description><![CDATA[Stories by Praneeth Paikray on Medium]]></description>
        <link>https://medium.com/@paikraypraneeth?source=rss-7df3fbeae6c7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iyRKPY20BSO_MKB_FytDaA.jpeg</url>
            <title>Stories by Praneeth Paikray on Medium</title>
            <link>https://medium.com/@paikraypraneeth?source=rss-7df3fbeae6c7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 10:52:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@paikraypraneeth/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[Thinking, Fast and Slow with Databricks Genie]]></title>
            <link>https://pub.towardsai.net/thinking-fast-and-slow-with-databricks-genie-29e908ac2a6e?source=rss-7df3fbeae6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/29e908ac2a6e</guid>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[databricks-genie]]></category>
            <category><![CDATA[chatbots]]></category>
            <dc:creator><![CDATA[Praneeth Paikray]]></dc:creator>
            <pubDate>Mon, 02 Nov 2026 12:01:02 GMT</pubDate>
            <atom:updated>2026-11-02T13:44:57.617Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Genie can now answer fast or slow. I tested when the slow answer is worth the wait.</em></h4><figure><img alt="Hand-drawn statechart. Flash and Standard answer the same question at the same time: how did shipment volume change from September to October. Flash runs one query and, unless you named the check, says volume fell by 300, which is wrong. Standard checks which dates exist, finds that October stops on the 15th, compares volume per day and says volume rose from 30 to 40 a day. Below, a fast courier, parcels, a calendar with the second half of October torn off, an hourglass and a clerk with a magnif" src="https://cdn-images-1.medium.com/max/1024/1*jzC82DVGMHcOfjLMFS0pvQ.png" /></figure><h3>Fast and slow thinking</h3><p>In <em>Thinking, Fast and Slow</em>, Daniel Kahneman describes two ways people think. System 1 is fast and automatic, and it answers from whatever is in front of it. System 2 is slow and takes effort, and it can check whether the first answer holds up. Most of the time System 1 is good enough. The trouble is that it does not notice when it is wrong. Kahneman calls this habit <em>what you see is all there is</em>. System 1 builds the best story it can from the information it has, and it does not ask what is missing.</p><p>Genie Agent mode now offers a similar choice. If you switch on the lightning button next to Agent, you get <a href="https://docs.databricks.com/aws/en/ai-bi/release-notes/2026">Flash</a>, which spends less time reasoning and answers faster. If you leave it off, you get standard Agent mode, which takes longer and checks more. I will call them Flash and Standard.</p><figure><img alt="The Genie agent “Meridian Parcel Operations” with a question typed in. Agent is selected and the lightning button for Flash is switched on." src="https://cdn-images-1.medium.com/max/1024/1*0EV_Fw4mkNJsmwly59UgDQ.png" /></figure><p>Databricks <a href="https://docs.databricks.com/aws/en/genie-agents/concepts">recommends Flash for simpler tasks</a>. But that volume question looks simple, and nothing in it says that half of October is missing. So I wanted a practical answer. When is the fast answer enough, and when should I wait for the slow one?</p><h3>How I tested it</h3><p>I made up a delivery company called Meridian Parcel and hid traps in its data. Each one is a number that points the wrong way at first glance, plus one check that shows the truth. For example:</p><ul><li>A month of data stops halfway.</li><li>Every row for a month was loaded twice.</li><li>An average falls only because the mix of parcels changed.</li></ul><p>For each trap, I also built a control network where the first number is correct. A good answer should not invent a problem there.</p><p>I asked about each network in three ways:</p><ul><li>A lookup asks for a figure, e.g., the average delivery time in each month.</li><li>A directed question names the check, e.g., it asks for volume per day.</li><li>An open question asks what a manager would ask, like the volume question at the start, and leaves the check to Genie.</li></ul><p>I ran the test in two rounds. The first round used four everyday cases, such as a complaint count that rises while the complaint rate falls. After seeing the results, I built a second round with four harder traps that the agent’s instructions never mention, such as the half month of data. I asked every question five times in each mode, each time in a fresh conversation, for 480 answers in all.</p><p>Before each round, I wrote down what a correct answer had to contain. Another AI model graded every answer against that list without knowing which mode wrote it, and I checked a sample by hand. A review found two mistakes in my first round list, so I fixed them, regraded everything, and settled a few uneven grades by hand. The <a href="https://github.com/Praneeth16/genie-flash-vs-standard/blob/main/notes/key_changes.md">change log</a> lists each change.</p><h3>When fast is enough</h3><p>When the question named the check, <strong>Flash did almost as well as Standard</strong>. Both reached the right conclusion in all 40 directed answers in the first round. In the second round, Flash missed 2 of 40 and Standard missed none. On the first round lookups, Flash got every one right.</p><p>This fits Kahneman’s picture. System 1 does fine when someone points it at the right thing. If I ask Genie for volume per day, Flash computes volume per day. It does not need to work out that it should.</p><figure><img alt="Dot chart of first round answers that met every check, by question type. Lookup: Flash 40/40, Standard 39/40. Directed: Flash 36/40, Standard 40/40. Open: Flash 26/40, Standard 37/40." src="https://cdn-images-1.medium.com/max/1024/1*0RISGPEKv-ihyQANDWnSyA.png" /></figure><p>In the first round, the gap on directed questions came from detail. Flash sometimes gave the right answer without the numbers behind it. One second round miss was stranger. Flash found that the complaint rate in remote deliveries fell from 8% to 7%, and then wrote that it had “nearly quadrupled”. Even when you name the check, read the numbers.</p><h3>When the obvious number is wrong</h3><p>The open questions are where the two modes split. In the second round, Flash reached the right conclusion on the partial month, duplicate and mix traps in <strong>0 of 15 runs</strong>. Standard reached it in <strong>10</strong>.</p><p>Flash usually ran one query and reported what it saw. When every October row had been loaded twice, Flash said volume “doubled” in all five runs. When a complaint rate rose overall but fell in both delivery zones, Flash said it got worse every time. This is <em>what you see is all there is</em> in practice. The first query returns a plausible number, and nothing in the number says it is wrong.</p><figure><img alt="Dot chart of second round open answers that reached the full conclusion. Half of October missing: Flash 0/5, Standard 5/5. October rows loaded twice: Flash 0/5, Standard 2/5. Complaint rate with a change in zone mix: Flash 0/5, Standard 3/5. The control for the zone mix trap: both 0/5. The other controls and the internal test parcel trap: both 5/5." src="https://cdn-images-1.medium.com/max/1024/1*PrVye8bGEmNoVqZ16KYktg.png" /></figure><p>Standard ran more queries before it answered. On the volume question, it checked which dates the October data covered each time. On a first round delivery question, it split the parcels into local and remote deliveries in four of five runs, and found that both had got slower. The overall average had fallen from 6.8 days to 4.2 only because October shipped far more local parcels, and local parcels are quick.</p><figure><img alt="Animation of 1,000 parcels. The local share grows from 20% to 80% while local and remote delivery times each rise by one day. The overall average moves from 6.8 days down to 4.2 days." src="https://cdn-images-1.medium.com/max/990/1*C67e3H5XdS3tPvJMODLvvQ.gif" /></figure><p>The checks cost time. On the open questions in the second round, Flash took a median of 11 seconds and Standard took 26.</p><h3>Slow is not always right</h3><p>Standard was not flawless. It found the duplicate rows in only two of five runs, and it overthought. One lookup asked only for two averages, and Standard added “Delivery time improved by 2.6 days month-over-month”, which is the misreading the trap was built to catch. On a control where the complaint rate did get worse, Standard twice ran a significance test and declined to call it worse. Every other answer, from both modes, said worse without looking at the zones, so none of them passed my checks.</p><p>Standard also wrote more. Its median open answer in the first round had 233 words, against 63 for Flash. In those open answers, the grading model found 25 claims that the data did not support in Standard’s answers, against 8 in Flash’s. More reasoning gave Standard more room to be useful and more room to be wrong.</p><h3>So which one should you use?</h3><p>Here is how I plan to choose:</p><ul><li><strong>Flash, when I can name the check.</strong> I ask for volume per day rather than volume, and I ask for the supporting numbers, because Flash tends to leave them out.</li><li><strong>Standard, when the obvious number could be wrong</strong> for a reason I have not thought of. Partial months, duplicate rows and shifts in mix caught Flash in every open run.</li></ul><p>In Kahneman’s terms, Flash behaves like System 1, and the person asking has to be System 2.</p><p>The data, questions, runner, raw responses and grades are in <a href="https://github.com/Praneeth16/genie-flash-vs-standard">github.com/Praneeth16/genie-flash-vs-standard</a>, so you can run the same test on your own Genie agent.</p><h3>Sources</h3><ol><li>Daniel Kahneman. Thinking, Fast and Slow. Farrar, Straus and Giroux, 2011.</li><li><a href="https://docs.databricks.com/aws/en/ai-bi/release-notes/2026">Databricks. AI/BI and Genie release notes 2026 (15 October 2026: Flash Beta).</a></li><li><a href="https://docs.databricks.com/aws/en/genie-agents/concepts">Databricks. Genie Agents concepts (Flash and standard Agent mode).</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29e908ac2a6e" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/thinking-fast-and-slow-with-databricks-genie-29e908ac2a6e">Thinking, Fast and Slow with Databricks Genie</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hiring Genie Code as your eval coworker]]></title>
            <link>https://pub.towardsai.net/hiring-genie-code-as-your-eval-coworker-dec2877e758a?source=rss-7df3fbeae6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/dec2877e758a</guid>
            <category><![CDATA[ai-coding-agent]]></category>
            <category><![CDATA[harness-engineering]]></category>
            <category><![CDATA[databricks-genie]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Praneeth Paikray]]></dc:creator>
            <pubDate>Sat, 17 Oct 2026 12:48:53 GMT</pubDate>
            <atom:updated>2026-10-19T06:01:17.809Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hiring Genie Code as Your Eval Coworker</h3><h4><em>Same eval job, 200 airline support conversations, and answers the agents never saw.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*lPCdIeYrcZ_PKBZ541ducg@2x.jpeg" /></figure><h3>In short</h3><ul><li>I asked Genie Code and Codex to work as the eval engineer for an AI airline support agent. Each worked with and without Hamel Husain and Shreya Shankar’s open-source evals-skills. Both agents used the same prompt and model, and I hid the correct pass/fail answers from them.</li><li>Without expert labels, no agent got the success rate right. They reported anything from 29.5% to 70%. The true rate was 56%.</li><li>After an expert labeled 100 conversations, both Genie Code runs built better judges. On scenarios they had never seen, they were 72–74% accurate, against 61–64% for Codex. Their estimates were also closer to the truth.</li></ul><h3>What did I test?</h3><p>Hamel Husain and Shreya Shankar teach a clear method for evaluating LLM apps:</p><ol><li>Read real traces first.</li><li>Name the failure modes you see.</li><li>Write pass/fail checks, in code where you can.</li><li>Trust an LLM judge only after you check it against a domain expert’s labels.</li></ol><p>I wanted to know if Genie Code CLI, the Databricks coding agent for your terminal (in Beta), follows this method better than a general coding agent.</p><p>The data is from τ²-bench, a public benchmark from Sierra. It has 200 conversations between an AI airline agent and simulated customers who book, change and cancel flights. For each conversation, the benchmark knows whether the final booking database is right. That gave me a hidden answer key to grade the agents with.</p><figure><img alt="Four setups get the same 200 conversations: Genie Code, Genie Code plus evals-skills, Codex, and Codex plus evals-skills. Each produces an eval and a pass rate for leadership. A hidden answer key of 112 passes and 88 fails grades every eval." src="https://cdn-images-1.medium.com/max/1024/1*IETLYHV3C5nY_J2TQjB5jw.gif" /></figure><p>My prompt read like a real request: <em>“Leadership wants to know how good the agent really is and what to fix first. Build an evaluation the team can keep running. No human is available.”</em></p><h3>What did the agents build before any labels existed?</h3><p>All four followed the method. Each read the policy and the conversations before choosing what to measure. Each built pass/fail checks in code before it reached for an LLM judge, and each wrote down what it hadn’t validated. They also found the same top problems: cancellations the policy didn’t allow, changes made without the customer’s confirmation, and several tool calls at once where the policy allows one.</p><p>Genie Code with evals-skills was the strictest. It refused to build an LLM judge until an expert had labeled examples. It built a review app and labeling instructions for that expert instead. It was also the fastest run, at 8 minutes and 2 million input tokens. The other runs took 10–28 minutes and 4–5.6 million tokens.</p><p>Then I checked the pass rates they reported.</p><figure><img alt="The pass rates the four setups reported: Genie Code 38%, Genie Code plus evals-skills 70%, Codex 66%, Codex plus evals-skills 29.5%. A dashed line marks the true rate of 56%. None of the bars is close to it." src="https://cdn-images-1.medium.com/max/1024/1*aUZ8fEquC68x3GK9Kz6mZw.gif" /></figure><p>None was close, and that is the method’s point. Code checks can see a cancellation without confirmation. They can’t see a booking for the wrong flight, because they don’t know what the customer wanted. Most of the conversations they wrongly passed had that kind of error. Without labels, nobody can tell which number to trust.</p><h3>What changed when an expert labeled 100 conversations?</h3><p>I told each agent that an airline-policy expert had labeled 100 conversations as pass or fail, with a note on each. The labels came from the benchmark’s answer key.</p><p>The benchmark runs each of its 50 scenarios four times. I gave labels for 25 scenarios and kept the other 25 hidden. That way I could test each final judge on scenarios it had never seen. I asked for one success rate leadership can trust, stored in Unity Catalog and MLflow.</p><p>Genie Code with evals-skills followed the method step by step:</p><figure><img alt="The 100 labels split into train 16, dev 44 and test 40. On the dev set, the share of failures the judge caught rose from 47% with judge v1 to 95% with v4. The final judge ran once on the test set and got 86% of passes and 83% of failures right. A correction formula turns the measured pass rate into an estimate of 51.9%, against a true rate of 56%." src="https://cdn-images-1.medium.com/max/1024/1*kH7UE_B5tTpmZ9Ib3zK9fQ.gif" /></figure><ol><li><strong>Split.</strong> It divided the labels into train, dev and test sets.</li><li><strong>Tune on dev only.</strong> It rewrote its judge prompt four times. It never looked at the test set while doing so.</li><li><strong>Test once.</strong> It ran the final judge on the test set one time.</li><li><strong>Correct the rate.</strong> It adjusted the measured pass rate for the judge’s known errors. This is the method in the course’s judgy library.</li></ol><p>Genie Code with its built-in skills took a different route. It didn’t trust its judge’s raw pass rate. It used the expert labels where they existed and estimated the unlabeled conversations within each request type. It also stated the assumption that estimate depends on.</p><figure><img alt="Estimates with 95% intervals against the true rate of 56%. Genie Code plus evals-skills estimated 51.9% (37.6 to 64.7), and its judge was 74% accurate on unseen scenarios. Genie Code estimated 57.1% (50.5 to 63.5), at 72%. Codex estimated 61.5% (51.9 to 70.4), at 64%. Codex plus evals-skills estimated 40.2% (28.0 to 61.0), at 61%." src="https://cdn-images-1.medium.com/max/1024/1*Dm1AsX37q2UPUS2Vo7irvA.gif" /></figure><p>Every interval contains the true 56%. Genie Code’s built-in run landed 1.1 points away, with the narrowest interval of the four. Both Genie Code judges also did better on new scenarios than either Codex judge.</p><h3>Why does accuracy on labeled data mislead?</h3><figure><img alt="Accuracy on labeled conversations compared with unseen scenarios. Codex plus evals-skills falls from 97% to 61%. Genie Code plus evals-skills falls from 91% to 74%. Genie Code falls from 84% to 72%. Codex falls from 81% to 64%." src="https://cdn-images-1.medium.com/max/1024/1*yu1lqwkbkfnPeb4XjN3TFw.gif" /></figure><p>Every judge looked better on the conversations it was built from. Real traffic repeats scenarios too, such as the same refund request from different customers. When copies of a scenario land in both your training and test sets, the judge looks better than it is. So split your labels by scenario, and keep some scenarios out of the labeled set entirely.</p><h3>Where does the eval live afterwards?</h3><p>All four runs stored their work in the Databricks workspace:</p><ul><li><strong>Unity Catalog:</strong> labels, conversations and verdicts as versioned Delta tables.</li><li><strong>MLflow:</strong> runs that log each estimate and the judge’s validation results.</li><li><strong>Rerun:</strong> a notebook or a job that reruns the evaluation.</li></ul><p>Genie Code with evals-skills also versioned its judge prompts in the MLflow Prompt Registry. Codex with evals-skills registered its judge as a Unity Catalog model.</p><h3>How can I try this on my own agent?</h3><ol><li>Install Genie Code CLI and the Databricks CLI, then run genie in a folder with your traces.</li><li>Copy evals-skills into .agents/skills in that folder.</li><li>Ask for an evaluation the team can keep running, not for a metric.</li><li>Have a domain expert label about 100 conversations. Spread them across scenarios, with roughly as many passes as fails.</li><li>Ask Genie Code to finish the evaluation. Then check that it split the labels by scenario, tested the judge once on held-out labels, corrected the pass rate for judge error, and stored the results in Unity Catalog and MLflow.</li></ol><h3>FAQ</h3><h4>Can Genie Code replace the domain expert?</h4><p>No. No agent measured the success rate correctly without labels. What Genie Code does is make the expert’s time count. It prepares the review, then turns 100 labels into a judge and an estimate you can rerun.</p><h4>How much should I trust these results?</h4><p>Treat them as one careful test, not a benchmark. Each setup ran once, and with 100 test conversations the accuracy gap is about two standard errors. The customers were simulated, and the labels came from the benchmark’s answer key, not from a person.</p><h3>Sources</h3><ul><li><a href="https://hamel.dev/blog/posts/evals-faq/">Hamel Husain, “Frequently Asked Questions about LLM evals”</a></li><li><a href="https://github.com/ai-evals-course/evals-skills">evals-skills</a> and <a href="https://github.com/ai-evals-course/judgy">judgy</a></li><li><a href="https://arxiv.org/abs/2506.07982">τ²-bench paper</a> and <a href="https://github.com/sierra-research/tau2-bench">repository</a></li><li><a href="https://docs.databricks.com/aws/en/genie-code/genie-code-cli">Genie Code CLI (Beta)</a></li><li><a href="https://docs.databricks.com/aws/en/mlflow3/genai/prompt-version-mgmt/prompt-registry/">MLflow Prompt Registry on Databricks</a></li></ul><p><em>*All conversations in this article come from a public benchmark with simulated customers.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dec2877e758a" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/hiring-genie-code-as-your-eval-coworker-dec2877e758a">Hiring Genie Code as your eval coworker</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Giving Your AI Coworker Enterprise Context with Databricks Genie]]></title>
            <link>https://pub.towardsai.net/giving-your-ai-coworker-enterprise-context-with-databricks-genie-a3bc8113790f?source=rss-7df3fbeae6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3bc8113790f</guid>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[ontology]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[context-engineering]]></category>
            <dc:creator><![CDATA[Praneeth Paikray]]></dc:creator>
            <pubDate>Wed, 14 Oct 2026 19:43:11 GMT</pubDate>
            <atom:updated>2026-10-15T09:01:18.916Z</atom:updated>
            <content:encoded><![CDATA[<h4>From team rules to company definitions, across Genie One and Code.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ukjlajAy1C62cf6oZxil9A.png" /></figure><h3>In short</h3><ul><li>Databricks Genie gives an AI coworker four places to hold enterprise context: instructions for team rules, skills for repeatable tasks, memory for personal preferences and Genie Ontology for company definitions.</li><li>In my test, Genie One and Genie Code read skills from the same personal folder, so a skill I made in one showed up in the other.</li></ul><h3>What is enterprise context for an AI coworker?</h3><p>Enterprise context is the knowledge an AI coworker needs to do your work the way your company does it. It is what a new hire picks up in their first weeks: the team’s rules, how recurring jobs get done, how you like to work and what the company’s terms mean.</p><p>Databricks has two AI coworkers that use this context. Genie One is the AI coworker for business users, who ask it questions about company data in plain language. Genie Code is the AI coworker for technical work, and it writes and runs code in your Databricks workspace.</p><p>To see how the context works in practice, I set up both of them as one person, an analytics engineer at Lumora. Lumora is a made-up software company that sells subscriptions, and all the data in my setup is sample data. Each kind of context ended up in its own place in Genie.</p><figure><img alt="Four cards, one for each Genie feature. Instructions are a new hire’s role description and team rules, and apply to a workspace or one user. Skills are playbooks for repeated tasks, and apply to one user or a whole workspace in Genie Code. Memory is what a new hire learns on the job, and applies to you. Genie Ontology is the company glossary, and applies to the whole company. Genie One and Genie Code use all four." src="https://cdn-images-1.medium.com/max/1024/1*iWpvDvMuA3T4sYuLU_Wppg.png" /></figure><h3>Where should each piece of context go?</h3><p>The rule I ended up with is short. If a fact is true for the whole company, it goes in Genie Ontology. If it is a rule for your team, it goes in instructions. If it is a task you repeat, it goes in a skill. If it is only about you, it goes in memory.</p><p>This is how the rule sorted the facts from my Lumora setup:</p><ul><li>Genie Ontology: “An active customer is a paying customer who logged in within 30 days” and “Our fiscal year starts on February 1.”</li><li>Instructions: “New tables go in the dev schema first” and “Ask before you drop a table.”</li><li>Skills: “Review a table with these six checks before it ships” and “Every Monday, send me a one-page brief,” which a scheduled task can run.</li><li>Memory: “When I say my region, I mean APJ” and “Show me numbers in a table first.”</li></ul><p>The sections below follow the order a new hire learns things in. Rules come on day one and playbooks in the first week. What they learn about you comes with time, and the company glossary sits underneath all of it.</p><h3>How do I tell Genie who I am and how my team works?</h3><p>A new hire’s first day starts with who they are working for and the house rules. In Genie, that is the instructions file. It is a Markdown file, which is plain text with simple formatting, and Genie reads it at the start of every conversation.</p><p>Genie Code looks for two of them. Your own rules go in .assistant_instructions.md in your user folder, and rules for everyone go in .assistant_workspace_instructions.md at the root of the workspace. Genie Code generally gives the workspace file priority unless you tell it otherwise. It also reads any AGENTS.md or CLAUDE.md file in the folders you work in. Each file can hold up to 20,000 characters, and Genie Code ignores anything past that.</p><p>My Lumora file was short. This is a shortened copy, where B2B SaaS means subscription software sold to businesses:</p><pre># About me<br>I am an analytics engineer on the RevOps data team at Lumora, a B2B SaaS<br>company. I build pipelines and metric views.<br> <br># How I work<br>- Write SQL first. Use Python only when SQL can&#39;t do it.<br>- New tables go in the lumora_dev schema. Never write to lumora directly.<br>- Every new table gets a table comment and a comment on each column.<br> <br># Ask before you act<br>- Ask before you drop, overwrite or rename a table.</pre><p>To check it, I opened a new chat and asked Genie Code, “What do you know about me and the rules I want you to follow?” It listed every rule from the file back to me.</p><p>Genie One handles instructions differently. It has one instructions file per workspace, which an admin writes at /Workspace/.genie_workspace_instructions.md, and that file applies only to Genie One chat. There is no personal instructions file in Genie One, so your own preferences go in memory instead.</p><h3>How do I teach Genie a task it should repeat?</h3><p>Rules tell a new hire what to avoid. Playbooks show them how to do the jobs that come up every week. In Genie, a playbook is a skill: a folder with a SKILL.md file that starts with a name and a one-line description, followed by step-by-step instructions. Genie skills follow the open Agent Skills format.</p><p>My first skill covered a job I do often, reviewing a table before it ships. A shortened copy:</p><pre>---<br>name: pipeline-review<br>description: Review a Lumora pipeline or table change before it ships. Use when<br>  asked to review, check or sign off a pipeline or a table.<br>---<br>Run these checks in order. Report each one as PASS or FAIL with one line of evidence.<br>1. Comments. The table and every column have a comment.<br>2. Schema. New tables are in lumora_dev, not lumora.<br>3. Row count. Flag any change above 5 percent compared with the source.<br>4. Nulls. List key columns where more than 1 percent of rows are null.<br>5. Duplicates. Check that the primary key is unique.<br>6. Definitions. If the table computes customers, MRR or churn, check the logic against Genie Ontology.<br>End with one of these: ship, ship with fixes, or do not ship.<br>Do not change any table during a review.</pre><p>I saved it in my personal skills folder, /Users/&lt;your-email&gt;/.assistant/skills/pipeline-review/, and typed &quot;Please review the subscriptions table before we ship it.&quot; I never named the skill. Genie Code matched my request to the skill&#39;s description, loaded the skill and made a plan with one step per check. This is why the description matters most. If it does not say what the skill does and when to use it, Genie has no reason to load it.</p><p>The review ended with “ship with fixes” because the table had no comments and sat in the wrong schema, which broke two rules from my instructions file.</p><p>In Genie One you make a skill by asking for it, for example “Create a skill called monday-brief that gives me a one-page brief for my region,” and you run it by typing /monday-brief.</p><p>That skill led to the most useful finding of my test. Genie One saved monday-brief in the same personal folder as my Genie Code skill. When I asked each product which skills it had, Genie One listed pipeline-review and Genie Code listed monday-brief. You can keep your personal skills in one folder and use them from both products.</p><figure><img alt="Genie Code lists the monday-brief skill that was created in Genie One." src="https://cdn-images-1.medium.com/max/760/1*SpoD1k-92_jmaUO9Y5kx8g.png" /></figure><h3>How does Genie remember things about me, and how do I check what it saved?</h3><p>Some things a new hire only learns by working with you, like what you mean by “my region” or how you like numbers shown. Genie keeps these as memories, which are short facts about you that it saves and uses in later conversations.</p><p>You save one by starting a message with “Remember that.” When I told Genie One, “Remember that when I say my region I mean APJ at Lumora,” it showed a “Saving a memory” step in the chat. When a later answer uses a memory, Genie One adds a citation that shows which one.</p><p>Genie Code also saves memories on its own when it learns something useful. When I asked it, “What do you remember about me?”, it listed my one saved preference and added, “Everything else I know comes from your .assistant_instructions.md, which I read fresh each session.” That line shows the difference between the two. Instructions apply to every conversation, and a memory comes up only when it fits the task.</p><p>Memories go out of date, so check them about once a month. Ask each product what it remembers and tell it to forget anything stale. In my test, both products deleted the memory I named and confirmed what was left. Also make sure no memory holds a password or an API key, because Genie saves what you tell it.</p><h3>Why do company definitions belong in Genie Ontology instead of skills?</h3><p>The last piece is the company glossary, and it is the one that most needs to be shared. Genie Ontology is the shared layer of business context in Databricks. Genie One and Genie Code can both use it, and so can Genie Agents. It has two parts. The first is the metric views and pages you write in Unity Catalog, which is where Databricks keeps your tables and their descriptions. A metric view is a saved definition of a business number, such as MRR (monthly recurring revenue). The second is context that Databricks pulls from what you already have, such as dashboards, saved queries and Genie Agents.</p><p>My test showed what goes wrong when a definition lives somewhere else. My test workspace is shared with other demos. When Genie One built the monday-brief skill, it searched the workspace for a definition of MRR, found a glossary page from a different demo and wrote that formula into the skill. The formula broke three Lumora rules:</p><ul><li>It added up subscription amounts as stored. Lumora stores the full yearly price on annual plans, so MRR has to divide those amounts by 12.</li><li>It used the calendar quarter, but Lumora’s fiscal year starts on February 1.</li><li>It counted every canceled subscription as churn, including customers who only moved to a bigger plan.</li></ul><p>Because the formula was written into the skill file, the skill would have repeated these mistakes every Monday. A better skill names the term and points to its Genie Ontology definition, for example “Use the Genie Ontology definition of MRR.” Then you fix a definition in one place instead of in every skill, and you can check the sources Genie cites in its answer.</p><p>Memory is the wrong place for definitions too. Genie One memories are private to you, so your teammates would not get the same answer you do.</p><p>This is how I wrote one Lumora term as a page:</p><pre>## Active customer<br>An active customer is a paying customer with at least one &#39;login&#39; event in<br>the last 30 days. API calls, report runs and exports do not count, because<br>integrations can keep running when nobody uses the product.</pre><h3>FAQ</h3><h4>Do I need Genie Ontology before I start?</h4><p>No. You can start on day one with an instructions file and one skill. Add Genie Ontology pages when your team needs the same answer to the same question, such as how many customers you have.</p><h4>Can my whole team use the same skill in Genie Code?</h4><p>Yes. Genie Code also reads skills from Workspace/.assistant/skills/, so a skill saved there works for everyone in the workspace, not only for you.</p><h3>Sources</h3><ul><li><a href="https://docs.databricks.com/aws/en/genie-code/instructions">Customize Genie Code with instructions</a></li><li><a href="https://docs.databricks.com/aws/en/genie-one/chat">Chat in Genie One</a></li><li><a href="https://docs.databricks.com/aws/en/genie/genie-ontology">Genie Ontology</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3bc8113790f" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/giving-your-ai-coworker-enterprise-context-with-databricks-genie-a3bc8113790f">Giving Your AI Coworker Enterprise Context with Databricks Genie</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ontology 101, Part 2: Building Knowledge Graphs for GraphRAG]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://pub.towardsai.net/ontology-101-part-2-building-knowledge-graphs-for-graphrag-914c833af8df?source=rss-7df3fbeae6c7------2"><img src="https://cdn-images-1.medium.com/max/1672/1*aKTUV85q4jfgGC08z8iYiQ.png" width="1672"></a></p><p class="medium-feed-snippet">Ontology 101, Part 2 of 5. Last week you wrote one churn rule into a file a machine can read. This week you walk the same accounts through&#x2026;</p><p class="medium-feed-link"><a href="https://pub.towardsai.net/ontology-101-part-2-building-knowledge-graphs-for-graphrag-914c833af8df?source=rss-7df3fbeae6c7------2">Continue reading on Towards AI »</a></p></div>]]></description>
            <link>https://pub.towardsai.net/ontology-101-part-2-building-knowledge-graphs-for-graphrag-914c833af8df?source=rss-7df3fbeae6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/914c833af8df</guid>
            <category><![CDATA[knowledge-graph]]></category>
            <category><![CDATA[ontology]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Praneeth Paikray]]></dc:creator>
            <pubDate>Tue, 15 Sep 2026 23:01:01 GMT</pubDate>
            <atom:updated>2026-09-15T23:01:01.943Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[What an Ontology Actually Is]]></title>
            <link>https://pub.towardsai.net/what-an-ontology-actually-is-75fc2606c7e8?source=rss-7df3fbeae6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/75fc2606c7e8</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[knowledge-graph]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ontology]]></category>
            <dc:creator><![CDATA[Praneeth Paikray]]></dc:creator>
            <pubDate>Fri, 21 Aug 2026 22:01:01 GMT</pubDate>
            <atom:updated>2026-08-21T22:01:01.496Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Ontology 101, Part 1 of 5: A hands-on series that starts at first principles and ends at Databricks Genie Ontology. Each part ends with a working artifact you carry into the next.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LMqSpw752r_zvqKBTH_INQ.png" /><figcaption>Ontology 101</figcaption></figure><p>Two dashboards at the same company report churn for the same quarter. One says 4.1 percent. The other says 6.8 percent. Both are correct. One counts an account as churned when the subscription lapses. The other counts it when usage drops to zero for thirty days because the sales team argues that a lapsed contract with active users is a renewal conversation, not a loss.</p><p>Neither definition is written down anywhere a machine can read. Both live in the heads of the analysts who built the dashboards, one of whom left in March.</p><p>Now put an AI agent in front of that warehouse and ask it, &quot;What&#39;s our churn?” It will pick one, confidently. It might even pick a third definition, inferred from a column named churn_flag whose population logic nobody remembers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DevlnCTx5kvoVMazZPxxJw.png" /><figcaption>4.1% vs 6.8%, contract rule vs usage rule, shared definition missing</figcaption></figure><p>This series builds a governed layer of meaning between the question and the query, using one SaaS churn example throughout. Part 1 writes one churn rule into a file a machine can read. Keep that file. The later parts only make sense if it exists.</p><h3>The five parts</h3><p>Each part is one idea plus a lab. You carry the same domain forward.</p><ol><li><strong>What an ontology is</strong> (this part). Paper model, OWL in rdflib and Protégé, SPARQL. You leave with saas_ontology.ttl.</li><li><strong>Knowledge graphs and GraphRAG.</strong> Why did the Semantic Web stall, then Neo4j, then GraphRAG over tickets and docs?</li><li><strong>Semantic layers.</strong> Governed MRR, churn, and active users in MetricFlow and Unity Catalog metric views.</li><li><strong>OntoBricks.</strong> Load the Part 1 file onto Unity Catalog tables and run a reasoner on Databricks.</li><li><strong>Genie Ontology.</strong> The platform learns a context layer. You plant two churn definitions and then evaluate whether they work.</li></ol><h3>The word</h3><p>&quot;Ontology&quot; comes from the Greek <em>&quot;ontos,&quot; meaning &quot;being,&quot; and &quot;logia,&quot; meaning &quot;study.&quot;</em> Aristotle never used the word. In the <em>categories,</em> he listed ten kinds of things that can be said of a subject, e.g., substance, quantity, quality, and relation. Later writers, starting with Porphyry, drew those kinds as trees that nest.</p><p>The word itself arrived around 1606, in Jacob Lorhard’s <em>Ogdoas scholastica</em>. Christian Wolff’s <em>Philosophia prima sive ontologia</em> (1730) made it a standard name for the study of being. For three centuries it stayed a philosopher’s word.</p><p>Then computer science took it. In 1993, <a href="https://tomgruber.org/writing/definition-of-ontology">Tom Gruber</a> needed a term for something knowledge engineers kept building. They wanted a formal description of what exists in a domain, written so software systems could share it. Gruber’s definition became the field’s default. An ontology is an explicit specification of a conceptualization.</p><p>Every word in that definition does work. <em>Conceptualization</em> is the abstract model in someone’s head, e.g., the sales team’s idea of what “churned” means. <em>&quot;Specification&quot;</em> means written down, not tribal knowledge. <em>&quot;Explicit&quot;</em> means the meaning is stated, not implied by a column name. The 4.1 versus 6.8 problem is, in Gruber’s terms, two conceptualizations and zero specifications.</p><p>People often mix the word with taxonomy. A taxonomy lists kinds and subkinds. An ontology also states relationships and rules, e.g. every subscription belongs to one account, and an account with no active subscription is churned. The rules have to live in the file. A query that restates them is still a query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*URMzb_niJ3GZSJw-tykiHQ.png" /><figcaption>Plan sorting machine: PaidPlan/FreePlan disjoint, Account–Subscription–Plan relationships, Churned consequence</figcaption></figure><h3>Prior art, briefly</h3><p>Between Aristotle and Gruber sits a stretch of AI history you should know, mostly because later parts of this series reuse it under new names.</p><p><strong>Frames</strong> (Marvin Minsky, mid-1970s) packaged knowledge into named objects with slots and default values. A frame for “restaurant visit” has slots for menu, table, and bill. A JSON schema with inheritance describes the same shape.</p><p><strong>Description logics</strong> (starting with Ron Brachman’s KL-ONE, late 1970s) made the semantics formal. A description logic is a decidable fragment of first-order logic built for this job. It defines classes, properties, and constraints so that a machine can prove consequences. If every enterprise subscription is a paid subscription and Acme’s subscription is enterprise, the machine derives that Acme pays. It does not look up the facts. It proves the fact from the definitions. Description logics became the mathematical foundation of OWL, which you will write into the file below, and which Part 4 will run on Databricks.</p><p>Then there is <strong>Cyc</strong>. Doug Lenat started it in 1984 with the goal of hand-coding common sense into one knowledge base. Forty years and tens of millions of rules later, Cyc had proved its premise and disproved its method. Machines need explicit knowledge to reason reliably. Humans should not type all of it in. Hold that thought until Part 5. There you will write some of the model by hand, and the platform will also learn a model from tables, queries, and dashboards. Genie Ontology is the learned layer. It is not the OWL file you are about to build.</p><h3>The stack that formalized it</h3><p>In 2001, Tim Berners-Lee published a vision of a web where data carried machine-readable meaning. The Semantic Web mostly did not happen, and Part 2 covers why. People still use the W3C standards built for that project, including inside modern data platforms. Those standards are also the simplest way to make Gruber’s definition concrete. There are four pieces.</p><p><strong>RDF</strong> is the data model. Everything is a triple: subject, predicate, object. A pile of triples is a graph, and that is the whole data model. Any fact, from any source, decomposes into the same shape, which is why triples outlived the larger project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gNGkQ9GAq625zXeRECGGuA.png" /><figcaption>Triple Press: CRM/billing/support documents stamped into subject-predicate-object triples that join into a graph</figcaption></figure><p><strong>RDFS</strong> adds vocabulary for structure. You get classes, subclasses, and property domains and ranges. This layer is the taxonomy.</p><p><strong>OWL</strong> adds the logic, backed by description logics. You can state that a property takes at most one value, that two classes cannot overlap, and that a class is defined by a condition. The OWL layer is where a taxonomy becomes an ontology.</p><p><strong>SPARQL</strong> is the query language. It matches patterns over triples. If you know SQL, the SELECT / WHERE shape will look familiar. You can write useful queries in it within about ten minutes.</p><p>That covers the concepts. Now open a terminal.</p><h3>Hands-on: model the domain before you touch a keyboard</h3><p>The running example for this whole series is a B2B SaaS business: accounts, subscriptions, plans, users, usage events, support tickets, and churn. In later parts the example becomes real tables in Unity Catalog, a knowledge graph in Neo4j, governed metrics, and a Genie space. Today it becomes an ontology, and the first step is paper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NFLVcAOmp6_rWxBJ3bUnAg.png" /><figcaption>Domain Modeling: Account entity stitched across billing, usage, and support tables; schema changes, meaning stays</figcaption></figure><p>Write down the <em>things</em> in the domain, not the tables you would eventually store them in.</p><ul><li><strong>Account:</strong> a customer company</li><li><strong>Subscription:</strong> a contract binding an account to a plan</li><li><strong>Plan:</strong> Free, Pro, Enterprise</li><li><strong>User:</strong> a person belonging to an account</li><li><strong>SupportTicket:</strong> filed by a user</li></ul><p>Now the relationships, as sentences:</p><ul><li>An Account <strong>has</strong> zero or more Subscriptions</li><li>A Subscription <strong>is on</strong> at most one Plan</li><li>A User <strong>belongs to</strong> at most one Account</li><li>A SupportTicket <strong>is filed by</strong> one User</li></ul><p>And two rules, the kind that have to live in the file rather than in a dashboard:</p><ul><li>Pro and Enterprise are kinds of <strong>PaidPlan</strong>, and PaidPlan is disjoint from FreePlan</li><li>An Account is <strong>Churned</strong> if it has no active subscription</li></ul><p>Every one of those sentences is a triple or a constraint. The paper exercise is the ontology. Everything after this is transcription.</p><h3>Hands-on: build it in rdflib</h3><p>You need Python and one package:</p><pre>pip install rdflib</pre><p>Define the vocabulary. Classes first:</p><pre>from rdflib import Graph, Namespace, Literal, RDF, RDFS, OWL, XSD<br><br>SAAS = Namespace(&quot;http://example.org/saas#&quot;)<br>g = Graph()<br>g.bind(&quot;saas&quot;, SAAS)<br>g.bind(&quot;owl&quot;, OWL)<br># Classes: the kinds of things that exist<br>for cls in [&quot;Account&quot;, &quot;Subscription&quot;, &quot;Plan&quot;, &quot;User&quot;, &quot;SupportTicket&quot;]:<br>    g.add((SAAS[cls], RDF.type, OWL.Class))<br># Taxonomy: paid plans are plans<br>g.add((SAAS.PaidPlan, RDF.type, OWL.Class))<br>g.add((SAAS.PaidPlan, RDFS.subClassOf, SAAS.Plan))<br>g.add((SAAS.FreePlan, RDF.type, OWL.Class))<br>g.add((SAAS.FreePlan, RDFS.subClassOf, SAAS.Plan))<br>print(f&quot;{len(g)} triples so far&quot;)</pre><p>Then the relationships. In OWL, relationships between things are object properties, and attributes with literal values are datatype properties:</p><pre># Object properties: thing-to-thing relationships<br>props = [<br>    (&quot;hasSubscription&quot;, SAAS.Account, SAAS.Subscription),<br>    (&quot;onPlan&quot;,          SAAS.Subscription, SAAS.Plan),<br>    (&quot;belongsTo&quot;,       SAAS.User, SAAS.Account),<br>    (&quot;filedBy&quot;,         SAAS.SupportTicket, SAAS.User),<br>]<br>for name, domain, range_ in props:<br>    p = SAAS[name]<br>    g.add((p, RDF.type, OWL.ObjectProperty))<br>    g.add((p, RDFS.domain, domain))<br>    g.add((p, RDFS.range, range_))<br>    # The at-most-one half of the paper list<br>    g.add((SAAS.onPlan, RDF.type, OWL.FunctionalProperty))<br>    g.add((SAAS.belongsTo, RDF.type, OWL.FunctionalProperty))<br>    # Datatype properties: attributes<br>    g.add((SAAS.mrr, RDF.type, OWL.DatatypeProperty))<br>    g.add((SAAS.mrr, RDFS.domain, SAAS.Subscription))<br>    g.add((SAAS.mrr, RDFS.range, XSD.decimal))<br>    g.add((SAAS.isActive, RDF.type, OWL.DatatypeProperty))<br>    g.add((SAAS.isActive, RDF.type, OWL.FunctionalProperty))<br>    g.add((SAAS.isActive, RDFS.domain, SAAS.Subscription))<br>    g.add((SAAS.isActive, RDFS.range, XSD.boolean))<br>    print(f&quot;{len(g)} triples so far&quot;)</pre><p>rdfs:domain and rdfs:range are not checks. If you write Acme filedBy Sub_001, a reasoner does not reject the triple. It implies that Acme is a SupportTicket. The check you probably want is SHACL, which arrives in Part 4. Domain and range still tell a query engine what the property is for owl:FunctionalProperty, onPlan, and belongsTo are at most one half of the paper list. A reasoner treats two different plans on one subscription as a contradiction. SPARQL will not enforce that by itself. isActive is functional too, and that one matters later; it tells the reasoner a subscription cannot be both active and inactive, which the churn rule will depend on.</p><p>Now instances. The plans, and one customer:</p><pre># The three plans. Free is a FreePlan. Pro and Enterprise are PaidPlans.<br>g.add((SAAS.Free, RDF.type, SAAS.FreePlan))<br>g.add((SAAS.Pro, RDF.type, SAAS.PaidPlan))<br>g.add((SAAS.Enterprise, RDF.type, SAAS.PaidPlan))<br># One account with a live subscription<br>g.add((SAAS.Acme, RDF.type, SAAS.Account))<br>g.add((SAAS.Sub_001, RDF.type, SAAS.Subscription))<br>g.add((SAAS.Acme, SAAS.hasSubscription, SAAS.Sub_001))<br>g.add((SAAS.Sub_001, SAAS.onPlan, SAAS.Enterprise))<br>g.add((SAAS.Sub_001, SAAS.mrr, Literal(4200.00, datatype=XSD.decimal)))<br>g.add((SAAS.Sub_001, SAAS.isActive, Literal(True)))<br># And one that churned: subscription exists, but lapsed<br>g.add((SAAS.Initech, RDF.type, SAAS.Account))<br>g.add((SAAS.Sub_002, RDF.type, SAAS.Subscription))<br>g.add((SAAS.Initech, SAAS.hasSubscription, SAAS.Sub_002))<br>g.add((SAAS.Sub_002, SAAS.onPlan, SAAS.Pro))<br>g.add((SAAS.Sub_002, SAAS.mrr, Literal(900.00, datatype=XSD.decimal)))<br>g.add((SAAS.Sub_002, SAAS.isActive, Literal(False)))<br>print(f&quot;{len(g)} triples so far&quot;)</pre><h3>Hands-on: put the churn rule in the file</h3><p>The paper said an account is <em>churned</em> if it has no active subscription. Until that sentence is an OWL axiom, it is still a comment. Paste this Turtle into the graph. Turtle is the human-readable RDF syntax. You will save the whole graph as Turtle at the end.</p><pre>g.parse(data=&quot;&quot;&quot;<br>@prefix saas: &lt;http://example.org/saas#&gt; .<br>@prefix owl:  &lt;http://www.w3.org/2002/07/owl#&gt; .<br>@prefix rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt; .<br>@prefix xsd:  &lt;http://www.w3.org/2001/XMLSchema#&gt; .saas:PaidPlan owl:disjointWith saas:FreePlan .<br>saas:ActiveSubscription a owl:Class ;<br>    owl:equivalentClass [<br>        a owl:Class ;<br>        owl:intersectionOf (<br>            saas:Subscription<br>            [<br>                a owl:Restriction ;<br>                owl:onProperty saas:isActive ;<br>                owl:hasValue true<br>            ]<br>        )<br>    ] .<br>saas:Churned a owl:Class ;<br>    rdfs:subClassOf saas:Account ;<br>    owl:equivalentClass [<br>        a owl:Class ;<br>        owl:intersectionOf (<br>            saas:Account<br>            [<br>                a owl:Class ;<br>                owl:complementOf [<br>                    a owl:Restriction ;<br>                    owl:onProperty saas:hasSubscription ;<br>                    owl:someValuesFrom saas:ActiveSubscription<br>                ]<br>            ]<br>        )<br>    ] .<br>&quot;&quot;&quot;, format=&quot;turtle&quot;)<br>print(f&quot;{len(g)} triples total&quot;)<br></pre><p>Read it once in order. ActiveSubscription is a subscription whose isActive value is true. Churned is an account that has no such subscription. PaidPlan and FreePlan cannot overlap. Those three claims are now in the graph. SPARQL, in the next section, will not apply them, because rdflib matches only what you asserted and does not run OWL. A reasoner will, and the churn rule is going to teach you something about how reasoners think. That surprise is waiting in the Protégé section.</p><h3>Hands-on: ask it questions</h3><p>SPARQL matches graph patterns. Total MRR across active subscriptions on paid plans:</p><pre>q = &quot;&quot;&quot;<br>PREFIX saas: &lt;http://example.org/saas#&gt;<br>PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;SELECT (SUM(?mrr) AS ?activePaidMrr)<br>WHERE {<br>  ?account saas:hasSubscription ?sub .<br>  ?sub saas:onPlan ?plan ;<br>       saas:mrr ?mrr ;<br>       saas:isActive true .<br>  ?plan a ?planType .<br>  ?planType rdfs:subClassOf* saas:PaidPlan .<br>}<br>&quot;&quot;&quot;<br>for row in g.query(q):<br>    print(&quot;Active paid MRR:&quot;, row.activePaidMrr)   # 4200.0</pre><p>Look at the last two lines of the WHERE clause. The query does not name Pro or Enterprise. It asks for any plan whose type sits anywhere under PaidPlan the taxonomy, using the * path operator to walk the subclass hierarchy. Add a premium plan next quarter, declare it a PaidPlan, and this query is already correct. SQL would push the same job onto a WHERE plan IN (...) list somebody forgets to update.</p><p>Now the question this article opened with, under definition one, is churn as a lapsed subscription. The query below restates the churn condition directly so you can check the two accounts today without a reasoner.</p><pre>q_churn = &quot;&quot;&quot;<br>PREFIX saas: &lt;http://example.org/saas#&gt;SELECT ?account<br>WHERE {<br>  ?account a saas:Account .<br>  FILTER NOT EXISTS {<br>    ?account saas:hasSubscription ?sub .<br>    ?sub saas:isActive true .<br>  }<br>}<br>&quot;&quot;&quot;<br>for row in g.query(q_churn):<br>    print(&quot;Churned (definition A, SPARQL):&quot;, row.account)   # http://example.org/saas#Initech<br>q_typed = &quot;&quot;&quot;<br>PREFIX saas: &lt;http://example.org/saas#&gt;<br>SELECT ?account WHERE { ?account a saas:Churned }<br>&quot;&quot;&quot;<br>print(&quot;Typed as Churned without a reasoner:&quot;, list(g.query(q_typed)))   # []</pre><p>The first query finds Initech. The second is empty. The churn rule is in the graph as OWL, but SPARQL will not apply it until a reasoner has run.</p><p>One thing to notice about the first query, because it comes back in a moment. FILTER NOT EXISTS treats absence as falsehood. No active subscription in the data means no active subscription, full stop. That assumption has a name, the closed-world assumption, and SPARQL makes it. OWL does not.</p><p>The competing usage-based definition needs usage events, which enter the dataset in Part 2. Part 3 will put both numbers into governed metrics. Part 5 will put both definitions in front of Genie Ontology. Today the disagreement is not resolved. One definition is in the file, in a form a later reasoner can use, and that file is what every later part of the series builds on.</p><p>Save your work:</p><pre>g.serialize(destination=&quot;saas_ontology.ttl&quot;, format=&quot;turtle&quot;)<br>ttl = open(&quot;saas_ontology.ttl&quot;).read()<br>assert &quot;owl:equivalentClass&quot; in ttl or &quot;equivalentClass&quot; in ttl<br>assert &quot;disjointWith&quot; in ttl<br>print(ttl[:1500])</pre><p>Open the .ttl file. You should see your paper sentences, including owl:equivalentClass for Churned and owl:disjointWith two planned classes. Keep this file. In Part 4 you will load it into OntoBricks and map it onto Unity Catalog tables. If the file has no axioms, the reasoner in that part has nothing to do.</p><h3>Hands-on: run a reasoner in Protégé</h3><p>Download <a href="https://protege.stanford.edu/">Protégé</a>, the free Stanford ontology editor. Open saas_ontology.ttl, then start the built-in reasoner (HermiT or Pellet, under Reasoner).</p><p>Run three checks.</p><p><strong>First, classify Enterprise.</strong> You typed it as PaidPlan. The reasoner should also place it under Plan because PaidPlan is a subclass of Plan. This is the easy kind of inference: walking up a hierarchy you declared.</p><p><strong>Second, look up Initech.</strong> You asserted it as an account with a lapsed subscription. The SPARQL query found it. So after the reasoner runs, Initech should appear under Churned.</p><p>It does not. This is not a bug, and it is the most useful thing in this article.</p><p>OWL makes the open-world assumption: what is not stated is unknown, not false. To classify Initech as churned, the reasoner has to <em>prove</em> Initech has no active subscription. It cannot. Nothing in the file says Sub_002 is Initech’s only subscription. For all the reasoner knows, there is a Sub_003 out there, active, that you never mentioned. So it stays silent. Compare the SPARQL query, which found Initech immediately because it FILTER NOT EXISTS assumes the data it can see is all the data there is. Same rule, same account, opposite answers, and the difference is the world assumption. When you put ontologies over a data warehouse, as Part 4 does, managing this gap is most of the work.</p><p>To let the reasoner close the world for Initech, tell it the subscription list is complete. This is called a closure axiom:</p><pre>g.parse(data=&quot;&quot;&quot;<br>@prefix saas: &lt;http://example.org/saas#&gt; .<br>@prefix owl:  &lt;http://www.w3.org/2002/07/owl#&gt; .<br># Closure: Sub_002 is Initech&#39;s only subscription<br>saas:Initech a [<br>    a owl:Restriction ;<br>    owl:onProperty saas:hasSubscription ;<br>    owl:allValuesFrom [ a owl:Class ; owl:oneOf ( saas:Sub_002 ) ]<br>] .<br>&quot;&quot;&quot;, format=&quot;turtle&quot;)<br>g.serialize(destination=&quot;saas_ontology.ttl&quot;, format=&quot;turtle&quot;)</pre><p>Reload in Protégé and run the reasoner again. Now the proof goes through: every subscription Initech has is Sub_002, Sub_002 has isActive false, isActive is functional, so it cannot also be true; therefore, Sub_002 is not an ActiveSubscription, therefore Initech has no active subscription, therefore Initech is churned. Initech appears under &quot;Churned,&quot; inferred, not asserted. That chain is what &quot;the machine proves the fact from the definitions&quot; looks like in practice.</p><p><strong>Third, make a contradiction on purpose.</strong> Assert that Free is also a PaidPlan, then re-run the reasoner. PaidPlan and FreePlan are disjoint, so Protégé should flag the ontology as inconsistent. A reasoner catches that contradiction; a document describing the same rule cannot.</p><p>If Initech does not show up under &quot;Churned,&quot; the closure axiom did not load. Open the turtle, confirm saas:Churned, owl:equivalentClass, and the owl:allValuesFrom closure is present, and reload the file.</p><h3>Where this leaves you</h3><p>You now hold three things the rest of the series uses. An ontology is an explicit, machine-readable specification of what exists and what the rules are. One churn definition now lives in saas_ontology.ttl, not only in a query. And you have seen open world versus closed world produce different answers to the same question on the same data, which is the single sharpest edge you will hit when Part 4 puts this file over real tables.</p><p>You also hold a fair objection. The example was a toy. A handful of classes, two accounts, hand-typed triples. The Semantic Web community built artifacts like it for a decade, and the global machine-readable web never arrived. The reasons it never arrived are specific, and they are mostly economic rather than technical. Triples, IRIs, and SPARQL survived.</p><p>Part 2 tells that story and adds your first real graph database plus a retrieval technique that lets an LLM reason across documents instead of matching isolated chunks. Bring the .ttl file.</p><p><em>Part 2: Knowledge graphs and GraphRAG. The dataset, notebooks, and this article’s code live in the </em><a href="https://github.com/Praneeth16/ontology-series"><em>series repo</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75fc2606c7e8" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/what-an-ontology-actually-is-75fc2606c7e8">What an Ontology Actually Is</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Journey of an Agent: From Demo to Production]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://pub.towardsai.net/journey-of-an-agent-from-demo-to-production-9606ea8df8eb?source=rss-7df3fbeae6c7------2"><img src="https://cdn-images-1.medium.com/max/1672/1*1X23FqdQU1UMyihgiYtouw.png" width="1672"></a></p><p class="medium-feed-snippet">The agent passed every demo. It was also confidently making things up.</p><p class="medium-feed-link"><a href="https://pub.towardsai.net/journey-of-an-agent-from-demo-to-production-9606ea8df8eb?source=rss-7df3fbeae6c7------2">Continue reading on Towards AI »</a></p></div>]]></description>
            <link>https://pub.towardsai.net/journey-of-an-agent-from-demo-to-production-9606ea8df8eb?source=rss-7df3fbeae6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/9606ea8df8eb</guid>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[langgraph]]></category>
            <category><![CDATA[llm-evaluation]]></category>
            <dc:creator><![CDATA[Praneeth Paikray]]></dc:creator>
            <pubDate>Mon, 08 Jun 2026 19:49:23 GMT</pubDate>
            <atom:updated>2026-06-10T05:19:29.673Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[LangGraph vs CrewAI vs DSPy]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://pub.towardsai.net/langgraph-vs-crewai-vs-dspy-6c7d208600b5?source=rss-7df3fbeae6c7------2"><img src="https://cdn-images-1.medium.com/max/1448/1*hO4lFbi1bL29GWK4wJ3thw.png" width="1448"></a></p><p class="medium-feed-snippet">Three frameworks, three different views of an LM application: CrewAI treats it as a team, LangGraph as a state machine, and DSPy as a&#x2026;</p><p class="medium-feed-link"><a href="https://pub.towardsai.net/langgraph-vs-crewai-vs-dspy-6c7d208600b5?source=rss-7df3fbeae6c7------2">Continue reading on Towards AI »</a></p></div>]]></description>
            <link>https://pub.towardsai.net/langgraph-vs-crewai-vs-dspy-6c7d208600b5?source=rss-7df3fbeae6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c7d208600b5</guid>
            <category><![CDATA[crew-ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-agent-frameworks]]></category>
            <category><![CDATA[dspy]]></category>
            <category><![CDATA[langgraph]]></category>
            <dc:creator><![CDATA[Praneeth Paikray]]></dc:creator>
            <pubDate>Thu, 30 Apr 2026 14:31:01 GMT</pubDate>
            <atom:updated>2026-04-30T14:31:01.463Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[What Gemma 4 Reveals About Where Open Model Design is Heading: Part 1]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://pub.towardsai.net/what-gemma-4-reveals-about-where-open-model-design-is-heading-part-1-eb1db8fe3008?source=rss-7df3fbeae6c7------2"><img src="https://cdn-images-1.medium.com/max/1024/1*-dK-raRgpm03wWxpm3waiw.png" width="1024"></a></p><p class="medium-feed-snippet">A visual, systems-level breakdown of the architecture choices in Google DeepMind&#x2019;s newest open models, and what they tell us about where&#x2026;</p><p class="medium-feed-link"><a href="https://pub.towardsai.net/what-gemma-4-reveals-about-where-open-model-design-is-heading-part-1-eb1db8fe3008?source=rss-7df3fbeae6c7------2">Continue reading on Towards AI »</a></p></div>]]></description>
            <link>https://pub.towardsai.net/what-gemma-4-reveals-about-where-open-model-design-is-heading-part-1-eb1db8fe3008?source=rss-7df3fbeae6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb1db8fe3008</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[gemma-4]]></category>
            <dc:creator><![CDATA[Praneeth Paikray]]></dc:creator>
            <pubDate>Tue, 21 Apr 2026 19:01:01 GMT</pubDate>
            <atom:updated>2026-04-21T19:01:01.402Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Build a Full-Stack Databricks App in Five Prompts]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://pub.towardsai.net/build-a-full-stack-databricks-app-in-five-prompts-f11d6813bc21?source=rss-7df3fbeae6c7------2"><img src="https://cdn-images-1.medium.com/max/1024/1*u1DUhH7ov4aRQxBbkfyY_g.png" width="1024"></a></p><p class="medium-feed-snippet">React + FastAPI + Lakebase + Genie API, scaffolded with ai-dev-kit and deployed to Databricks Apps.</p><p class="medium-feed-link"><a href="https://pub.towardsai.net/build-a-full-stack-databricks-app-in-five-prompts-f11d6813bc21?source=rss-7df3fbeae6c7------2">Continue reading on Towards AI »</a></p></div>]]></description>
            <link>https://pub.towardsai.net/build-a-full-stack-databricks-app-in-five-prompts-f11d6813bc21?source=rss-7df3fbeae6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/f11d6813bc21</guid>
            <category><![CDATA[full-stack-development]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[lakebase]]></category>
            <category><![CDATA[ai-agents-in-action]]></category>
            <dc:creator><![CDATA[Praneeth Paikray]]></dc:creator>
            <pubDate>Sun, 29 Mar 2026 04:46:11 GMT</pubDate>
            <atom:updated>2026-04-01T17:55:19.395Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Building LLM Agents From Scratch: Crafting a Dynamic NLP Data Generator ]]></title>
            <link>https://medium.com/@paikraypraneeth/building-llm-agents-from-scratch-crafting-a-dynamic-nlp-data-generator-383abcb3051b?source=rss-7df3fbeae6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/383abcb3051b</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[openai-api]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[synthetic-data]]></category>
            <category><![CDATA[llm-agent]]></category>
            <dc:creator><![CDATA[Praneeth Paikray]]></dc:creator>
            <pubDate>Tue, 21 Jan 2025 21:27:38 GMT</pubDate>
            <atom:updated>2025-01-21T21:27:38.342Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever wished you had more data for your NLP projects? Imagine having an AI helper to learn from your existing data and create more like it! Today, we will build precisely that — a basic but powerful AI agent that can generate synthetic data. And the best part? We’ll create an agent from scratch using Python and the OpenAI API!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jkues6h8Osdya58tOIUdKw.jpeg" /></figure><h3>What We’re Building</h3><p>Think of our AI agent as a clever student who:</p><ol><li>First, learn by looking at your data (Learning Phase)</li><li>Then, create new, similar data (Creation Phase)</li><li>Finally, it checks if the new data is good enough (Validation Phase)</li></ol><p>Let’s break this down into simple steps and follow the chart below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UXCcvgMy3MbEeVkd77mi1g.png" /><figcaption>Synthetic data generation LLM pipeline flow</figcaption></figure><h3>1. The Learning Phase: Building a Smart Data Analyzer</h3><p>Think of training an LLM agent, like teaching a friend to write viral content. As your friend would study successful viral posts to identify winning patterns, compelling tones, and key elements, our AI agent analyzes text to understand its characteristics.</p><p><em>Setup your OpeAI APIs to run the below code.</em></p><pre>from collections import Counter<br>import json<br>import os<br>import random<br>from typing import Dict, List, Optional<br><br>from openai import OpenAI<br>import pandas as pd<br>from sklearn.feature_extraction.text import TfidfVectorizer<br><br>api_key = &quot;&quot; # openai api key<br><br>def analyze_text_patterns_with_llm(client: OpenAI, texts: List[str], label: str) -&gt; Dict:<br>    &quot;&quot;&quot;<br>    Like a student taking detailed notes, this function uses an AI to analyze<br>    writing patterns in our sample texts<br>    &quot;&quot;&quot;<br>    analysis_prompt = f&quot;&quot;&quot;<br>    Analyze the following {len(texts)} text samples for class &#39;{label}&#39; and identify their common patterns:<br><br>    Texts:<br>    {json.dumps(texts, indent=2)}<br><br>    Analyze and return a JSON object with these components:<br>    1. writing_style: List of identified writing styles (e.g., formal, casual, technical, emotional)<br>    2. semantic_patterns: List of semantic patterns (e.g., sentiment trends, topic focus, common themes)<br>    3. structural_patterns: List of sentence structure patterns (e.g., length, complexity)<br>    4. context_rules: List of contextual patterns and rules (e.g., typical scenarios, common subjects)<br><br>    Format your response as a JSON object with these exact keys.<br>    Be specific and detailed in your analysis.<br>    &quot;&quot;&quot;<br>    <br>    response = client.chat.completions.create(<br>        model=&quot;gpt-4o&quot;,<br>        messages=[{<br>            &quot;role&quot;: &quot;system&quot;,<br>            &quot;content&quot;: &quot;You are an expert linguistic pattern analyzer that identifies detailed writing patterns and styles.&quot;<br>        },<br>        {<br>            &quot;role&quot;: &quot;user&quot;,<br>            &quot;content&quot;: analysis_prompt<br>        }],<br>        response_format={ &quot;type&quot;: &quot;json_object&quot; }<br>    )<br>    <br>    return json.loads(response.choices[0].message.content)<br><br>def analyze_class_patterns(client: OpenAI, texts: List[str], labels: List[str]) -&gt; Dict:<br>    &quot;&quot;&quot;<br>    Like organizing notes by topic, this function analyzes patterns for each type of text<br>    &quot;&quot;&quot;<br>    # Figure out how many of each type we have<br>    class_distribution = Counter(labels)<br>    <br>    # Take a small sample from each type (10% of each class)<br>    samples_per_class = {}<br>    for label in set(labels):<br>        class_texts = [text for text, l in zip(texts, labels) if l == label]<br>        sample_size = max(1, int(len(class_texts) * 0.1))<br>        samples_per_class[label] = random.sample(class_texts, sample_size)<br>    <br>    # Find important words for each type using TF-IDF<br>    vectorizer = TfidfVectorizer(max_features=50)<br>    <br>    class_keywords = {}<br>    label_patterns = {}<br>    <br>    for label, class_texts in samples_per_class.items():<br>        if class_texts:<br>            # Get important words<br>            tfidf_matrix = vectorizer.fit_transform(class_texts)<br>            feature_names = vectorizer.get_feature_names_out()<br>            class_keywords[label] = list(feature_names)<br>            <br>            # Get AI analysis for this type<br>            llm_patterns = analyze_text_patterns_with_llm(client, class_texts, label)<br>            <br>            # Combine everything we learned<br>            label_patterns[label] = {<br>                &#39;writing_style&#39;: llm_patterns[&#39;writing_style&#39;],<br>                &#39;key_phrases&#39;: class_keywords[label],<br>                &#39;semantic_patterns&#39;: llm_patterns[&#39;semantic_patterns&#39;],<br>                &#39;structural_patterns&#39;: llm_patterns[&#39;structural_patterns&#39;],<br>                &#39;context_rules&#39;: llm_patterns[&#39;context_rules&#39;]<br>            }<br>    <br>    return label_patterns</pre><h3>2. The Creation Phase: Implementing the Generation Engine</h3><p>Now that our LLM agent understands the patterns, it’s time to create new data! This is like asking our friend to write viral posts based on their learning.</p><pre>def generate_synthetic_samples(client: OpenAI, patterns: Dict, target_label: str, num_samples: int) -&gt; List[str]:<br>    &quot;&quot;&quot;<br>    Uses AI to generate new text samples based on what we learned<br>    &quot;&quot;&quot;<br>    prompt = f&quot;&quot;&quot;<br>    You are a synthetic text generation expert. Generate {num_samples} new text samples <br>    that match this class&#39;s patterns:<br><br>    1. Writing Style:<br>    {json.dumps(patterns[&#39;writing_style&#39;], indent=2)}<br><br>    2. Key Phrases:<br>    {json.dumps(patterns[&#39;key_phrases&#39;], indent=2)}<br><br>    3. Semantic Patterns:<br>    {json.dumps(patterns[&#39;semantic_patterns&#39;], indent=2)}<br><br>    4. Structural Patterns:<br>    {json.dumps(patterns[&#39;structural_patterns&#39;], indent=2)}<br><br>    5. Context Rules:<br>    {json.dumps(patterns[&#39;context_rules&#39;], indent=2)}<br><br>    Requirements:<br>    - Generate completely unique and original texts<br>    - Maintain the identified patterns and style<br>    - Ensure natural language flow<br>    - Create diverse examples while staying within the class patterns<br>    - Avoid exact copying of training examples<br><br>    Return a JSON array with the structure:<br>        &quot;samples&quot;: [<br>            &quot;sample text 1&quot;,<br>            &quot;sample text 2&quot;,<br>            ...<br>        ]<br>    &quot;&quot;&quot;<br>    <br>    response = client.chat.completions.create(<br>        model=&quot;gpt-4o-mini&quot;,<br>        messages=[{<br>            &quot;role&quot;: &quot;system&quot;,<br>            &quot;content&quot;: &quot;You are a synthetic text generation expert that creates realistic but unique samples.&quot;<br>        },<br>        {<br>            &quot;role&quot;: &quot;user&quot;,<br>            &quot;content&quot;: prompt<br>        }],<br>        response_format={ &quot;type&quot;: &quot;json_object&quot; }<br>    )<br>    <br>    result = json.loads(response.choices[0].message.content)<br>    return result.get(&quot;samples&quot;, [])</pre><h3>3. The Validation Phase: Ensuring Data Integrity and Quality</h3><p>Finally, we need to check if our generated data is good enough — just like a guide would review our friend’s viral posts!</p><pre>def validate_synthetic_sample(client: OpenAI, text: str, target_label: str, patterns: Dict) -&gt; tuple[bool, list, list]:<br>    &quot;&quot;&quot;<br>    Checks if our generated text matches the patterns we learned<br>    &quot;&quot;&quot;<br>    prompt = f&quot;&quot;&quot;<br>    Validate if this synthetic text matches the patterns for class &#39;{target_label}&#39;:<br>    <br>    Text to validate:<br>    {text}<br>    <br>    Expected Patterns:<br>    {json.dumps(patterns, indent=2)}<br>    <br>    Check for:<br>    1. Does it follow the identified writing style?<br>    2. Does it use appropriate key phrases?<br>    3. Does it match the semantic patterns?<br>    4. Does it follow structural patterns?<br>    5. Does it adhere to context rules?<br>    <br>    Return JSON with:<br>        &quot;is_valid&quot;: true/false,<br>        &quot;issues&quot;: [&quot;issue1&quot;, &quot;issue2&quot;, ...],<br>        &quot;suggestions&quot;: [&quot;suggestion1&quot;, &quot;suggestion2&quot;, ...]<br>    &quot;&quot;&quot;<br>    <br>    response = client.chat.completions.create(<br>        model=&quot;gpt-4o&quot;,<br>        messages=[{<br>            &quot;role&quot;: &quot;user&quot;,<br>            &quot;content&quot;: prompt<br>        }],<br>        response_format={ &quot;type&quot;: &quot;json_object&quot; }<br>    )<br>    <br>    result = json.loads(response.choices[0].message.content)<br>    return (<br>        result.get(&quot;is_valid&quot;, False),<br>        result.get(&quot;issues&quot;, []),<br>        result.get(&quot;suggestions&quot;, [])<br>    )<br><br>def augment_dataset(client: OpenAI, texts: List[str], labels: List[str], <br>                   target_label: str, num_synthetic: int) -&gt; tuple:<br>    &quot;&quot;&quot;<br>    Creates a balanced dataset by adding synthetic samples<br>    &quot;&quot;&quot;<br>    # First analyze patterns in the dataset<br>    patterns = analyze_class_patterns(client, texts, labels)<br>    <br>    # Generate synthetic samples<br>    synthetic_samples = []<br>    valid_count = 0<br>    <br>    while valid_count &lt; num_synthetic:<br>        # Generate in batches of 10<br>        batch = generate_synthetic_samples(<br>            client,<br>            patterns[target_label], <br>            target_label, <br>            min(10, num_synthetic - valid_count)<br>        )<br>        <br>        for sample in batch:<br>            is_valid, issues, suggestions = validate_synthetic_sample(<br>                client,<br>                sample, <br>                target_label,<br>                patterns[target_label]<br>            )<br>            if is_valid:<br>                synthetic_samples.append(sample)<br>                valid_count += 1<br>                if valid_count &gt;= num_synthetic:<br>                    break<br>    <br>    # Combine with original dataset<br>    augmented_texts = texts + synthetic_samples<br>    augmented_labels = labels + [target_label] * len(synthetic_samples)<br>    <br>    return augmented_texts, augmented_labels</pre><h3>Putting it all together</h3><p>Let’s integrate these components and test our system with a smaller dataset. While we’re using a sample size for this demonstration, it will effectively showcase the pipeline’s capabilities while being mindful of API usage. This approach allows us to validate our methodology before scaling to larger datasets:</p><pre># Setup OpenAI client<br>client = OpenAI(api_key=api_key)<br><br># Sample movie reviews<br>sample_reviews = [<br>    &quot;This movie was absolutely fantastic! Great acting and wonderful plot.&quot;,<br>    &quot;Decent film but the pacing was a bit slow. Good performance by the lead actor.&quot;,<br>    &quot;Not worth the ticket price. Poor storyline and mediocre acting.&quot;,<br>    &quot;A masterpiece of modern cinema. Every scene was perfectly crafted.&quot;<br>]<br><br># Sample labels<br>sample_labels = [&quot;positive&quot;, &quot;neutral&quot;, &quot;negative&quot;, &quot;positive&quot;]<br><br># Let&#39;s say we want to generate more neutral reviews to balance our dataset<br>print(&quot;📚 Analyzing original data...&quot;)<br><br># Find out how many samples we need<br>label_counts = Counter(sample_labels)<br>desired_samples = max(label_counts.values())<br>target_label = &quot;neutral&quot;<br>synthetic_needed = desired_samples - label_counts[target_label]<br><br>print(f&quot;🤖 Generating {synthetic_needed} new {target_label} reviews...&quot;)<br><br># Generate balanced dataset<br>augmented_texts, augmented_labels = augment_dataset(<br>    client=client,<br>    texts=sample_reviews,<br>    labels=sample_labels,<br>    target_label=target_label,<br>    num_synthetic=synthetic_needed<br>)<br><br>print(&quot;\nOriginal Distribution:&quot;, dict(Counter(sample_labels)))<br>print(&quot;New Distribution:&quot;, dict(Counter(augmented_labels)))   <br>print(f&quot;Augmented text:\n{list(set(augmented_texts) - set(sample_reviews))}&quot;)</pre><p><strong><em>Output</em></strong></p><pre>Augmented text:<br>[<br>    &quot;The lead actor&#39;s performance was solid, but the film had some slow pacing that dragged it down a bit.&quot;<br>]</pre><h3>What’s next?</h3><p>We’ve just built our own LLM-powered synthetic data generation agent. This is just the beginning — we can enhance it by:</p><ol><li>Running the complete pipeline on a real-world dataset</li><li>Adding more analysis metrics (topic detection)</li><li>Implementing different validation techniques</li><li>Replace the sample examples with a real world dataset</li><li>Implementing a production Synthetic Data generation agent by leveraging <a href="https://argilla.io/"><strong><em>Argilla</em></strong></a></li><li>Going beyond OpenAI models and experimenting with Deepsek-v3</li></ol><p>The possibilities are endless! Attaching the <a href="https://github.com/Praneeth16/articles/blob/main/agents-from-scratch/synthetic_agent_from_scratch.ipynb"><strong><em>jupyter notebook</em></strong></a> to play around.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=383abcb3051b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>