KDD 2025 · AAE Workshop · Paper Digest

Enterprise Text-to-SQL

A full engineering account of LinkedIn's internal Text-to-SQL chatbot: knowledge-graph backbone plus a Researcher Agent for fixing hallucinations, achieving 53% expert-rated correctness and 300+ weekly active users on a data lake with millions of tables.

Enterprise Text-to-SQL Knowledge Graph Researcher Agent Multi-Agent UI Trino SQL LinkedIn Production

Albert Chen, Manas Bundele, Gaurav Ahlawat, Patrick Stetz, Zhitao Wang and 13 more · LinkedIn · arXiv:2507.14372

SECTION 01

Problem Statement — Spider 90% does not mean enterprise-ready

Spider/BIRD execution accuracy has climbed from 54% to over 90%, but those numbers collapse the moment you move to a real enterprise data lake. LinkedIn set out to build a SQL assistant any employee at the company could use — and this paper is the full engineering write-up of that journey.

1.1 Why academic benchmarks don't carry over

Spider 1.0

90%+

SOTA execution accuracy as of Nov 2023 — looks essentially solved.

BIRD

76%

Best score as of Apr 2025. Sits between usable and unusable.

Spider 2.0

31%

Apr 2025 SOTA is only 31%. Ground truth queries are over 100 lines on tables with 1000+ columns. The realistic enterprise benchmark.

Even Uber's internal QueryGPT only reports roughly 50% overlap on ground-truth tables on their own eval set. In short, slapping a fine-tuned LLM on top of a schema is not enough.

1.2 Four challenges specific to LinkedIn

Schema scale explosion

The data lake contains millions of tables, with popular tables reaching 100+ columns. Tables get deprecated regularly and many overlap in content — the model must first pick the right table to do anything useful.

Same words, different meanings (personalization)

"Latest click-through rate" means something completely different to a notifications team vs a search team. The model must integrate user / product-area context to interpret correctly.

Business jargon and acronyms

The company has its own acronyms and terms invisible to any public corpus — they must be mined from wikis, code repos, and historical queries.

Auxiliary tasks

Users don't only want SQL — they want the chatbot to find tables, explain queries, and debug. "Text-to-SQL" is only one part of the chat experience.

The paper's three contributions: ① a knowledge graph that fuses schemas, code repos, query logs, wikis, jargon, and crowdsourced domain knowledge, with ICA to auto-cluster tables into product areas; ② a Query Writer Agent with multi-stage retrieval + ranking, plus a Researcher Agent that dynamically retrieves new tables during fix-up to resolve hallucinations; ③ a Multi-Agent UI that routes intents — query writing / data finding / query fixing / Q&A — to keep follow-ups smooth.

"To our knowledge, this paper is the first detailed presentation of an enterprise Text-to-SQL solution."

SECTION 02

Three-Layer Architecture

Bottom-up: Knowledge Graph (semantic foundation) → Query Writer Agent (the SQL-generating core agent) → Multi-Agent Chat UI (user interface and intent routing). Data flow between the three layers is shown below.

LAYER 3 · MULTI-AGENT CHAT UI User Question + chat history Intent Classifier route by intent Query Writer write query Data Finder suggest tables Query Fixer / Q&A debug / answer LAYER 2 · QUERY WRITER AGENT (4 steps) ① Retrieve Context EBR + examples + user mentions K_ret = 20 ② Rank Context table ranker LLM column ranker LLM K_rnk = 7 ③ Write Query tables + columns + examples + jargon gpt-4o ④ Validate & Fix Trino EXPLAIN VALIDATE + Researcher Agent retry ≤ 2 times LAYER 1 · KNOWLEDGE GRAPH (5 indexes) Table/Column Index Usage Index Table Cluster Index Example Query Index Domain Knowledge + Jargon feeds Query Writer
Figure 1 · LinkedIn Enterprise Text-to-SQL three-layer architecture (synthesized from paper Figures 1–3)

Each layer in the diagram is expanded in the sections that follow. Three keywords to anchor on: the knowledge graph provides semantics, the Query Writer Agent turns semantics into SQL, and the multi-agent UI handles everything that isn't strictly T2S.

SECTION 03

