Foreword xiii
Preface xv
Acknowledgments xix
Introduction xxi
Part I From Traditional Information Retrieval to Modern RAG 1
1 Information Retrieval 3
1.1 Definition and Historical Evolution 3
1.2 Information Retrieval Components 14
1.3 Information Retrieval Applications 34
1.4 Challenges with IR Systems 45
1.5 Summary 46
2 Large Language Models 49
2.1 LLMs Overview 49
2.2 LLM Use Case in Information Retrieval 91
2.3 Challenges of LLMs for Information Retrieval 108
2.4 Summary 119
3 Retrieval-augmented Generation 123
3.1 RAG Overview 123
3.2 Data Preparation and Indexing 126
3.3 Retrieval Approaches 139
3.4 Generation 148
3.5 Summary 153
4 Practice: RAG Implementation 157
4.1 Overview of LangChain and LlamaIndex 157
4.2 Implementing RAG Pipelines with LlamaIndex 159
4.3 Example: Implementing RAG on the WANDS Dataset 175
4.4 Implementing Agentic RAG 189
4.5 Summary 195
Part II Graphs and Knowledge Graphs 197
5 Graphs and Graph Databases 199
5.1 Introduction to Graphs 199
5.2 Graph Databases: Comparison and Analysis 217
5.3 Introduction to Neo4j and Cypher 221
5.4 Practice: Flight Network Analysis and Optimization 228
5.5 Summary 244
6 Knowledge Graphs 247
6.1 Understanding KGs 247
6.2 Construction and Management of KGs 261
6.3 KGs Analytics and Enrichment 268
6.4 LLMs and KGs 287
6.5 Practice: Constructing KG from the WANDS Dataset 293
6.6 Practice: Construct KG from Unstructured Data 301
6.7 Summary 303
Part III Integrate RAG with Graph 307
7 Graph-based Retrieval-augmented Generation 309
7.1 Introduction to Graph-RAG 309
7.2 Architecture and Components of Graph-RAG 315
7.3 Applications 337
7.4 Summary 340
8 Practice: Graph-RAG Implementations 345
8.1 Graph-RAG on WANDS Dataset with LlamaIndex 345
8.2 Graph-RAG on Wiki and Kaggle Data with LangChain 352
8.3 Summary 364
9 Graph-RAG Evaluations 367
9.1 Performance Metrics Framework 367
9.2 Quality Assessment Methodologies 382
9.3 Benchmarking Frameworks 392
9.4 Tools and Platforms for Graph-RAG Evaluations 396
9.5 Practice: Evaluating RAG Pipelines Using Ragas 400
9.6 Summary 402
Part IV Advanced Implementations and Frontiers 405
10 Graph-RAG Frameworks for Enhanced Information Retrieval 407
10.1 Overview of Graph-RAG Frameworks for Search and Recommendations 407
10.2 Graph-RAG Tools and Softwares Overview 421
10.3 Practice: Run Graph-RAG Frameworks 424
10.4 Summary 453
11 Frontiers of Graph-RAG 455
11.1 Emerging Trends in Graph-RAG 455
11.2 Ethical Considerations and Bias Mitigation 478
11.3 Future Research Directions 482
11.4 Summary 490
11.5 Conclusion and Final Thoughts 491
A Set Up Experiment Servers 495
A.1 Two Models Hosted by vLLM 497
A.2 LLM Gateway 499
A.3 UI for LLM Models 500
A.4 Vector Store 500
A.5 Graph Database 501
B Prepare Synthetic Recommendation Data from WANDS 503
B.1 Step 1: Download the WANDS Dataset 503
B.2 Step 2: Load the Dataset 503
B.3 Step 3: Prepare the Data for Recommendation Tasks 504
B.4 Step 4: Generate Synthetic Recommendation Data 504
B.5 Step 5: Dataset Statistics and Sample Entries 509
Index 511