<?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 John Joy on Medium]]></title>
        <description><![CDATA[Stories by John Joy on Medium]]></description>
        <link>https://medium.com/@john.joy77777?source=rss-ad2caaeb87e3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MiqFrNosQd8dnZw1</url>
            <title>Stories by John Joy on Medium</title>
            <link>https://medium.com/@john.joy77777?source=rss-ad2caaeb87e3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:24:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@john.joy77777/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[Visual Model Fusion: A New Way to Harness AI on Your Choice of Models — Local or Cloud Inference]]></title>
            <link>https://medium.com/@john.joy77777/visual-model-fusion-a-new-way-to-harness-ai-on-your-choice-of-models-local-or-cloud-inference-f5daad5b292e?source=rss-ad2caaeb87e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5daad5b292e</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[John Joy]]></dc:creator>
            <pubDate>Wed, 17 Jun 2026 20:25:17 GMT</pubDate>
            <atom:updated>2026-06-17T21:50:28.194Z</atom:updated>
            <content:encoded><![CDATA[<p><em>*On mixing models, testing their combinations, and why the canvas is a better control plane than code.*</em></p><p>The dominant mental model for AI development right now is: pick a model, write a prompt, iterate. Single model, single provider, single context window.</p><p>That mental model is already obsolete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JTT5xD4kVAEZlIa4" /><figcaption>Photo by <a href="https://unsplash.com/@di360muller?utm_source=medium&amp;utm_medium=referral">DiEGO MüLLER</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The systems that produce the best outputs today are not single-model calls. They are pipelines where different models play different roles — one for breadth, one for precision, one for critique. They use tools that reach into real files and real systems. They run feedback loops where one model’s output becomes another’s input.</p><p>Building those systems today means writing a lot of glue code, losing the design intent in the process, and having no way to test whether this particular combination of models outperforms a different combination without rewriting everything.</p><p>There’s a better control plane for this. It’s a canvas.- Ik it exists as managed services and is not model agnostic, is being tied to the provider, and you lose your intent. This stands as a guide for your next coding/vibe coding inspiration. Bliss is a product I developed out of curiosity that tackles this problem.</p><p><strong>The Problem With Single-Model Thinking</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uX97b-w_b6Ph7un8" /><figcaption>Photo by <a href="https://unsplash.com/@liam_1?utm_source=medium&amp;utm_medium=referral">Liam Briese</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When you prompt a single model to research, reason, critique, and summarise in one shot, you’re asking it to wear every hat at once. The model that’s best at breadth may not be best at precision. The model that’s cheapest for summarisation may not be worth the cost for deep reasoning. Mixing them intentionally — by role, by capability, by cost — is how you get better outcomes than any single model can provide.</p><p>We call this <strong>fusion</strong>: deliberately composing heterogeneous models in a single pipeline, where each model is selected for the role it plays best.</p><p>The problem is that fusion is hard to build and even harder to test. You can’t easily answer “does Claude for research + GPT-4 for critique + Haiku for summarisation outperform all-Claude?” without building both variants, running them against the same inputs, and comparing outputs. That’s a lot of friction for what should be a configurable parameter.</p><p>The canvas removes that friction.</p><p><strong>Designing Fusion on a Canvas</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bxtVbRJ-In9jS-ny" /><figcaption>Photo by <a href="https://unsplash.com/@albertstoynov?utm_source=medium&amp;utm_medium=referral">Albert Stoynov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Each node on the canvas has its own model configuration. The Architect node can run `claude-sonnet-4–6`. The Critic node can run `gpt-4o`. The Summariser at the end can run `claude-haiku-4–5`. You see it laid out visually — which model sits where in the pipeline, what role it plays, what system prompt shapes its behaviour.</p><p>Swapping a model in a node takes one field change in the inspector. Running the same session against a different configuration takes creating a second session with the modified canvas. The comparison is immediate and the provenance is clear — the session is permanently linked to the canvas that created it, so you always know which configuration produced which output.</p><p>This is <strong>fusion model testing</strong>: not A/B testing a single model, but testing the composition itself. Does putting a more expensive reasoning model at the start and a cheap summariser at the end match the quality of an expensive model end-to-end, at lower cost? You can find out without writing any new code.</p><p><strong>Personal Compute as the Execution Environment</strong></p><p>Most AI tooling treats your local machine as a terminal to a cloud service. The agent runs remotely, in a sandbox, with no access to your files, your codebase, your data.</p><p>Bliss runs where you run it. When you configure a workspace path, every tool in your workflow has access to that directory — real files, real reads, real writes. A tool node that lists your project files, parses a config, runs a test suite, checks git status — these are all expressible as tool code that executes in your actual workspace.</p><p>This matters for a specific class of use case: <strong>agents that assist with work you’re doing on your machine right now</strong>. Not summarising documents you’ve uploaded to a cloud service. Not answering questions about a knowledge base someone else indexed. Your local codebase, your local files, your local tools — the agent operates in the same environment you do.</p><p>The workspace path is set once at the application level and flows automatically to every tool node you create. Your tools know where your work lives. The models you’ve wired into the pipeline can reason about what those tools return. The gap between “AI that knows things” and “AI that operates in your environment” closes.</p><p><strong>Visually Harnessing Models</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UQTqRLlPRN7iya0a" /><figcaption>Photo by <a href="https://unsplash.com/@alexlitvin?utm_source=medium&amp;utm_medium=referral">Alex Litvin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The canvas is not a prettier way to write code. It’s a different abstraction layer — one that makes certain things visible that code deliberately hides.</p><p>When you open a codebase that uses multiple models, you have to read the code to understand which model is called when, what it’s given, and what it’s allowed to do. The design intent is buried in implementation detail.</p><p>On the canvas:</p><p>- <strong>Pipeline edges</strong> show execution order — the solid lines connecting nodes in sequence</p><p>- <strong>Tool-link edges</strong> show capability — the dashed yellow lines that appear when you configure an agent’s tool access, immediately visible on the canvas</p><p>- <strong>Node colour</strong> shows role — research nodes in emerald, critic nodes in orange, tool nodes in yellow</p><p>- <strong>Inspector</strong> shows configuration without noise — just the fields that matter for that node type</p><p>When a new team member looks at the canvas, they see the system. Not a deployment diagram that diverged from the code months ago — the actual running configuration, because the canvas <em>*is*</em> the running configuration.</p><p>Changing the system means changing the canvas. The visual representation and the executable specification are the same document.</p><p><strong>The Testing Surface This Opens</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qLyj1kd4HvvZJTl6" /><figcaption>Photo by <a href="https://unsplash.com/@alexeydemidov?utm_source=medium&amp;utm_medium=referral">Alexey Demidov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Once the pipeline is a visual, configurable specification, testing becomes a design-time activity rather than an afterthought.</p><p><strong>Role isolation</strong> Each node in the pipeline is a testable unit. You can replay a session up to any node, freeze the state, and run only the downstream segment against the modified configuration. Change the Critic’s system prompt and re-run only the critique step — you don’t need to re-run the research.</p><p><strong>Combination coverage. </strong>Because model configuration is per-node, you can systematically cover the meaningful combinations. Cheap model at every node. Expensive model only at the reasoning-heavy step. Different provider at the critique step. The canvas makes the configuration space navigable instead of implicit.</p><p><strong>Fusion regression.</strong> When you change one node, the dashed tool-link edges tell you immediately which agents are affected by any tool changes. The pipeline order tells you which downstream nodes will see different inputs. The impact surface of a change is visible before you run anything.</p><p><strong>Local ground truth.</strong> When your tools operate in a real workspace, your test cases can too. An agent that checks code quality against your actual files is testable against real files — not synthetic fixtures that don’t represent what the agent encounters in practice.</p><p><strong>What Becomes Possible</strong></p><p>The combination of fusion model design, local workspace access, and visual specification creates something that hasn’t existed before: <strong>a personal AI workbench</strong>.</p><p>Not a cloud platform you subscribe to. Not a framework you install and configure in code. A running environment on your own machine where you compose heterogeneous models into pipelines, connect them to your local tools and files, test their combinations against real inputs, and iterate on the design in the same interface where you run it.</p><p>The canvas is the control plane. The workspace is the execution environment. The sessions are the experiment log.</p><p>As the platform matures, the canvas gains observability — latency per node, token cost per session, tool call frequency, evaluation results rendered as annotations on the nodes that produced them. The visual model of the system becomes a live dashboard of how the system is behaving.</p><p>The direction is toward a tighter loop: design the pipeline visually, run it against your real environment, observe its behaviour in the same interface, and iterate. No context switching, no separate dashboards, no re-reading code to understand what you built.</p><p>The model you can see is the model you can improve.</p><p>Original work with AI-assisted writing</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5daad5b292e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Not to Generate a Knowledge Graph with an LLM]]></title>
            <link>https://medium.com/@john.joy77777/how-not-to-generate-a-knowledge-graph-with-an-llm-6968c293a8e9?source=rss-ad2caaeb87e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6968c293a8e9</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[kg-construction]]></category>
            <category><![CDATA[knowledge-graph]]></category>
            <dc:creator><![CDATA[John Joy]]></dc:creator>
            <pubDate>Mon, 08 Jun 2026 19:00:56 GMT</pubDate>
            <atom:updated>2026-06-08T19:00:56.370Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w8tpDcisB9kxaH7t" /><figcaption>Photo by <a href="https://unsplash.com/@guerrillabuzz?utm_source=medium&amp;utm_medium=referral">GuerrillaBuzz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>There is a moment, somewhere around the third demo, when generating a knowledge graph with a language model stops feeling like magic. The model still produces entities. It still produces relations. The output still looks structured. But you start noticing that when you ask the graph to <em>do</em> something — answer a question, support a lookup, drive a retrieval — it doesn’t quite hold up.</p><p>I’m not claiming here that LLMs can&#39;t handle complex tasks, and very clearly they can. They are plausibly good that failures are hard to detect from everything generated. In terms of the knowledge graph construction, this will work as a guide to check for failures in your pipeline.</p><h3>Don’t let the model invent the ontology on the go</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fpdI1bhT00jS_NAf" /><figcaption>Photo by <a href="https://unsplash.com/@a_lo?utm_source=medium&amp;utm_medium=referral">Angela Loria</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The cheapest way to ruin a knowledge graph is to ask, in the prompt, for “the entities and relations.” Without a fixed schema, the LLM picks its own types and its own relation names — and it picks differently from one document to the next. The same concept gets tagged three different ways across a corpus. New relation labels appear mid-run. By the time you’ve extracted from a thousand abstracts, you don’t have a graph; you have a thousand small ones that happen to share a file.</p><p>Hand the model a tight, explicit ontology: a small list of entity types, a fixed relation set, one-line definitions for each. Constrain the output schema. Yes, it makes the model less “creative.” That’s the point. A graph you can query is a graph the model wasn’t allowed to free-style. Everything else in this post assumes you’ve done this; if you haven’t, none of the metrics below means anything because there’s no consistent vocabulary to score against.</p><h3>Don’t grade the graph by how big it is</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*shoTOxnS3FH1KepT" /><figcaption>Photo by <a href="https://unsplash.com/@kommumikation?utm_source=medium&amp;utm_medium=referral">Mika Baumeister</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The first instinct, after running zero-shot extraction over a corpus, is to count edges. The number is reassuring. It is often <em>larger</em> than a hand-curated reference would give you for the same text. People mistake that for thoroughness.</p><p>It isn’t. A graph can contain more relationships than the gold standard and still answer fewer questions. Surplus extractions tend to be noisy, mistyped, or weakly grounded — the kind of edges that don’t connect to anything useful when you query them. Coverage is a vanity metric. Treat it as one.</p><h3>Don’t trust extraction F1 to predict downstream behaviour</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WZ2dt8X9FL-FV10b" /><figcaption>Photo by <a href="https://unsplash.com/@sigmund?utm_source=medium&amp;utm_medium=referral">Compagnons</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Extraction metrics — precision, recall, F1 over triples — measure whether the LLM produced spans and relations that overlap with a reference. They do not measure whether the resulting graph supports the tasks you actually care about.</p><p>The interesting reading is the <em>gap</em> between the extraction F1 and the downstream task accuracy. A small gap means the extraction quality is your ceiling. A large gap means the extraction <em>looks</em> fine and the failures live somewhere else — usually in type assignments or relation semantics. If you only ever report extraction F1, you will optimise the easy half of the problem and ignore the hard one.</p><h3>Don’t conflate “got the span” with “got the entity”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K-iunPvB652lLgfd" /><figcaption>Photo by <a href="https://unsplash.com/@americanaez225?utm_source=medium&amp;utm_medium=referral">Arturo Añez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This is the failure mode that surprised me the most. LLMs are quite good at recovering the right surface form from text — they pull out the entity, often with phrasing that fuzzy-matches the reference. They are noticeably worse at deciding <em>what kind of thing</em> the entity is.</p><p>You can lose roughly half of your apparent entity recall the moment you require the entity <em>type</em> to match. The span looks right; the label is wrong; the downstream query that filters by type quietly returns nothing. If your ontology has overlapping-but-distinct categories (“method” vs “task,” “metric” vs “evaluation target”), the model collapses them. Score typing as its own metric, not as a hidden component of “extraction.”</p><h3>Don’t use semantically ambiguous relation labels without help</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gH9GgtLDNLFQofRr" /><figcaption>Photo by <a href="https://unsplash.com/@trebron?utm_source=medium&amp;utm_medium=referral">Norbert Kundrak</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Some relations carry strong, unambiguous semantics — “used-for,” “type-of.” Models handle them well. Other relations — “feature-of,” “evaluated-for,” “conjunction,” anything that overlaps with several plausible alternatives — collapse, almost without exception, into whichever neighbour is easier to lexicalise.</p><p>The cure is not to invent more relations. It’s to either (a) constrain the prompt with explicit, contrastive definitions or (b) accept that you’ll need post-hoc disambiguation. The worst option is to keep the ambiguous labels and pretend the headline F1 is the whole story. It isn’t — those few relations are where it hides its worst behaviour.</p><h3>Don’t let the LLM be the constructor and the judge</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zL7NVLq5aouEO0Zh" /><figcaption>Photo by <a href="https://unsplash.com/@kommumikation?utm_source=medium&amp;utm_medium=referral">Mika Baumeister</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you use a language model to extract the graph, then use the same family of models to generate the evaluation questions, then use it again to grade the answers, you have built a closed loop that scores itself. The numbers will look stable. They will not reflect anything about the world.</p><p>The fix is structural: derive your test set from something the LLM didn’t generate, query the graph deterministically, and grade with a matcher that doesn’t read the answer. Any of those steps left to a model recreates the dependency.</p><h3>Don’t ship a single pass</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uVclTJCm_Mr2Enfg" /><figcaption>Photo by <a href="https://unsplash.com/@opeleye?utm_source=medium&amp;utm_medium=referral">Jordan Opel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Zero-shot prompting in one pass is the demo. It is not the system. Almost every published improvement on LLM-based KG construction in the last two years involves <em>more</em> passes — a validator, an iterator, a retrieval-augmented refinement step. Treat the single-pass graph as the floor. Whatever number it gives you is the worst case for what supervision can buy.</p><h3>Don’t measure success by what it looks like</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l6KL8lHw8eMEril3" /><figcaption>Photo by <a href="https://unsplash.com/@dlerman6?utm_source=medium&amp;utm_medium=referral">Daniel Lerman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This is the cumulative version of everything above. A knowledge graph generated by an LLM <em>looks</em> like a knowledge graph. It has nodes, edges, labels, and types. It serialises to triples. It loads into your store. It survives every visual sanity check.</p><p>It is failing exactly where you can’t see it: in the connectivity that doesn’t quite compose across hops, the entity types that drift toward generic, the relations that flatten into a handful of confident defaults. None of these shows up in a precision-recall printout. All of them show up the moment a downstream system tries to reason over the graph.</p><h3>The summary</h3><p>If you take only one habit away from this: report two numbers, not one. Whatever extraction score you usually publish, also publish a downstream-task score. The gap between them is the only honest measurement of how much your LLM-generated graph actually works. Most of the time, the gap is larger than the headline suggests, and most of the engineering you have left to do lives inside it.</p><p>Coverage is cheap. Utility is the part that has to be earned.</p><blockquote>Original work with AI Assisted Writing</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6968c293a8e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Knowledge Graph Generation using LLM]]></title>
            <link>https://medium.com/@john.joy77777/knowledge-graph-generation-using-llm-28761e085f7b?source=rss-ad2caaeb87e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/28761e085f7b</guid>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[knowledge-graph]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[llamaindex]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[John Joy]]></dc:creator>
            <pubDate>Tue, 17 Sep 2024 18:58:17 GMT</pubDate>
            <atom:updated>2024-09-17T18:58:17.486Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Knowledge graphs are semantic representation of real-world data and they consist of entities linked with each with relationships. Entities can be objects, persons, events etc. Knowledge graphs are popular in indexing data for certain tasks such as reasoning and question answering and are also popular among big tech providers for indexing different sources on the internet for faster retrieval of information. Previously, the creation of a knowledge graph was solely something that was done through manual effort. With the advancement in Artificial intelligence, it has become easier to create knowledge graphs automatically.</p><p>Knowledge graphs are represented as connected triples (head, relation, tail) or some represent knowledge graphs as (subject, action, object). With improvements in the Named entity recognition models, it has become easier to extract different NERs from a free text. Especially for specific use cases where you have access to a model that has a decent amount of accuracy in detecting objects and relations from the model, it was still a big win for specific use cases.</p><p>With the introduction of Large Language Models (LLMs), it has further become much easier to extract, the triples from a text corpus. Different libraries support the creation of knowledge graph abstracting the complexity.</p><h3><strong>Creation of Knowledge Graphs with LLMs</strong></h3><p>Since that are innumerable articles discussing using deep-learning models to create a knowledge graph, for the sake of current relevancy I will be discussing more methods of generation of knowledge graphs using an LLM. (The accuracy of the results that are discussed depends on the LLM you choose to use)</p><h4>1 . Prompt Engineering</h4><p>With access to an LLM, you could always prompt to an LLM, and create your wrapper to be able to create a knowledge graph. The prompt to the LLM would depend on the LLM you have access to and choose to use and needs to be tested out for better results. Find an example of a prompt that could be used to generate knowledge graphs using Groq and python.</p><pre>from groq import Groq<br>import os<br>import networkx as nx<br>import pandas as pd<br>import matplotlib.pyplot as plt<br><br>os.environ[&quot;GROQ_API_KEY&quot;] = &quot;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&quot;<br><br>def prompt_generator(context:str):<br>    &quot;&quot;&quot; Generate prompt for the given context<br>    <br>    Args:<br>        context (str): The context for which prompt is to be generated<br>        <br>    Returns:<br>        str: The prompt generated from the context<br>    &quot;&quot;&quot;<br>    PROMPT = f&quot;&quot;&quot;Extract the subject, action, and object from the following sentence:.<br><br>            {context}.<br><br>            Return the subject, action, and object in the following format: Subject: [subject], Action: [action], Object: [object].&quot;&quot;&quot;<br>    return PROMPT<br><br><br><br>def generate_kg(context:str):<br>    &quot;&quot;&quot; Generate knowledge graph from the given context<br><br>    Args:<br>        context (str): The context from which knowledge graph is to be generated<br><br>    Returns:<br>        list: A list of knowledge graph extracted from the context<br>    &quot;&quot;&quot;<br>    client = Groq(<br>    api_key=os.environ.get(&quot;GROQ_API_KEY&quot;),<br>)<br>    knowledge_graph = []<br>    print(context.split(&#39;. &#39;))<br>    for each in context.split(&#39;. &#39;):<br>        response = client.chat.completions.create(<br>            model=&quot;llama3-8b-8192&quot;,<br>            messages=[<br>                {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: prompt_generator(each)},<br>            ]<br>        )<br>        response = response.choices[0].message.content<br>        # Extracting the subject, action, and object from the response<br>        print(response)<br>        subject = response.split(&#39;Subject: &#39;)[1].split(&#39;, Action:&#39;)[0].strip()<br>        action = response.split(&#39;Action: &#39;)[1].split(&#39;, Object:&#39;)[0].strip()<br>        obj = response.split(&#39;Object: &#39;)[1].strip()<br>        knowledge_graph.append([subject, action, obj])<br>    return knowledge_graph<br><br>def visualize_kg(kg:list):<br>    &quot;&quot;&quot; Visualize the knowledge graph<br><br>    Args:<br>        kg (list): List of knowledge graph<br>    &quot;&quot;&quot;<br>    df = pd.DataFrame(kg, columns=[&#39;Subject&#39;, &#39;Action&#39;, &#39;Object&#39;])<br>    print(df.shape)<br>    g = nx.from_pandas_edgelist(df, &#39;Subject&#39;, &#39;Object&#39;, [&#39;Action&#39;])<br>    nx.draw(g, with_labels=True)<br>    plt.savefig(&#39;plotgraph.png&#39;, dpi=300, bbox_inches=&#39;tight&#39;)<br>    plt.show()<br><br><br>if __name__ == &quot;__main__&quot;:<br>    context = &quot;The quick brown fox jumps over the lazy dog. The dog barks at the fox. The fox runs away.&quot;<br>    graph = generate_kg(context)<br>    visualize_kg(graph)<br><br></pre><h4><strong>2. Langchain</strong></h4><p>Langchain is a framework that could be used to create flexible AI applications in the form of chains. Each component can be represented as a chain and can be run sequentially. Langchain abstracts a lot of LLM calls especially function calls that enable more advanced LLM querying strategies through agents. Creation of knowledge graph using Langchain has been well documented in the <a href="https://python.langchain.com/v0.1/docs/use_cases/graph/constructing/">link</a>. Langchain also supports creation of knowledge graph and the persistence on the neo4j.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/0*JGBW-PE4rA7WBdcw.png" /><figcaption><a href="https://python.langchain.com/v0.1/docs/use_cases/graph/constructing/">Source</a></figcaption></figure><p>3. Llama-Index</p><p>Llama index is another framework that makes interaction with LLMs easier. Llama indexes are generally great when you have a specific task in mind and when functionality is supported by the library, in this is case knowledge graph creation.</p><p>Llama index supports the creation of property graphs which is a recent addition to the library and also supports persistence on neo4j.</p><p>There are multiple modes of creation of property knowledge graph using llama-index.</p><p>a SimplePathLLMExtractor — This allows the LLM to choose the triples from the context provided and on top of that it also includes entities and relations that it deems necessary. This could be very useful in cases where you have less domain knowledge and can afford more flexibility in the knowledge graph created.</p><p>b. DynamicPathLLMExtractor — This allows you to give suggestions to the LLM such as possible entities and possible relations. However, LLM still has the flexibility in determining the structure of the knowledge graph. It works best when you have better knowledge but not complete knowledge of the domain you work on.</p><p>c.SchemaPathLLMExtrator- This allows you to have complete authority over the entities and relations you need to extract. There is a parameter which lets you to have stricter rules or lazy rules. If the value is set to True for the strict flag, triples extracted beyond the schema is discarded. This lets you design your knowledge graph. This is used when you have good domain knowledge and vision on the knowledge graph you require since this let you set the schema which will then be parsed as a pedantic class.</p><p>The documentation to the code can be found in the<a href="https://docs.llamaindex.ai/en/stable/examples/property_graph/property_graph_advanced/"> link</a>.</p><p>The Llama index consists of extractors and retrievers as two main components to index and retrieve the information from the source.</p><p>4. Microsoft Graph</p><p>Microsoft repositories have resources meant for creation of knowledge graph that could be further used in the retrieval pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Q0l8cIAXWF-y4V2dFXzMnQ.jpeg" /><figcaption><a href="https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/">Source</a></figcaption></figure><p>Further documentation can be found in the <a href="https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/">link</a></p><h3>Conclusion</h3><p>In the era of LLMs creation of knowledge graphs have become easier than ever before. There are useful resources that could be used to create knowledge graphs using LLMs. However, there are some challenges with the generated knowledge graphs using the above libraries, such as entity ambiguity. I hope to discuss further on another post how to tackle some of the challenges for the generated knowledge graph. Thanks for reading the post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28761e085f7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>