Skip to content

Extract markdown links as first-class edges #951

Open

Description

@chris-boson

Problem

When processing a corpus of interlinked markdown documents, Graphify's semantic extraction relies entirely on the LLM to infer relationships. However, markdown files often contain explicit, human-authored links ([text](path.md)) that represent high-confidence relationships between documents.

In our test with 1,256 Intercom help articles:

  • 2,905 nodes extracted, but 1,636 (56%) are isolated (≤1 connection)
  • Many of these articles link to each other via standard markdown links
  • The LLM-based extraction misses these because it focuses on conceptual entity extraction, not syntactic link parsing

These human-authored links are arguably the highest-quality relationship signal in a documentation corpus — someone deliberately said "this article relates to that article."

Proposed Solution

Add a deterministic pre-pass that extracts markdown links as edges before/alongside LLM semantic extraction:

  1. Regex/parser scan of all .md files for:

    • Standard links: [link text](relative/path.md)
    • Wikilinks: [[page-name]] (if applicable)
    • Relative URL references between files in the corpus
  2. Emit edges with the existing schema:

    {
      "source": "article_a_id",
      "target": "article_b_id",
      "relation": "links_to",
      "confidence": "EXTRACTED",
      "confidence_score": 1.0,
      "source_file": "path/to/a.md",
      "source_location": "line or section where link appears"
    }
  3. Merge these edges into the graph in the same step where AST and semantic results are combined.

Design Considerations

  • Link resolution: Relative paths need to resolve to actual files in the corpus. Unresolvable links (external URLs, broken references) could either be skipped or emitted with a lower confidence score.
  • Link text as context: The anchor text ([this text here](...)) often describes the relationship — could be stored as edge metadata.
  • Bidirectionality: A link from A→B is directional, but you might optionally infer a linked_from back-edge.
  • Deduplication: If the LLM also infers a relationship between the same two documents, the deterministic edge should take precedence (higher confidence).
  • New relation type: links_to would join the existing set (references, cites, conceptually_related_to, etc.).

Impact

For documentation-heavy corpora (help centers, wikis, technical docs), this could dramatically reduce isolated nodes and improve community detection quality — connecting clusters that the LLM extraction treats as separate because it processes files in batches without cross-file link awareness.

Prior Art

This is analogous to how the AST extraction handles imports in code — deterministic, structural relationships that don't need an LLM to identify.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions