Sitemap
AI Mind

Learn, explore, or build the future of AI with top stories on the latest trends, tools, and technology. Share your crazy success stories or AI-fueled fails in a supportive community.

Graph-First Financial AI: Why Your LLM Needs Structural Context in Excel

Why Graph Theory is the Missing Link Between Excel and Agentic Reasoning

7 min readJan 26, 2026

--

Press enter or click to view image in full size
Snapshot of showing an Excel file as graph
Excel as graph (photo by author)

The current paradigm for applying LLMs to financial spreadsheets often relies on inefficient methods: uploading entire binary files, sampling raw data rows, or utilizing vector embeddings. Each of these approaches fails to capture the essential “physics” of a financial model: its dependency structure. While the market now offers various tools with improved Excel readability, many remain ‘black-box’ solutions that lack the transparency or API-first architecture required for seamless integration into custom business pipelines.

In this article, I argue that these traditional workflows provide insufficient context for complex reasoning. I propose an alternative architecture where the spreadsheet is parsed into a deterministic Directed Acyclic Graph (DAG) before inference. By calculating “Structural Reach” using Breadth-First Search (BFS), we can inject high-value causal metadata into the LLM’s context window. This method significantly outperforms binary analysis and vector search in both accuracy and token efficiency, transforming the AI from a passive reader of data into an active auditor of logic.

1. The Limitations of Current Workflows

When attempting to analyze complex Excel models with AI, developers typically resort to three common patterns, each with critical flaws:

1.1 The “File Upload” (Binary Analysis)

Users upload the full .xlsx binary to an LLM's code interpreter environment.

The Bottleneck: While .xlsx is technically a collection of XMLs, most LLMs treat it as an opaque binary blob. The model must write and execute Python code (e.g., using pandas or openpyxl) to "see" the data. This is slow, expensive, error-prone, and often results in shallow analysis. The AI sees the result of the calculations (the values) but rarely effectively parses the logic (the formulas) across multiple sheets without extensive, fragile scripting.

The Context Gap: The model struggles to differentiate between a hard-coded input and a calculated output and understanding how different values relate to each other. To the interpreter, they are just numbers in a dataframe.

1.2 Sample Data / Snapshots

Developers extract the first n rows or a random sample of data and paste it into the prompt.

The “Bag of Numbers” Problem: This completely destroys structural context. If the AI sees Row 5 but not Row 100 which depends on it, it cannot trace causality. It leads to descriptive hallucination and the AI summarizes the visible numbers but cannot trace and explain why they changed in the same way an experienced analyst would.

1.3 Vector Embeddings (Standard RAG)

Spreadsheet rows are chunked, embedded, and stored in a vector database.

The Semantic Trap: Vector search relies on semantic similarity (textual relatedness). In finance, “Revenue” and “Cost” are semantically distinct, but structurally inseparable. A vector search for “Profit drivers” might retrieve the “Profit” row but miss the “Unit Price” assumption buried in a different sheet that actually drives the profit. Mathematical dependency is not semantic similarity.

2. The Proposed Approach: Deterministic Graph Contextualization

To provide true understanding, we must shift from data-centric context to structure-centric context. I propose treating the spreadsheet not as a table, but as a system of equations represented as a Graph.

2.1 Graph Construction

We parse the spreadsheet into a Directed Acyclic Graph (DAG) G=(V,E), where V represents the set of all cells containing data or formulas, and E represents the dependencies.

  • Nodes (V): Every cell in the workbook.
  • Edges (E): Directional links where if Cell A’s formula contains =B1, an edge exists from B1→A.

This graph is built locally and deterministically using formula parsing, independent of the AI.

2.2 Algorithmic “Reach” Scoring

Once the graph is built, we need to filter the signal from the noise. In a model with 50,000 cells, which 10 matter? We can answer this using a two-phase graph traversal algorithm to calculate a Structural Reach Score.

Phase 1: Identifying Roots via Back-Tracing

First, we must find the origins of the logic. We scan the graph for any cell that has dependents (outgoing edges) and trace it backwards recursively until we hit a “Root” node — a cell with no parents (indegree = 0) or one that resides on a designated “Input” or “Assumptions” sheet.

Let P(n) be the set of parents for node n. A node r is a Root if P(r)=∅ or if r∈AssumptionsSheet.

Phase 2: Calculating Reach via Breadth-First Search (BFS)

For every identified Root node r, we quantify its influence by calculating the size of its transitive closure (the set of all downstream nodes reachable from it).

We employ a standard BFS traversal:

  1. Initialize: Create a queue Q=[r] and a set of visited nodes V={r}.
  2. Iterate: While Q is not empty:
    - Dequeue node u.
    - Find all direct children C(u) from the adjacency list.
    - For each child v∈C(u):
    — If v∈/V, mark v as visited (V←V∪{v}) and enqueue v.
  3. Score: The Reach Score is ∣V∣−1 (the total number of unique descendants excluding the root itself).

The Insight:

Get Arsalan Pardesi’s stories in your inbox

