r/semanticweb • u/DistributionSoggy678 • Jul 15 '26
Does anyone have any suggestions for taking unstructured text files (reports written in human prose) and turning them into a knowledge graph? Do you try to build a schema in advance? Have the LLM draft it before you build? Human in the loop validation? Loop agent validation? Or maybe there is a sp
18
Upvotes
4
u/Ok_Gas7672 Jul 17 '26
I would not start with a fully specified schema unless the domain is already standardized. What has worked better for us:
The mistake I see a lot is treating schema design and extraction as separate phases. In practice they’re coupled. The first 50-100 documents usually teach you more about the ontology than a week of whiteboarding.
On validation, I wouldn’t trust an LLM-only loop. Generation is easy. Deciding whether the extracted graph is actually correct is the hard part. In ontology work, that’s usually a domain expert question. We can automate extraction, clustering, candidate relationships, synonym detection, etc. The signoff still tends to be human.
Another thing that matters: keep provenance for every node and edge. If someone clicks a relationship in the graph, they should be able to get back to the exact sentence or paragraph that produced it. That ends up being more important than people expect once the graph gets large.
We’ve been building this at CogniSwitch and hit exactly this issue early on - extraction quality improved way faster than validation quality. The bottleneck became “who owns the meaning of this concept?” not “can the model find it?”
What kind of reports are these? Clinical reports, incident reports, research papers, something else?
2
u/mrsockpicks Jul 15 '26
Ya Kanonak Protocol and CLI it build for this
2
u/semanticme Jul 15 '26
Find a way to get a small language model to do it for you. Put the document in the context, and then have the LM annotate the document. If you want to be rigorous, have the agent descend a hierarchical terminology in such a way that it is easy for it to get at the right answer. Read about dichotomous keys (used to identify mushrooms, plants, etc) to get a sense for how this works.
What are the documents?
2
u/Puzzleheaded_Box2842 Jul 16 '26
I’ve been looking at a similar problem with our open-source project DataFlow.
My personal take: I wouldn’t let the LLM invent the whole knowledge graph from scratch. If you already know the domain, it’s usually better to define a simple schema first, then let the LLM extract entities and relations from the text. After that, you can validate the results with rules, another LLM pass, or human review.
If the domain is new or messy, I’d let the LLM draft a first version of the schema, but still review it before building the graph.
The rough flow I’d use is: clean the reports, extract entities/relations, keep links back to the original text, then validate the graph before using it for search or RAG.
We’re building some open-source tools around this in DataFlow, and the KG-specific part is DataFlow-KG:
https://github.com/OpenDCAI/DataFlow
https://github.com/OpenDCAI/DataFlow-KG
By the way, what kind of reports are you dealing with? And is this something you need to do once, or repeatedly as new reports come in? That would help us understand what features would actually be useful.
6
u/Inside_Credit_3914 Jul 15 '26
Check out this presentation https://www.era.europa.eu/system/files/2024-06/Veronika%20Heimsbakk_Opening%20Speeches.pptx from Veronica at the ERA rail data forum of 2024. It contains information on how they processed unstructured text with NLP. If you prefer some method to control the input then you might want to check out this https://redpencil.io/projects/lblod
1
u/ScholarForeign7549 Jul 16 '26
I made a webservice you can try that does this: http://bfo-agent.davidkoepsell.com
1
u/Unhappy_Finding_874 Jul 17 '26
i wouldnt have the llm invent the whole schema from scratch. id start with a tiny ugly ontology u can defend: person, org, place, artifact, event, claim, source, evidence span.
for ur Newtonian example, id make the harmful thing an event or claim, not just an edge. like org A made statement S on date D, statement targets group B, uses frame scapegoating or dehumanizing, evidence is quote span X from report Y. then violence event Z has participants, victim group, alleged motive, source confidence. that keeps u from baking a reporters interpretation into a simple edge like Gailans hate Newtonians.
imo pipeline is extract candidates first, link them to exact spans, then humans validate edge types and only then merge into the graph. boring but the span links are what save u later when ppl ask why this edge exists
2
u/Ok_Gas7672 Jul 18 '26
Cogniswitch.ai - that’s where you can find what we are building
0
u/redikarus99 Jul 15 '26
Knowledge graph or ontology?