AGENCYSCRIPT
CoursesEnterpriseBlog
πŸ‘‘FoundersSign inJoin Waitlist
AGENCYSCRIPT

Governed Certification Framework

The operating system for AI-enabled agency building. Certify judgment under constraint. Standards over scale. Governance over shortcuts.

Stay informed

Governance updates, certification insights, and industry standards.

Products

  • Platform
  • Certification
  • Launch Program
  • Vault
  • The Book

Certification

  • Foundation (AS-F)
  • Operator (AS-O)
  • Architect (AS-A)
  • Principal (AS-P)

Resources

  • Blog
  • Verify Credential
  • Enterprise
  • Partners
  • Pricing

Company

  • About
  • Contact
  • Careers
  • Press
Β© 2026 Agency Script, Inc.Β·
Privacy PolicyTerms of ServiceCertification AgreementSecurity

Standards over scale. Judgment over volume. Governance over shortcuts.

On This Page

Prerequisites Beginners SkipPick a narrow, real corpusDecide what you will ask the graphSketch a minimal schemaWriting Your First Extraction PromptStructure the instruction clearlyDemand and enforce structureRunning Extraction and Inspecting OutputResolving Entities Into NodesSimple normalization firstLoad into a store you can queryValidating Against Your Original QuestionsRun your target queriesMeasure before you scaleIterating Toward a Better GraphChange one thing at a timeGrow the schema deliberatelyKnow when the starter project is doneFrequently Asked QuestionsHow many documents do I need for a first project?Do I need a graph database to start?What is the most common first-project mistake?Why does my model invent relationships that are not in the text?When should I worry about entity resolution?Key Takeaways
Home/Blog/From Raw Documents to a Working Entity Graph
General

From Raw Documents to a Working Entity Graph

A

Agency Script Editorial

Editorial Team

Β·November 10, 2019Β·8 min read
prompting for knowledge graph extractionprompting for knowledge graph extraction getting startedprompting for knowledge graph extraction guideprompt engineering

The fastest way to learn prompt-driven knowledge graph extraction is to extract a graph from documents you actually care about, end to end, in an afternoon. Tutorials that start with abstract ontology theory lose people before they see a single node. The approach here inverts that: get a small graph working first, understand why each piece exists, then deepen. A working artifact, even a rough one, teaches more than a chapter of definitions.

That said, a few prerequisites genuinely matter, and skipping them is the most common reason a first attempt produces a graph nobody trusts. You need a small, focused set of documents, a clear sense of what you want to ask the graph, and a minimal schema. Get those right and the extraction itself is almost easy. Get them wrong and no amount of prompt tuning saves you.

This walkthrough takes you from raw documents to a queryable first graph, names the prerequisites that beginners underestimate, and points to where each decision deepens as you grow beyond the starter project. The goal is your first real result, not a complete education.

If you take one thing from this walkthrough, let it be the order of operations. The instinct of most beginners is to start by tuning the prompt, because the prompt is the part that feels like the work. But the prompt is the easy part once the foundations are right, and it is nearly hopeless when they are wrong. Choose your corpus, write your questions, and sketch your schema first. Those three decisions determine whether your first graph is a satisfying success or a frustrating mess, long before a single token reaches the model.

Prerequisites Beginners Skip

Three things determine whether your first attempt succeeds, and all three precede any prompting.

Pick a narrow, real corpus

Choose a small set of documents from one type: a dozen contracts, a folder of meeting notes, a handful of research papers. Variety is the enemy of a first project because each new document type introduces extraction quirks. Narrow and real beats broad and hypothetical.

Decide what you will ask the graph

Write down three questions you want the graph to answer. These questions define which entities and relationships matter and which you can ignore. A graph built without target questions extracts everything and answers nothing well.

Sketch a minimal schema

List the entity types and relationship types your questions require. Keep it small, perhaps four entity types and five relationship types. This minimal ontology is the contract your prompt will enforce, and the reasoning behind closed versus open schemas is laid out in When Strict Schemas Beat Open-Ended Graph Extraction.

Writing Your First Extraction Prompt

The prompt has three jobs: state the schema, supply the document, and demand structured output.

Structure the instruction clearly

Tell the model the entity types and relationship types it may use, instruct it to return a list of triples in a specific JSON shape, and instruct it to extract only what the text supports. Explicitly forbid inventing relationships, because a model left unconstrained will helpfully hallucinate plausible-sounding edges.

Demand and enforce structure

Use your model's structured-output mode, function calling, or JSON mode rather than hoping for clean JSON in free text. This single choice prevents most first-project frustration and is the reliability lever explored across Software That Turns Messy Text Into Clean Triples.

Running Extraction and Inspecting Output

Run the prompt on one document first, by hand, and read the result closely before scaling to the rest.

  • Check that every extracted entity actually appears in the source text.
  • Check that every relationship is genuinely stated, not inferred or imagined.
  • Note any true relationships the model missed, because misses reveal prompt gaps.
  • Confirm the output conforms to your schema without manual cleanup.

This single-document inspection is the most valuable hour in the whole project. It surfaces almost every problem you will face at scale while it is still cheap to fix.

