← All work
Deployed technical prototypeLegal technology

Evidence-linked investigation across documents and entities

Legal Discovery Graph

The business question

How can an investigator move from a large discovery record to evidence they can inspect and trace?

The answer

Combine vector and graph retrieval with cited evidence, structured entities, timelines, and calibrated refusal.

Demonstrated value

Connects documents, people, events, and citations in one inspectable investigation workflow.

Focus

AI engineer / Data engineer

I built the extraction, indexing, graph, hybrid retrieval, evaluation, and Streamlit delivery path.
Primary stakeholder

Reviewer or investigator working through a synthetic discovery record

Context and stakes

Large records hide relationships across documents.

Discovery work rarely lives in a single document. People, companies, events, and citations are distributed across a record, while the connections between them carry as much meaning as the passages themselves.

A similar-looking document is not enough when an investigator needs to trace why a person, event, or relationship matters. The system needed to return inspectable evidence and preserve the path between a question and the material used to answer it.

Approach

Connect retrieval paths, then show the evidence.

Combine vector retrieval for semantic similarity with a relationship graph for structure, then return cited evidence through one investigation workspace with a calibrated refusal path.

Design constraints

  • Every document, person, company, amount, and event in the published corpus is synthetic and fictional.
  • Evaluation results describe a reproducible templated corpus, not real legal matters.
  • Graph and vector systems stay separate enough to support complementary retrieval paths.

Decision journey

A discovery corpus becomes an inspectable case view.

The workflow moves from fictional source material to structured, cited evidence a reviewer can trace.

  1. Data

    Generate

    Create the synthetic discovery corpus used for repeatable extraction and retrieval evaluation.

  2. AI

    Extract

    Structure entities and events so evidence can be connected across documents.

  3. Data

    Index

    Build the vector index used to find semantically related passages.

  4. Data

    Connect

    Load entities and relationships into the graph for traceable traversal.

  5. AI

    Retrieve

    Combine vector and graph paths, attach citations, and refuse when support is insufficient.

  6. Human

    Investigate

    Review evidence, entities, timelines, and relationship paths in the workspace.

Interactive architecture

Vector similarity and graph structure meet at evidence orchestration.

The architecture keeps semantic similarity and relationship structure as complementary retrieval paths. Select a stage to see the role it plays in the investigation flow.

Drag to pan / use controls to zoom / select any stage
100%
documentspassagesentities + eventssemantic matchesrelationship pathscited evidenceSourceDiscovery corpusSynthetic documentsStructureEntity extractionPythonSimilarityVector indexPostgreSQL + pgvectorConnectionRelationship graphNeo4j AuraDBEvidenceHybrid retrievalLangChainReviewInvestigation viewStreamlit + Plotly
Read the architecture as text
  1. Discovery corpusSource / Synthetic documents

    Provides the fictional, templated record used for repeatable extraction and evaluation.

  2. Entity extractionStructure / Python

    Identifies the people, companies, events, and evidence units used by both retrieval paths.

  3. Vector indexSimilarity / PostgreSQL + pgvector

    Retrieves passages by semantic similarity to the investigation question.

  4. Relationship graphConnection / Neo4j AuraDB

    Preserves structured relationships and paths between entities and events.

  5. Hybrid retrievalEvidence / LangChain

    Combines graph and vector results with cited evidence and calibrated refusal.

  6. Investigation viewReview / Streamlit + Plotly

    Presents citations, entities, timelines, and relationship paths for human inspection.

Technology used
PythonFlaskLangChainsentence-transformersONNX RuntimePostgreSQL + pgvectorNeo4j AuraDBSupabasePlotly

Pivotal decisions

Two choices shape the investigation boundary.

Both choices trade broader claims for a system that can be inspected and evaluated honestly.

Decision

Keep graph and vector retrieval together

Find relevant language while preserving the relationships an investigator needs to trace.

Constraints
  • Semantic similarity does not describe every relationship.
  • Graph traversal depends on structured extraction.
Alternatives
  • Vector retrieval only
  • Graph traversal only
Criteria
Relevant passages / Inspectable relationships / Cited evidence / Calibrated refusal
Selected
Complementary pgvector and Neo4j retrieval paths
Why
Vector search finds semantically related material while the graph preserves explicit entity and event connections.
Trade-off
Maintaining two retrieval systems adds indexing and operational complexity.
What supported it
The published evaluation reports graph retrieval R@5 of 0.929 and relationship hit@5 of 0.833.
Revisit when
Reconsider the split if component-level evaluation shows one path no longer adds useful evidence.
Decision

Use a reproducible synthetic discovery corpus

Evaluate extraction and retrieval without publishing information from real legal matters.

Constraints
  • No real documents or personal data
  • Repeatable evaluation
  • Evidence must remain inspectable
Alternatives
  • Private matter data
  • Unlabeled public documents
Criteria
Safe to publish / Fictional / Reproducible / Suitable for gold-label evaluation
Selected
Templated synthetic documents, people, companies, events, and amounts
Why
A controlled corpus makes extraction and retrieval behavior measurable while keeping the public boundary explicit.
Trade-off
Synthetic records cannot establish performance on the language, scale, or ambiguity of real discovery matters.
What supported it
Entity extraction strict F1 is reported at 0.889 on the reproducible corpus.
Revisit when
Expand the corpus before making any claim about broader document or matter coverage.

Results and evaluation

Measured retrieval on a disclosed synthetic corpus.

0.929graph retrieval R@5 on the reproducible synthetic evaluation corpus
Method
The project reports retrieval and extraction metrics against its templated synthetic corpus.
Meaning
Within that disclosed evaluation boundary, relevant graph evidence appeared in the first five retrieved results at the reported rate.
Limitation
The result does not establish performance on real legal records, unseen matter types, production scale, or attorney work product.

Limitations and next steps

Useful evidence, bounded claims.

What this does not prove

  • All published documents, people, companies, amounts, and events are synthetic and fictional.
  • The evaluation describes a templated corpus and is not a claim about real legal matters.
  • Maintaining graph and vector stores together adds indexing and operational complexity.
  • A retrieved citation still requires human interpretation in the context of the investigation.

What I would do next

  1. Expand the synthetic corpus with harder entity, event, and relationship ambiguity.
  2. Measure the graph-only, vector-only, and hybrid paths separately before changing the retrieval mix.
  3. Define approved access, privacy, and matter-isolation controls before considering any real material.

This project demonstrates a connected investigation workflow without claiming behavior on real legal matters.

Explore the rest of the work