Knowledge Graph — Wiring enterprise semantics into a graph

The central node of the knowledge graph is the Table: from a table you can find its columns, common joins, example queries, domain-knowledge records, and the user groups with read permission. The other organizing node is the Product Area, which ties tables to teams.

3.1 Node attributes (Table 1)

Table 1 · Attributes of the table / column nodes in the Knowledge Graph
NodeAttributes
Table Database Name, Table Name, Human Description, AI Description, Usage Popularity, Table Cluster, Tags, Certification Status, Deprecation Status
Column Database Name, Table Name, Column Name, Human Description, AI Description, Usage Popularity, Top Values, Data Type, Column Type (metric/dimension/attribute), Is Partition Key

Key design choices: Certification Status flags governance-approved high-quality tables; Column Type distinguishes metrics, dimensions, and attributes so the LLM knows what a column is. When no human description exists, Glean Chat API auto-generates an AI description.

3.2 The five indexes (§2.1.2)

Table / Column Index

Source: DataHub. Embeddings cover table name + description + tags. Supports EBR plus lookup by name or product area. Refreshed weekly.

Usage Index

Parses EXPLAIN plans (JSON) from successful Trino queries to aggregate popularity and common joins. Refreshed weekly.

Table Cluster Index

A list of relevant datasets per user (see §04 ICA clustering). Refreshed weekly.

Example Query Index

Human-authored queries from code repos and wikis. Wiki descriptions are embedded directly; code repo queries get auto-descriptions via gpt-35-turbo before embedding. Filters: creation date, execution count, filename, and whether the user has certified the query.

Domain Knowledge Index

User-submitted product background, data explanations, and personal preferences, gathered in the chatbot UI. Refreshed instantly (a user submission takes effect immediately).

Jargon Map

Source: company wiki. Stored as {jargon → explanation}; pulled at query time via string matching and appended to the LLM prompt.

Key distributed-design choice: different indexes have different refresh cadences — domain knowledge is instant while others are weekly — so user-contributed annotations pay off immediately. This is the "user contributes → system improves → user contributes more" flywheel.

SECTION 04

ICA Table Clustering — Picking each team's usual tables out of millions

Millions of tables cannot be fed to an LLM. LinkedIn takes a user-table access matrix from three months of query history and runs Independent Component Analysis (ICA) for soft clustering, mapping each user and product area to its most relevant table subset.

4.1 Pipeline (Algorithm 1)

Filter out low-frequency tables

Drop tables with too few total accesses or unique users — e.g. intermediate tables produced by data pipelines that no one queries directly.

Standardize the matrix

Standardize across the user dimension (mean=0, std=1) so that a few heavy users don't dominate.

Run FastICA

Use sklearn.decomposition.FastICA with N_comp = 200 components. Each component corresponds to one access pattern — typically a particular product team's working habits.

Soft clustering

For each component, take the top T_c = 20 tables by absolute score. A single table can belong to multiple clusters — soft clustering is the key.

Map users / teams to clusters

For each user, sum their access counts per component and take the top components. For product areas, vote across the clusters of representative employees in the team email group, breaking ties by cluster access count.

4.2 Why ICA instead of K-means?

K-means is hard clustering — a table can only go to one cluster, but in reality a member table might be used by growth, ads, and search at once as a "shared table". ICA's soft clustering lets shared tables naturally show up in multiple clusters, and when a team disbands or a table is deprecated, simply rerunning the weekly job re-assigns everything automatically.

Throughput: the whole clustering pipeline has a P90 runtime of 15 minutes. Rerunning weekly is not a system bottleneck.

4.3 Candidate-table assembly (Algorithm 4)

function GetCandidateTables(user, product_areas):
    user_clusters        = GetUserGroupClusters(user)
    product_email_groups = GetEmailGroups(product_areas)
    representative_users = GetEmployees(product_email_groups)
    product_area_clusters = GetUserGroupClusters(representative_users)
    clusters             = merge(user_clusters, product_area_clusters)

    inferred_tables = GetExtendedTables(clusters)
    explicit_tables = GetExplicitTables(product_areas)

    return merge(inferred_tables, explicit_tables)