Join Medium for free to get updates from this writer.

This score is a mathematically rigorous proxy for business importance. A cell with a Reach Score of 1,200 is objectively a “Key Driver”, changing it ripples through 1,200 other calculations. A cell with a Reach Score of 5 is a local helper. A cell with a Reach Score of 0 is a final Output (a Sink).

By sorting input candidates by their Reach Score, we can mathematically isolate the top n “load-bearing” assumptions in the entire model before the AI even looks at a single number.

3. The “Graph-Enriched” Prompt

Instead of feeding the LLM raw rows or binary files, we feed it the Metadata of Logic.

Comparison of Inputs:

  • Standard Approach (Raw Data):
    “Input: 5.0. Input: 0.25.” (The AI has no idea what these represent or their importance.)
  • Graph Approach (Structured Context):
    “Key Driver Identified: ‘Revenue Growth Rate’ (Value: 5.0).
    Significance: High. This input structurally drives 1,240 downstream cells.
    Impacts: It is a direct precedent for ‘Net Income’ and ‘EBITDA’.”

4. Results: Descriptive vs. Diagnostic

To demonstrate the efficacy of this approach, I ran the exact same Real Estate Financial Model through both a standard "File Upload" workflow and my Graph-First pipeline. The difference in insight is stark.

4.1 The Binary Approach

When I uploaded the full Excel file to a leading LLM, the model acted like a Librarian. It could read the book’s cover and table of contents, but it couldn’t understand the plot.

AI Output:

“The attached Excel file is a professional real estate financial model. It is designed to project financial performance, debt schedules, and investment returns over a multi-year period (specifically from 2014 to 2026). The workbook serves as a ‘presentation model,’ likely used to showcase the financial feasibility or historical/projected performance of a real estate asset or entity.”

While accurate, this is purely descriptive. It tells me what the file is, but not what matters. It deduced the purpose by reading file extensions (.xlsm) and sheet names ("Assumptions", "Loan"). It lacks specific business insight. It is effectively a generic summary that could apply to any real estate model.

4.2 The Graph-Enriched Approach

When I pre-processed the file into a Dependency Graph and fed the “Reach Scores” and “Flows” to the model, it acted like an analyst. It ignored the file format and focused on the levers.

AI Output:

“This financial model serves as a development pro forma and valuation tool for a large-scale real estate asset, focusing on the lifecycle from construction through to stabilized residential operations. The selection of critical drivers reflects the core pillars of project feasibility: capital expenditure, capital structure, revenue stabilization, and the cost of capital. ’Hard Construction Costs’ (Assumptions!D22) is the primary driver for total capitalized costs, setting the baseline for the entire investment. ’Equity’ (Assumptions!F151) defines the funding mix and leverage levels, which determines the debt service burden. ’Normalization Year Occupancy’ (Assumptions!F46) is the pivotal revenue assumption that dictates the asset’s terminal value and long-term yield. The ‘Interest Rate (Loan!F10) acts as a critical sensitivity for both financing costs and the Net Present Value (NPV) calculation. Finally, the ‘Construction Management Fee’ (Assumptions!F134) represents a key soft cost driver that impacts the total funding requirement and project profitability.”

The disparity in output is significant. By providing the LLM with the ‘structural skeleton’ of the Excel model, we shift the AI’s role to that of an analyst.

  • Causality: It doesn’t just list “Occupancy” as an input; it explains that it dictates the “Terminal Value.”
  • Precision: It pinpoints specific cells (Assumptions!D22) as the "primary driver" because the Reach Score confirmed it impacts the most downstream cells.
  • Business Logic: It connects “Equity” to “Debt Service Burden” — a relationship it inferred because the graph showed a link between the Equity input and the Loan sheet calculations.

Using our Graph based context approach, we moved from a generic file summary to specific and analyst level understanding of the model.

5. Conclusion

Financial Analysis is an exercise in understanding causality, not just observing values. Traditional AI workflows (Binary, Sampling, Embeddings) strip away this causality. By injecting deterministic graph algorithms , specifically BFS-based Reach Scoring, into the pipeline before the prompt is constructed, we provide LLMs with the one thing they cannot infer reliably: the deterministic ground truth of the model’s architecture. This approach yields higher accuracy, lower hallucination, and vastly improved token efficiency.

I incorporate this graph based approach into an Excel utility. See the full demo below — the complete context based on the full graph is towards the end of the video.

Video Demo — Excel Atlas utility

If you found this interesting, please share and follow me on Medium and LinkedIn to stay connected.

A Message from AI Mind

Thanks for being a part of our community! Before you go:

--

--

Arsalan Pardesi
Arsalan Pardesi

Written by Arsalan Pardesi

Strategy & Transactions professional — Writes about SaaS, diligence, value creation, growth strategies, data analytics and ML.

AI Mind
AI Mind

Published in AI Mind

Learn, explore, or build the future of AI with top stories on the latest trends, tools, and technology. Share your crazy success stories or AI-fueled fails in a supportive community.