Repository navigation
Use cases for data pipelines with LLMs and Structured data sources #18
Replies: 1 comment
|
A pattern that works well is to treat the LLM as a planner over a semantic layer rather than as a direct SQL generator. Context mismatch: Don't hand the model the raw schema and expect it to guess. Build a small schema catalog — table/column names, descriptions, units, enum values and a few representative rows — and retrieve only the entries relevant to the current question before prompting. A business glossary that maps domain jargon to physical columns closes most of the gap, and a few few-shot (question -> SQL) pairs anchored in real terminology help more than generic instructions. Entity ignorance: Resolve entities before generating SQL. Give the model an entity catalog/knowledge graph mapping natural-language mentions to canonical keys (account IDs, SKUs, customer IDs), then have it emit those canonical identifiers rather than free-text names. Fuzzy or embedding lookup over that catalog handles typos and aliases, and the final SQL should always filter on resolved IDs. Compositionality: Use plan-then-execute: decompose the question into sub-questions, retrieve the schema slice for each, generate and validate one SQL fragment per step, then join the results in code. Constrain generation with a SQL grammar/structured decoding, dry-run or EXPLAIN each statement, and feed execution errors back for one repair pass. That keeps each generated query small and composable instead of asking for one monolithic, brittle statement. In a Pathway llm-app pipeline these steps are just UDFs over a schema/entity catalog kept as an input table, so they stay current as the database changes. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was initially posted in a reddit discussion below:https://www.reddit.com/r/dataengineering/comments/156ltst/use_cases_for_llms_on_structured_data_sourced/
Does anybody have use cases around data pipelines for LLMs and structured data sources? If so how do you deal with the following :
Context mismatch - since enterprise databases have very specific schemas and terminology that the LLM is unaware of, how do you prevent misunderstanding?
Entity ignorance - entities are a relational db terminology but how do you get that into the LLM world?
Compositionality - LLMs lean towards a holistic view, and our database queries require hierarchical, compositional views. How do you deal with this?
All reactions