Resolving Entities Into Nodes

Raw triples are not yet a graph. The same entity will appear under different surface forms, and merging those is what turns triples into a connected structure.

Simple normalization first

Start with basic normalization: lowercase, trim whitespace, collapse obvious variants. For a first project, simple rules handle most cases. Reserve sophisticated entity resolution for when your graph is large enough that duplicates actually distort your answers, a topic developed in Coreference, Long Context, and Other Graph Extraction Hard Parts.

Load into a store you can query

For a first graph, even an in-memory structure or a simple graph library is enough to run your three questions. Do not over-invest in infrastructure before you have proven the extraction works.

Validating Against Your Original Questions

The graph is only successful if it answers the three questions you wrote at the start.

Run your target queries

Pose each of your three questions as a graph query. If the answers are right, you have a working pipeline. If they are wrong, the failure tells you exactly what to fix: missing entities point to recall problems, wrong answers point to precision or resolution problems.

Measure before you scale

Before extracting your full corpus, spot-check accuracy on a few documents so you know roughly how trustworthy the graph is. Even informal measurement now prevents scaling a broken pipeline, and formalizing it is the subject of Scoring Whether Your Extracted Triples Are Actually Right.

Iterating Toward a Better Graph

Your first graph will be imperfect, and that is the point. The value of getting something working quickly is that it gives you a concrete artifact to improve, with real failures to diagnose rather than imagined ones.

Change one thing at a time

When a query returns a wrong answer, resist the urge to rewrite the entire prompt. Change a single instruction, re-run on your inspection document, and observe the effect. Changing one thing at a time is the only way to learn which instruction actually mattered, and that learning is what compounds into skill across future projects.

Grow the schema deliberately

As you read your results, you will notice relationships your minimal schema cannot express. Resist adding them all at once. Add one entity or relationship type, confirm the extraction still works and your existing queries still pass, then add the next. A schema grown deliberately stays coherent; a schema expanded in a panic becomes a tangle.

Know when the starter project is done

The first project is complete when your three questions return correct answers on your small corpus and you understand why each part of the pipeline exists. At that point you have earned the right to scale up, take on harder document types, and tackle the advanced problems. Stopping earlier leaves you with a demo; pushing further before this point usually means scaling problems you have not yet diagnosed.

Frequently Asked Questions

How many documents do I need for a first project?

Fewer than you think. A dozen documents of one type is plenty to learn the full pipeline and surface most problems. Starting small keeps the feedback loop fast, which matters far more than corpus size when you are learning.

Do I need a graph database to start?

No. An in-memory structure or a lightweight graph library is enough to prove the concept and run your first queries. Add a real graph database only when your queries traverse many hops or your graph outgrows memory.

What is the most common first-project mistake?

Skipping the target questions. Without them, you extract everything and have no way to judge whether the graph is good. The three questions are what make success measurable.

Why does my model invent relationships that are not in the text?

Because you did not forbid it clearly enough. Add an explicit instruction to extract only relationships stated in the source, and consider asking the model to cite the supporting span for each triple, which sharply reduces invention.

When should I worry about entity resolution?

Once duplicate nodes start distorting your query answers. For a small first graph, simple normalization is enough. Sophisticated resolution is a problem you grow into, not one you solve on day one.

Key Takeaways

  • Start by extracting a small, real graph end to end; a working artifact teaches more than abstract ontology theory.
  • The prerequisites that decide success are a narrow corpus, three target questions, and a minimal schema, all chosen before prompting.
  • Enforce structured output natively and forbid the model from inventing relationships not present in the text.
  • Inspect a single document's output by hand before scaling; it surfaces nearly every problem while fixes are still cheap.
  • Validate the graph against your original three questions, and spot-check accuracy before extracting your full corpus.

Search Articles

Categories

OperationsSalesDeliveryGovernance

Popular Tags

prompt engineeringai fundamentalsai toolsthe difference between AIMLagency operationsagency growthenterprise sales

Share Article

A

Agency Script Editorial

Editorial Team

The Agency Script editorial team delivers operational insights on AI delivery, certification, and governance for modern agency operators.

Related Articles

General

Rolling Out AI Hallucinations Across a Team

Most teams discover AI hallucinations the hard way β€” a confident-sounding wrong answer makes it into a client deliverable, a legal brief, or a published report. The damage isn't just to the output; it

A
Agency Script Editorial
June 1, 2026Β·11 min read
General

Case Study: Large Language Models in Practice

Most teams that fail with large language models don't fail because the technology doesn't work. They fail because they treat deployment as a one-time event rather than a discipline β€” pick a model, wri

A
Agency Script Editorial
June 1, 2026Β·11 min read
General

Thirty-Second Wins Breed False Confidence With LLMs

Working with large language models is deceptively easy to start and surprisingly hard to do well. You can get a useful output in thirty seconds, which creates a false confidence that compounds over ti

A
Agency Script Editorial
June 1, 2026Β·10 min read

Ready to certify your AI capability?

Join the professionals building governed, repeatable AI delivery systems.

Explore Certification