What is text-to-SQL? Natural language queries with LLMs
Text-to-SQL uses an LLM to turn a plain-English question into a SQL query for your database. How it works, the benchmarks, and the guardrails, with Python.
Tags
14 posts tagged
Text-to-SQL uses an LLM to turn a plain-English question into a SQL query for your database. How it works, the benchmarks, and the guardrails, with Python.
Agentic RAG puts retrieval inside an agent loop: the model decides when to search, grades results and rewrites queries. How it works, with a Python demo.
Reciprocal rank fusion (RRF) merges ranked lists by summing 1/(k + rank) for each document. Why k = 60, why it beats adding scores, with runnable Python.
Hybrid RAG combines keyword (BM25) and vector search, then fuses the rankings. Why each misses what the other finds, and how to fuse them, with runnable Python.
Contextual retrieval prepends an LLM-written note on where each chunk sits in its document before indexing, cutting RAG retrieval failures. With Python.
RAG chunking strategies decide how documents are split before embedding. Fixed-size, recursive, structure-aware and semantic chunking compared, with Python.
RAG vs long context: 1M-token windows can hold a whole corpus, but cost, latency and lost-in-the-middle effects still favor retrieval. Research and cost math.
GraphRAG builds a knowledge graph and community summaries from your documents so an LLM can answer whole-corpus questions. How it works, with a Python demo.
Reranking rescores a retriever's shortlist with a cross-encoder that reads the query and each document together. Why it beats embeddings alone, with Python.
BM25 ranks documents by how often query terms appear, how rare they are and how long the document is. The formula, k1 and b, with a from-scratch Python demo.
RAG vs fine-tuning: RAG gives a model facts at query time, fine-tuning changes its behavior. What the research says, what each costs, and when to use which.
How to evaluate RAG: measure retrieval with recall@k, MRR and nDCG, and answers with faithfulness and relevance. The metrics explained, with runnable Python.
HyDE (hypothetical document embeddings) has an LLM write a fake answer, then searches with its embedding. How HyDE and query rewriting work, in Python.
RAG (retrieval-augmented generation) fetches relevant text from your data and puts it in the prompt so the LLM answers from it. How it works, in Python.