At the start of every chat session, this function flattens all clusters corresponding to the user + selected product areas and adds in manually-curated explicit tables — defining the search scope for the subsequent EBR. Long-tail tables outside this set are dynamically pulled in via in-chat follow-up.

SECTION 05

Query Writer Agent — 4 steps to generate SQL

Implemented in langchain. Inputs: question, user name, list of product areas. Output: a dict containing the SQL, an explanation, the tables/columns used, and assumptions for the user to verify.

5.1 Step 1 — Retrieve Context

Goal: high recall. First the candidate-table list from §04 bounds the search space, then we pull from three sources:

  1. EBR with user question — query the table index with the question's embedding; results restricted to candidate tables.
  2. Tables in retrieved examples — first retrieve example queries similar to the user's question, then extract the tables those examples use.
  3. Tables in user question — pick up any table names the user explicitly mentioned — this path is NOT restricted to the candidate set; if the user wants it, use it.

The three combined produce K_ret = 20 tables, then we fetch all their columns, plus the product area's domain knowledge and jargon entries.

5.2 Step 2 — Rank Context (Table Ranker + Column Ranker)

An LLM trims 20 tables down to K_rnk = 7. The Table Ranker LLM scores each table 1–10 with explanations, using:

A notable callout from the authors: feeding the table schema to the ranker actually hurt recall and increased latency, so schemas are omitted here.

The Column Ranker then selects columns from the top 7 tables into two tiers: relevant and potentially relevant. Including the second tier improves recall. Each table is rendered as a CREATE TABLE statement with columns ordered by usage popularity.

5.3 Step 3 — Write Query

The selected tables + columns + relevance scores and explanations + examples + domain knowledge + jargon all get packed into the prompt. The Query Writer LLM (gpt-4o) returns:

{
  "assumptions": [...],   # for the user to verify
  "query": "SELECT ...",
  "explanation": "...",
  "tables": [...],
  "columns": [...]
}

5.4 Step 4 — Validate & Fix (Researcher Agent enters)

The query validation loop runs at most twice, handling two error categories:

Syntax / compilation errors

Validated via Trino EXPLAIN VALIDATE. The error message is fed straight back to a fixer LLM.

Table / column hallucination

A separate custom hallucination validator catches all non-existent tables/columns in one pass (Trino EXPLAIN only returns one error at a time). This kind of error usually means the context lacked the right table, so a new round of retrieval is needed — Researcher Agent's cue.

5.5 Researcher LLM Agent

The Researcher is a self-reflecting agent built specifically for hallucination resolution. It has tools to search tables, fetch table schemas, and fetch metadata. For instance, it can search for the table most similar to a hallucinated one.

Speed-tuning detail: the Researcher itself uses the faster gpt-4o-mini for search, but its self-reflection step uses the stronger gpt-4o. Output is "updated context + recommendation on what data to use", which is then passed to the query fixer LLM to rewrite the query.

5.6 Hyperparameters at a glance

K_ret

20

tables kept after retrieval

K_rnk

7

tables passed to writer after ranking

Validation loop

≤ 2

max two fix-up rounds

SECTION 06

Multi-Agent UI — The interface may matter more than the LLM

The biggest lesson the authors learned post-launch: users don't want Text-to-SQL — they want a general data assistant that can write queries, find tables, debug bugs, and answer any data question. That's why the system evolved into a multi-agent structure.

6.1 Intent classifier routes to four agents

Query Writer

The core agent — the full pipeline from §05.

Data Finder

Runs only the retrieve + rank stages of Query Writer, returning 7 suggested tables with metadata.

Query Fixer

Dedicated to debugging query execution failures (permissions, syntax, schema).

Question-Answering

All unsupported long-tail intents. Architecturally similar to Researcher Agent, with tools for schema lookup, wiki search, and query validation.

6.2 Speed tricks for the Q&A agent

The Q&A agent has the widest scope, so the authors use three speed-ups: ① evaluate question difficulty and skip self-reflection on simple ones; ② pre-fetch table metadata to avoid repeated tool calls; ③ both LLMs use gpt-4o-mini.

6.3 UI design highlights

Embedded in the existing SQL editor

The chatbot lives in the sidebar of the company's SQL editor — users never switch tools. A "Fix with AI" button appears automatically whenever a query execution fails.

