liveBook · Manning

Chapter 3: Advanced vector retrieval strategies

What you will learn in chapter 3 of Essential GraphRAG

This chapter introduction motivates improving a basic RAG retriever with query rewriting and advanced document-embedding strategies to retrieve more relevant, complete context for answer generation.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This chapter introduction motivates improving a basic RAG retriever with query rewriting and advanced document-embedding strategies to retrieve more relevant, complete context for answer generation.

Key terms: query rewriting, step-back prompting, retrieval accuracy, recall, hypothetical question–embedding strategy, parent document–embedding strategy, parent document, child chunks, nearest neighbors, averaging

3.1 Step-back prompting

This section shows how step-back prompting uses an LLM to rewrite detailed questions into broader queries that can improve vector retrieval.

Key terms: step-back prompting, query rewriting, vector retrieval, step-back question, system prompt, LLM, zero-shot prompting, few-shot prompting, examples, paraphrasing behavior

3.2 Parent document retriever

This section prepares a parent-document retrieval structure by hierarchically chunking a PDF, embedding child chunks, and importing the resulting graph into Neo4j.

Key terms: parent document retriever, parent documents, child documents, embedding, PDF node, Parent node, split_text_by_titles, regular expression, sections, tiktoken

3.2.1 Retrieving parent document strategy data

This section implements parent-document retrieval by searching child-node vectors, deduplicating their parents, and returning a final set of relevant documents.

Key terms: Cypher statement, vector-based search, child nodes, question embedding, parent documents, final k limit, k * 4, initial vector search, deduplicate, unique parent documents

3.3 Complete RAG pipeline

This section combines step-back prompting, parent document retrieval, and LLM answer generation into a complete RAG pipeline and suggests testing its impact.

Key terms: rag_pipeline, step-back prompt, parent document retrieval, original question, LLM, final answer, step-back prompting, Einstein's life, PDF

3.4 Summary

This summary recaps advanced vector-retrieval strategies that improve query-document alignment and retrieve more relevant context for RAG answers.

Where this is used later

Concepts explained in this chapter

← Chapter 2: Vector similarity search and hybrid search Chapter 4: Generating Cypher queries from natural language questions →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.