GraphRAG · relationship discovery in progress

FakeCompanyABC — GraphRAG

A graph-construction study that starts from the same fictional HR corpus as the classical RAG baseline. Entity-schema discovery and interactive entity validation now feed an explicit relationship-discovery stage, where text-grounded entity pairs are inspected before any edge schema is promoted into Neo4j.

25reviewed entity types
20document chunks
361candidate detections ≥ 0.20
198unique entity/type pairs
0.586mean stored confidence
Research pipeline

Build the graph in validated stages

The graph is treated as an engineered representation, not as an automatic LLM by-product. Each intermediate stage is inspected before the next one is trusted.

08.1Schema discoveryspaCy candidates → embeddings → PCA/HDBSCAN → manual review
→
08.2Entity extractionGLiNER spans + type + confidence + offsets
→
08.2.1Entity validationInteractive full-corpus inspection
→
08.3 · currentRelation discoveryEntity-pair candidates → adjacency filtering → typed relation patterns
→
NextRelation validationNormalize semantics, direction and schema before Neo4j
→
FutureNeo4j + GraphRAGValidated graph retrieval compared with the classical RAG baseline
08.1 · entity schema discovery

Let the corpus suggest the ontology, then review it manually

Candidate concepts were collected from the policy corpus, embedded with Nomic, projected with PCA, clustered with HDBSCAN, and manually reviewed into a domain-specific schema.

InputHR policiesClean Markdown + 700/120 chunks
→
CandidatesspaCyNER + noun phrases
→
RepresentNomic embeddings768-dimensional vectors
→
ExplorePCA + HDBSCANStructure candidate concepts
→
ReviewManual curationMerge, split, reject noisy clusters
→
Output25 entity typesReviewed GLiNER schema

PCA view of candidate concepts

PCA visualization of entity candidates
Clustering is used as a schema-discovery aid, not as final entity extraction.

Cluster-size summary

Entity candidate cluster size summary
Manual review turns the discovered structure into a stable domain schema.

Reviewed entity schema · 25 types

MONEY_AMOUNTDURATIONORGANIZATIONLEAVE_RULEAPPROVAL_REQUIREMENTLEAVE_CONCEPTPOLICYWORK_ARRANGEMENTREMOTE_WORK_ALLOWANCEBUSINESS_TRAVELDATETIME_PERIODTIME_CONSTRAINTLIMITHOTEL_RATE_LIMITEXPENSE_CONCEPTJOB_ROLEENTITLEMENTREQUIREMENTEMPLOYEE_TYPECOMPANY_RESOURCEEXCEPTIONTRANSPORT_MODECOUNTRYCURRENCY
08.2 · GLiNER entity extraction

Extract candidate spans with a deliberately low validation floor

GLiNER receives the 25 reviewed labels and the original chunks. Each stored prediction preserves the exact span, canonical type, confidence, and character offsets.

Schema25 reviewed typesNatural-language labels supplied to GLiNER
+
Text20 chunks5 policy documents
→
ModelGLiNER medium v2.1urchade/gliner_medium-v2.1
→
Output361 detectionsspan + type + score + offsets

Current extraction metadata

Documents5
Chunks20
Chunk size / overlap700 / 120
Schema size25 types
Stored detections361
Unique entity/type pairs198
Extraction floor0.20
Confidence range0.202 – 0.987
Mean confidence0.586

Threshold experiment

212detections at old ≥ 0.50 run
98 unique entity/type pairs
→
361detections at current ≥ 0.20 run
198 unique entity/type pairs

The 0.20 threshold is an extraction floor for validation, not the final acceptance threshold. Lower-confidence candidates are intentionally retained so they can be inspected instead of discarded upstream.

Detections by entity type

COUNTRY38
EMPLOYEE_TYPE38
POLICY34
LEAVE_CONCEPT26
DURATION25
CURRENCY22
LIMIT20
APPROVAL_REQUIREMENT19
ORGANIZATION15
BUSINESS_TRAVEL14
DATE12
EXPENSE_CONCEPT12
LEAVE_RULE11
REMOTE_WORK_ALLOWANCE11
TRANSPORT_MODE11
WORK_ARRANGEMENT11
ENTITLEMENT9
JOB_ROLE9
EXCEPTION7
REQUIREMENT5
TIME_PERIOD4
MONEY_AMOUNT3
COMPANY_RESOURCE2
TIME_CONSTRAINT2
HOTEL_RATE_LIMIT1

Detections by source policy

travel_policy.md94
remote_work.md74
annual_leave.md73
parental_leave.md61
expense_policy.md59

Counts are mention-level detections in the current ≥0.20 JSON and include repeated entities across chunks/context.

08.2.1 · interactive validation

Inspect every entity in its original context.

The standalone viewer contains the entire chunked corpus and allows filtering by source document, entity type, and confidence. It is used to check coverage, span boundaries, label quality, and the effect of moving the confidence threshold before relations are trusted.

08.3 · relationship candidate discovery

Find relation evidence before naming graph edges.

The first relation pass stays grounded in the policy text: detected entities are paired inside each sentence, the exact text between them is retained as evidence, and compact adjacent pairs are prioritized before clustering or semantic normalization.

372unique relation candidates
161adjacent entity pairs
5median between-text tokens
0.40median pair confidence

Initial candidate finding

For each detected entity pair, the relation-candidate record keeps the source sentence, left and right entity spans and types, the exact text between them, token gap, number of intervening entities, adjacency flag, and pair confidence. This produced 372 unique candidates.

The first precision-oriented view keeps pairs with no intervening detected entity. That leaves 161 adjacent pairs (43.3% of the candidate pool), and 159 of 161 of those have eight or fewer between-text tokens. The relation viewer exposes the full pool while defaulting to the compact adjacent set.

What the evidence looks like

The between-text already exposes recurring typed structures that can later be consolidated into a smaller relation vocabulary. Examples from the current corpus include:

WORK_ARRANGEMENT → “is” → COUNTRY
EMPLOYEE_TYPE → “receive” → LEAVE_CONCEPT
LEAVE_CONCEPT → “per” → TIME_PERIOD
DATE → “requires” → APPROVAL_REQUIREMENT

These are evidence patterns, not final Neo4j relationship labels. Pair confidence is inherited from entity detection; it is not yet a learned relation-confidence score.

First typed-pattern discovery run

Input161 adjacent pairsText-grounded candidates with no intervening entity
→
Screen12 low-informationFlag generic or weak between-text before clustering
→
Eligible149 candidatesRetained for typed-pattern discovery
→
Deduplicate131 unique patternsleft type + phrase + right type
→
NextCluster + normalizeReview representative patterns and define reusable edge semantics
Current boundary: 08.3 has moved beyond planning into relation-candidate generation and typed-pattern discovery. The next gate is relation-schema validation—merging paraphrases, rejecting weak patterns, and deciding direction/cardinality—before anything is loaded into Neo4j.