Rich UI elements

Query output includes inline-commented SQL, validation results, an explanation, tables used, related reference queries, and assumptions to verify. Table output shows description, popularity, common joins, certification status, with checkboxes for users to pick which tables to use.

Quick-reply buttons

Suggested follow-ups appear above the chat box — users can keep the conversation moving without typing.

Users contribute knowledge back

The UI lets users add product areas, add domain knowledge, and certify example queries — all written straight into the knowledge graph, spinning the weekly flywheel.

Speed is critical. Multi-agent + state maintenance + intent classifier all stack latency. The production full model averages 60 seconds per reply — not fast, but acceptable for complex enterprise queries.

SECTION 07

Evaluation — Metrics and Ablations

The authors built an internal benchmark: 133 questions × 10 product areas × 167 ground-truth tables, with 60% of questions allowing multiple correct answers (multiple ground truths).

7.1 Three metric categories

Recall

Table recall and column recall — did the bot find the right tables and columns? For multi-ground-truth questions, use the ground truth with the highest overlap.

Quality

Overall score (1–5), compilation success rate, valid tables & columns rate. Both human eval and LLM-as-judge (gpt-4o) are used.

Latency

Number of LLM calls, EBR queries, DB queries — proxies for system complexity. Full model averages 60 seconds per question.

7.2 Scoring rubric (Figure 4)

Figure 4 · 5-point rubric for human / LLM-as-judge
ScoreDefinition
1Completely wrong; does not answer the question at all.
2Right tables but 90% of columns are wrong; does not answer the question.
3Right tables and most of the right columns, but has gaps requiring substantial effort or domain knowledge to fix; doesn't answer the question.
4Right tables and almost all right columns; minor issues a non-expert can fix (e.g. wrong date filter). Answers the question but may miss trivial details.
5Answers the question perfectly and completely.

7.3 Ablation study (Table 2) — full reproduction

Models: example embeddings use E5-large-v2, table/column embeddings use text-embedding-ada-002, Researcher LLM uses gpt-4o-mini-2024-07-18, other LLMs use gpt-4o-2024-05-13, temperature = 0, single run.

Table 2 · Ablation study (A.* = KG components, B.* = modeling components, C.* = both combined)
ConfigDescription Tab RecallCol Recall Score 4+Compile OKValid T&C LLMEBRDB
FullAll components78%56%48%96%99%4.63.09.4
A.5Full w/o popularity or joins77%53%42%95%98%4.83.08.4
A.4A.5 w/o domain knowledge or jargon76%52%49%96%99%4.73.08.5
A.3A.4 w/o example queries60%38%24%98%100%4.61.07.0
A.2A.3 w/o table or column attributes56%30%11%93%99%5.01.07.5
A.1A.2 w/o table clusters (schemas only)45%24%9%88%99%5.11.07.1
B.3Full w/o researcher agent75%53%47%95%98%4.33.09.5
B.2B.3 w/o query fixer76%55%47%76%85%4.03.08.4
B.1B.2 w/o rankers (EBR + writer only)67%50%46%66%77%2.03.07.1
C.4(A.4, B.3) combination76%52%46%97%98%4.33.08.6
C.3(A.3, B.2) combination60%37%20%77%87%4.01.06.1
C.2(A.2, B.1) combination49%27%17%68%83%2.01.05.0
C.1(A.1, B.1) combination37%23%16%67%81%1.91.03.9

7.4 Key observations

50% 40% 30% 10% 0% Score 4+ (%) A.1 9% A.2 11% A.3 24% A.4 ★ 49% A.5 42% Full 48% A.1 = schemas only; A.4 = + table clusters + attributes + examples; Full = everything
Figure 2 · Cumulative contribution of each KG component to "Score 4+" (redrawn from Table 2)

The Knowledge Graph drives "quality"

Score 4+ climbs from A.1's 9% to Full's 48%, with most of the lift from example queries (A.3→A.4: +25 pp), table clusters, and table/column attributes. Semantic understanding can only come from the KG.

Modeling components drive "correctness"

Compilation success rises from B.1's 66% to Full's 96%, valid T&C from 77% to 99%, largely from the query fixer and context rankers. But the score gain is small — modeling components can't fix semantic understanding.

