Phase 3: Global Relation Extraction¶
Overview¶
Phase 3 discovers semantic relations between entity pairs across chunk and document boundaries. Where Phase 2 extracts local (within-chunk) triples, Phase 3 identifies global relations whose evidence is distributed across the corpus.
The default SOTA implementation uses DenseRetrievalGlobalRelationExtractor (Retrieve \(\to\) Rerank \(\to\) Extract),
combining dense vector retrieval, Text-Attributed Graph (TAG) subgraph envelopes, Cross-Encoder joint-attention
reranking, and structured LLM decoding.
Processing is crash-resilient: entities are read from the graph store (or from the Phase 2 artifact view on first run).
Each committed global triple carries scope="global" to distinguish it from Phase 2 local triples.
Goals¶
- Identify semantically meaningful relations between entity pairs across different documents and chunks.
- Break chunk boundaries via dense vector candidate generation rather than relying solely on co-occurrence.
- Filter candidate pairs with high precision using Cross-Encoder joint attention before invoking LLM decoding.
- Retrieve coherent evidence envelopes (subgraph context) per candidate pair.
- Validate all extracted relation types against
SchemaConfig. - Provide a reusable
GlobalRelationExtractorinterface shared with Phase 4b ARC.
Steps (Retrieve \(\to\) Rerank \(\to\) Extract)¶
- Entity Loading: All Layer 2 entities are loaded from the graph store via
get_entities()(falling back toPhase2ArtifactsViewon first run). - Dense Candidate Generation (The Prior):
- Entities are embedded globally using their name and description.
- Pairwise cosine similarities are computed across the corpus.
- Pairs exceeding
Phase3Config.dense_similarity_thresholdform the candidate set, capped atmax_candidates_per_entity_pairper entity hub.
- Subgraph Envelope Retrieval (
get_subgraph_envelope):- For each candidate entity in a pair, the graph store is queried for up to
subgraph_depthhops of contextual neighborhood (chunk nodes and adjacent entities). - Envelopes for entity A and entity B are merged, deduplicated, and formatted into compact context strings.
- For each candidate entity in a pair, the graph store is queried for up to
- Cross-Encoder Precision Reranking (
RelationReranker):- The candidate entity pair and their merged envelope context are evaluated jointly by
RelationReranker(e.g.Alibaba-NLP/gte-reranker-modernbert-base). - Cross-encoders perform full cross-attention between entity contexts, filtering spurious semantic matches.
- Pairs scoring below
Phase3Config.reranker_thresholdare discarded.
- The candidate entity pair and their merged envelope context are evaluated jointly by
- LLM Relation Decoding:
- Candidate pairs passing the reranker threshold are passed to the LLM via
astructured_predictagainstGlobalRelationOutput. - The LLM outputs:
relation: str | None,confidence: float,direction: Literal["A_to_B", "B_to_A"], andreasoning: str.
- Candidate pairs passing the reranker threshold are passed to the LLM via
- Schema Validation & Graph Commit:
- If
relationis not inSchemaConfig.relation_types, it is dropped. - Valid triples are committed to Neo4j via MERGE with
scope="global"andsource_chunk_id=None.
- If
Phase Data Flow¶
- Input:
Phase2ArtifactsView(or graph store on resume). - Output: Phase 3 global relation artifact collection.
- Graph updates:
- Relation edges (
SchemaConfig.relation_types):confidence,scope: "global",source_chunk_id: None
- Relation edges (
GlobalRelationExtractor — Shared Interface¶
GlobalRelationExtractor(ABC) defines the pluggability seam for global relation discovery. It is shared with Phase 4b
ARC: the same extractor instance created in Pipeline.for_task() is injected into both Phase3Runner and
Phase4Runner. This guarantees consistent evidence retrieval across the pipeline.
The interface exposes:
extract(entities, graph_store, schema) -> list[L2Triple]: Full batch extraction (Phase 3).get_subgraph_envelope(entity, graph_store, depth) -> SubGraph: Per-entity contextual envelope retrieval (used by Phase 4b ARC for argument component pairs).
Implementations:¶
DenseRetrievalGlobalRelationExtractor(pipeline/phases/phase3_global_relations/dense_retrieval_extractor.py): Default SOTA implementation using dense retrieval and Cross-Encoder reranking.TAGRelationExtractor(pipeline/phases/phase3_global_relations/tag_extractor.py): Alternative implementation utilizing chunk-co-occurrence structural blocking.
Pluggability¶
- Extractor: Implement
GlobalRelationExtractor(ABC)and pass viaPhase3Runner(global_extractor=MyExtractor()). - Reranker: Pass any
RelationRerankerorCrossEncodertoPipeline.for_task(relation_reranker=...). - Schema: Validated dynamically against
SchemaConfig.
ADR References¶
Implementation¶
pipeline/phases/phase3_global_relations/__init__.py—Phase3Runnerpipeline/phases/phase3_global_relations/dense_retrieval_extractor.py—DenseRetrievalGlobalRelationExtractorpipeline/phases/phase3_global_relations/tag_extractor.py—TAGRelationExtractorpipeline/phases/phase3_global_relations/rerankers.py—CrossEncoderRelationRerankerpipeline/phases/phase3_global_relations/models.py—GlobalRelationOutputpipeline/protocols/extractors.py—GlobalRelationExtractor(ABC),RelationReranker(ABC)