On this page
- Introduction: knowledge is not the same as documents
- Where traditional RAG falls short
- Our approach: RAG plus an Ontology Knowledge Framework
- System architecture
- From file to searchable chunks: the ingestion lifecycle
- Ontology, entities and relationships
- Knowledge governance: who decides what is true?
- Security and access control
- Query processing: how a question becomes a grounded answer
- Engineering challenges
- POC evaluation
- Technology stack
- Conclusion
Most organizations do not suffer from a lack of knowledge. They suffer from a lack of a reliable way to reach it. Policies live in SharePoint libraries, contracts are scanned PDFs, amendments arrive as Word files, and the most recent decision is sometimes recorded only in a spreadsheet. The knowledge exists, but it is fragmented, inconsistent and hard to trust.
Introduction: knowledge is not the same as documents
The obvious first idea for "AI over company documents" is a chatbot over PDFs: split the files into chunks, embed them, retrieve the chunks most similar to a question, and let a language model write an answer. This pattern, retrieval-augmented generation (RAG), is a genuine step forward over keyword search, and it is a good foundation. For an enterprise it is also not enough.
An enterprise does not only need an answer that sounds plausible. It needs an answer it can rely on. That raises questions a plain chatbot cannot answer on its own:
- Which document is authoritative when two documents disagree?
- Is this still valid, or was it replaced by a newer version?
- Where did the answer come from, so that a person can check it?
- Who is allowed to see it, including facts that were derived from restricted documents?
The goal of this platform was to move from searchable documents to reliable, interconnected, governed organizational knowledge, while keeping the flexibility of RAG.
Where traditional RAG falls short
Traditional RAG works at the level of text chunks. That is its strength (it handles almost any document) and the source of most of its limitations in an enterprise setting. These are the six we kept running into.
1. Chunks do not understand business relationships
A chunk is a piece of text. It does not know that a contract belongs to a vendor, that an amendment modifies that contract, or that a policy is owned by a department. Those relationships may be spread over several documents, and a similarity search has no concept of "follow the link from this contract to its amendments".
2. Documents can conflict
Real document collections contain contradictions. Two sources can state different values for the same fact, and nothing in the embedding tells a retriever which one to trust.
3. Old and new policies coexist
Superseded documents are rarely deleted. They stay in the library next to their replacements, and they often look very similar to them. A retriever may happily return the outdated version.
4. Conditional rules are easy to misread
Business rules are often conditional: "30 days, unless the vendor is strategic, in which case 60 days with approval". When a chunk boundary falls between the rule and its exception, the model sees only half of it.
5. Similarity is not authority
Vector similarity measures how close a passage is to the question. It says nothing about whether the passage is the approved, current, correct statement. A retrieved passage is evidence, not authority.
6. Access control must follow derived knowledge
Permissions are normally defined on source documents. As soon as a system extracts facts from those documents, the facts need the same protection. A summary of a confidential contract is still confidential.
An illustrative example: the vendor agreement
Suppose a company works with a fictional vendor, Acme Supplies, and three documents mention payment terms.
"Invoices are payable within 45 days of receipt."
"Payment terms for all services are revised to 30 days."
"Strategic vendors may receive 60-day terms with Finance approval."
Each passage is individually "relevant". A chunk-based system has no principled way to decide between them. To answer correctly you need to know that the amendment supersedes the original agreement for the period after 2024, and that the policy is a conditional exception that applies only to a certain class of vendor. That information is structure, and structure is exactly what plain chunks lack.
Our approach: RAG plus an Ontology Knowledge Framework
We did not replace RAG. We added a layer of structured knowledge on top of it, which we call the Ontology Knowledge Framework (OKF). The combined system uses:
- Traditional RAG for broad, flexible retrieval over document text.
- A custom domain ontology that defines which kinds of entities and relationships matter to the business.
- Entity and relationship extraction to find those entities and relationships in documents.
- Knowledge-graph concepts to represent how the extracted pieces connect.
- Ontology validation to reject extractions that do not make sense in the domain.
- Temporal reasoning so that "valid from" and "superseded by" are explicit.
- Conflict identification to surface disagreements instead of hiding them.
- Provenance so that every piece of knowledge points back to its source evidence.
- Human-reviewed publishing so that extracted knowledge becomes authoritative only after review.
What OKF is, and what it is not
It is easy to misdescribe this layer, so it is worth being precise. OKF is not a vector database: it does not store embeddings for similarity search, and RAG continues to do that job. It is also not simply a synonym for a knowledge graph. A knowledge graph is one useful way to represent entities and their relationships. OKF is the broader framework around it: the ontology that defines the vocabulary, the rules for extraction and validation, the handling of time and conflicts, the provenance, and the governance process that decides what is published.
RAG finds relevant text. OKF decides what that text means and whether it can be trusted.
System architecture
The platform is organized as a pipeline that turns source documents into two things: a searchable index of text, and a governed body of structured knowledge. Both are used when a user asks a question.
- 01Document sources
SharePoint libraries and uploaded PDF, DOCX and CSV files.
Microsoft GraphSharePoint - 02Ingestion
Register each document and hand it to background workers.
FastAPIAzure Blob Storage - 03Document processing
Parse, clean and prepare the content.
Python - 04RAG pipeline
Chunk the text, create embeddings and index them.
Azure OpenAIAzure AI Search - 05OKF extraction
Extract entities and relationships against the ontology.
Azure OpenAI - 06Knowledge validation
Check ontology rules, temporal validity and conflicts.
Python - 07Governance
Steward review, approval and publication.
PostgreSQLReact - 08Storage and indexing
Keep governed knowledge, originals and search indexes.
PostgreSQLAzure Blob StorageAzure AI Search - 09Query processing
Interpret the question and retrieve with access filters.
FastAPIAzure AI Search - 10Grounded answers
Generate an answer that points back to its evidence.
Azure OpenAI
What each component is responsible for
| Component | Responsibility |
|---|---|
| Python and FastAPI | The service layer: APIs for ingestion and queries, orchestration of background workers, and the extraction and answering logic. |
| PostgreSQL | The authoritative store for governance: the document registry, extracted entities and relationships, review state and permission data. |
| Azure Blob Storage | Keeps the original files, so the source of truth is never lost or rewritten by processing. |
| Azure AI Search | The search index for document chunks, used for hybrid (keyword and vector) retrieval, with results filtered by what the user may access. |
| Azure OpenAI | Provides the language model for extraction and answer generation, and the embedding model for vector search. |
| Microsoft Graph and SharePoint | How the platform reads enterprise documents and the permission context attached to them, so source permissions can be carried through. |
A deliberate design choice is to separate search from governance. The search index is optimized for fast retrieval. PostgreSQL is the system of record for what the organization has decided is true. Keeping them separate means a retrieval problem never silently rewrites approved knowledge.
From file to searchable chunks: the ingestion lifecycle
Every document goes through the same lifecycle, and each step is separate so it can fail, retry and be measured independently.
- Original storage. The unmodified file is stored first. Everything derived later can be traced back to it.
- Document registration. A record is created for the document, capturing its identity, source and the access information needed later.
- Queue and worker. Heavy processing runs in the background. Uploading a file stays fast, and slow parsing or model calls cannot block users.
- Parsing and cleaning. Different formats are turned into clean text while keeping useful structure such as headings and tables.
- Chunking. The text is split into pieces small enough to retrieve precisely, but large enough to keep a rule together with its context.
- Embeddings and indexing. Each chunk is embedded and written to the search index, ready for hybrid retrieval.
Ontology, entities and relationships
The structured side of the platform rests on a few simple ideas.
- An entity is a thing the business cares about: a vendor, a contract, a policy, a department.
- A relationship connects two entities: a vendor is party to a contract, a contract is governed by a policy.
- A domain ontology defines which entity types exist, which relationships are allowed between them, and what properties they can have. It is the shared vocabulary of the domain.
- Entities and relationships together form a knowledge graph, which can be followed and queried.
- Provenance attaches each extracted fact to the source evidence it came from, such as the document and the location in it.
Swipe sideways to see the whole diagram.
With this structure, the earlier question has a defensible answer. The system can see that two payment terms exist, that one supersedes the other from 2024, and which document and page each came from. A language model is then given that, rather than three loosely related paragraphs.
Why ontology validation matters
Language models extract confidently, including when they are wrong. The ontology acts as a set of rules the extraction must obey. If a model proposes that a Department "signed" a Policy, and the ontology does not allow that relationship between those types, the candidate is rejected or flagged instead of entering the knowledge base. Validation turns free-form model output into something that fits the domain.
# Illustrative sketch only: not the production schema
entity Vendor { name }
entity Contract { title, effective_from, effective_to }
entity Policy { title, version }
entity Department { name }
relation Vendor PARTY_TO Contract
relation Contract AMENDS Contract
relation Contract GOVERNED_BY Policy
relation Department OWNS Policy
# every extracted fact also records provenance:
# source document · location in it · period of validity · review status
Knowledge governance: who decides what is true?
Extraction by a language model is a proposal, not a fact. Before an extracted statement can influence answers as authoritative knowledge, it goes through a governed workflow.
- Extraction produces candidate entities and relationships with their provenance.
- Validation checks the candidates against the ontology.
- Conflict analysis compares them with existing knowledge and flags disagreements and superseded statements.
- Steward review puts a responsible person in front of anything that needs a decision.
- Approval and publication make the knowledge available to the retrieval layer as approved knowledge.
Human review matters for three reasons. Model extraction is probabilistic, so some errors will always get through automated checks. Resolving a conflict is often a business judgment (which source wins, and from when?) that software should not make silently. And an organization needs accountability: when an answer is challenged, there should be a record of who approved the underlying knowledge.
Security and access control
Security was treated as part of the design from the start, not as a final layer. The platform uses:
- Role-based access control (RBAC) to decide what users can do in the platform.
- Document-level permissions to decide which documents a user may read.
- Group-based access so permissions can be managed for teams rather than individuals.
- Source permission inheritance so that the platform respects the permissions set in the original system, such as SharePoint, instead of inventing its own.
- Access-filtered retrieval in Azure AI Search, so a user only gets results they are allowed to see.
- PostgreSQL as authoritative governance storage, so permissions and review state live in one controlled place.
Security only on documents
A fact extracted from a restricted contract becomes visible to everyone through a relationship or a generated answer.
Security that follows derived knowledge
Entities and relationships carry the access rules of the evidence they came from, so derived knowledge is filtered the same way as the documents.
This is the part that is easy to miss. If permissions are applied only to document chunks, the structured layer becomes a side door. A relationship such as "Vendor X is party to Contract Y" can itself be sensitive. So security must extend beyond document chunks to entities and relationships, and derived knowledge has to be filtered with the same care as the originals.
Query processing: how a question becomes a grounded answer
When a user asks a question, it travels through a sequence of steps, and both conventional RAG and OKF contribute.
- Intent identification. The system works out what kind of question this is (for example, looking up a policy versus finding who owns something). Intents are configurable, because every business asks different kinds of questions.
- Retrieval strategy. The intent selects how to retrieve: which sources to prefer and how much to rely on structured knowledge.
- Hybrid retrieval. Keyword and vector search retrieve relevant chunks from the access-filtered index.
- Ontology-aware retrieval. Related entities and relationships are pulled in, along with their validity and provenance, so that the context reflects structure, not just similarity.
- Context construction. The retrieved text and the approved knowledge are assembled into a compact, well-organized context.
- LLM and evidence validation. The model drafts an answer, which is then checked against the evidence, so that what is said can be traced back to material the user is allowed to see.
| Conventional RAG contributes | OKF contributes |
|---|---|
| Broad coverage of any document text | Structured, approved knowledge about entities |
| Flexible handling of unexpected questions | Explicit relationships, validity periods and supersession |
| Fast semantic and keyword matching | Conflict awareness and provenance |
| Low effort to add new documents | Governed, reviewed and access-controlled knowledge |
The two approaches are complementary. RAG covers the long tail of questions, while OKF gives reliable answers where the stakes are higher and the structure is known.
Engineering challenges
The hardest problems were not about calling a model. They were about what happens around it.
Conflicting business rules
Detecting that two statements disagree is harder than it sounds. They may use different wording, apply to different scopes, or both be correct under different conditions. The design choice was to surface conflicts for review instead of trying to resolve them automatically.
Temporal validity
Knowledge has a lifespan. A fact can be true from one date, superseded on another, and still relevant for historical questions. Storing validity explicitly, rather than assuming "latest wins", keeps both current and historical answers possible.
Entity duplication
The same vendor can appear as "Acme Supplies", "Acme Supplies Ltd." and "Acme". If each variant becomes a separate entity, the graph fragments and relationships are missed. Reconciling them is a core part of keeping the knowledge useful.
Relationship validation
A plausible-looking relationship can still be wrong for the domain. Validating against the ontology catches a whole class of errors before they reach a reviewer, which also saves human time.
Permission propagation
Permissions change over time and must reach derived knowledge. Deciding how access rules flow from a document to the entities and relationships extracted from it, and keeping that consistent, is easy to get wrong and costly if it is.
Extraction cost
Running a language model over every document has a real cost. This shaped the evaluation: the question was not only whether extraction works, but whether it works well enough for the cost.
Human approval
Review gives trust but can become a bottleneck. The aim is to send reviewers only what genuinely needs judgment, with the evidence and conflicts already laid out for them.
Retrieval quality
Better structure does not excuse weak retrieval. Chunking, hybrid search and context construction still decide whether the right evidence reaches the model, so they need as much attention as the knowledge layer.
POC evaluation
The proof of concept was set up around three questions, each with a clear verdict.
Cost versus accuracy
Whether the approach delivers acceptable accuracy for its cost.
Conflict granularity
Detecting conflicts from short statements up to paragraph-level content.
Intent customization
Making business-intent identification configurable.
1. Cost versus accuracy: pass
The POC concluded that the approach met its objective of balancing extraction cost against accuracy.
2. Conflict granularity: partial
This is the honest part. The result was partial, meaning the approach did not hold up equally across the whole range from short statements to paragraph-level content. There is an inherent reason it is hard: a short, self-contained statement is relatively easy to compare with another, while in a long paragraph the conflicting claim is embedded in surrounding context, conditions and exceptions. This remains an open area for improvement, and I do not want to overstate it.
3. Intent customization: pass
The POC showed that business-intent identification can be configured to suit a business, rather than being fixed in code. That matters because the useful categories of question differ between organizations.
Technology stack
The technologies are grouped below by role.
Frontend
- React
- TypeScript
Backend
- Python
- FastAPI
LLM
- Azure OpenAI
- GPT-4.1-mini
Embeddings
- text-embedding-3-small
Database
- PostgreSQL
Search
- Azure AI Search
Storage
- Azure Blob Storage
Integrations
- Microsoft Graph
- SharePoint
Infrastructure
- Docker
- Azure Container Apps
These are the architectural building blocks of the platform. This page does not claim that any of them ran in production.
Conclusion
Connecting a language model to a folder of documents is the easy part, and for many uses it is enough. For an enterprise it is only the beginning. The real work lies in everything that makes an answer something people can rely on.
Building enterprise AI knowledge systems takes more than connecting an LLM to documents. It takes structured knowledge, traceability, governance, access control, temporal awareness, and measurable evaluation.
RAG gave us reach across unstructured content. The Ontology Knowledge Framework added meaning, provenance and a path for human judgment. Security had to extend to every piece of derived knowledge, and the proof of concept had to be evaluated with honest verdicts, including a partial one. Working on this taught me that the quality of an AI system is decided as much by its engineering around the model as by the model itself.
All examples, names and figures in this article are fictional or conceptual and exist only to explain ideas. No confidential material has been used.