Surprising finding: domain knowledge hurts quality

A.5 (with domain knowledge) achieves Score 4+ = 42%; A.4 (without) achieves 49%. The authors suspect "irrelevant domain knowledge records" cause interference.

C.4 is the "good enough" sweet spot

C.4 reaches Score 4+ = 46% (only 2 pp below Full) with fewer components (A.4 KG + B.3 modeling), and uses 4.3 LLM calls vs 4.6 and 8.6 DB queries vs 9.4 — cheaper with almost no quality loss.

SECTION 08

Production Numbers

The chatbot has been live since July 2024. Below are the real usage numbers at the time of writing (April 2025).

8.1 Adoption

WAU

300+

weekly active users

Power Users

100+

chat sessions per month

Weekly retention

20%

this-week actives who return next week

Code pasted to editor

33%

of sessions end with code in the SQL editor

8.2 Expert review

Domain experts from each of the 10 product areas rated the production version, returning ratings for 124 of 133 questions:

Score 4+ (correct / close)

53%

experts judged "correct" or "minor fix"

Score 3+

77%

"helpful for identifying tables and columns"

Top error: Filter

24%

filter condition wrong; incorrect join only 4%.

8.3 User satisfaction survey

"Very good" or "Excellent": 39% — "very good, requires only minor modifications" or "excellent, queries are correct".

"Passes" or better: 95% — "at least requires some modifications" but usable.

SECTION 09

Negative Results — Academic tricks that didn't work here

This section is the most valuable part of the paper. The authors tried three mainstream academic techniques, and all three failed in the LinkedIn setting. Free lessons for anyone building enterprise T2S.

9.1 Multi-query + Self-Consistency: dies without query execution

The academic recipe is to generate multiple queries and pick the most self-consistent (e.g. CHASE-SQL, CHESS). But in an enterprise setting:

A workaround (generating up to 3 ways to write the query as a kind of CoT) did not improve recall. The authors' conclusion: self-consistency's effectiveness comes from input shuffling AND actual execution — neither can be skipped.

9.2 Query Planner LLM Decomposition: smaller subtasks make things worse

Following DIN-SQL — use a planner LLM to break the question into subtasks solved iteratively. Result:

Even when they constrained the planner to "minimize the number of tasks" with few-shot examples, it still failed. The hypothesis: gpt-4o is strong enough on its own that task decomposition only constrains its solution space — smaller models may need it, but gpt-4o doesn't.

9.3 Using planner subtasks for query expansion: no EBR gain

Use the planner's subtasks as query strings for retrieval (a form of query expansion). The result: no improvement in EBR table recall. The authors speculate that a prompt explicitly designed for query expansion might work, but the subtask format isn't quite right.

Free lessons for anyone building enterprise T2S: academic SOTA tricks (multi-path generation, self-consistency, task decomposition) often don't transfer to production systems — not because the tricks are wrong, but because (1) you can't execute queries, (2) you can't make users wait 5 minutes, (3) your base model may already be stronger than the academic-setup model. Investing in the KG and retrieval usually pays off more than model-side tricks.

SECTION 10

Conclusion & Takeaways

The authors claim this is the first publicly available, fully detailed enterprise Text-to-SQL paper. Required reading for any team building an internal SQL chatbot.

10.1 Quantitative summary

Score 4+

9% → 49%

schemas only → Full KG

Table Recall

37% → 78%

C.1 → Full

Hallucination

23% → 1%

schema hallucination rate

Compilation error

34% → 4%

SQL compile failure rate

10.2 Caveats the paper doesn't dwell on but are worth noting

The eval set is only 133 questions, all written and scored by the same domain experts — sample size is small and selection bias is real, so it's not directly comparable to Spider/BIRD.

Production WAU of 300+ is only ~2% of LinkedIn's ~14k headcount. The authors don't discuss why broader adoption hasn't happened yet — likely the 60-second latency and 53% correctness are still adoption barriers.

All experiments are single runs at temperature 0, so they're reproducible but offer no variance estimate for the J metric.

④ The negative results sit in the appendix, but for practitioners they may be more valuable than the positive results.