E-Book, Englisch, 350 Seiten
Reihe: Packt Publishing
Bourne, Keith / Es, Shahul Unlocking Data with Generative AI and RAG
1. Auflage 2025
ISBN: 978-1-83588-791-2
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection
Enhance generative AI systems by integrating internal data with large language models using RAG
E-Book, Englisch, 350 Seiten
Reihe: Packt Publishing
ISBN: 978-1-83588-791-2
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection
Generative AI is helping organizations tap into their data in new ways, with RAG combining the strengths of LLMs with internal data for more intelligent and relevant AI applications. The author harnesses his decade of ML experience in this book to equip you with the strategic insights and technical expertise needed when using RAG to drive transformative outcomes.
The book explores RAG's role in enhancing organizational operations by blending theoretical foundations with practical techniques. You'll work with detailed coding examples using tools such as LangChain and Chroma's vector database to gain hands-on experience in integrating RAG into AI systems. The chapters contain real-world case studies and sample applications that highlight RAG's diverse use cases, from search engines to chatbots. You'll learn proven methods for managing vector databases, optimizing data retrieval, effective prompt engineering, and quantitatively evaluating performance. The book also takes you through advanced integrations of RAG with cutting-edge AI agents and emerging non-LLM technologies.
By the end of this book, you'll be able to successfully deploy RAG in business settings, address common challenges, and push the boundaries of what's possible with this revolutionary AI technique.
*Email sign-up and proof of purchase required
Weitere Infos & Material
Preface
In the rapidly evolving landscape of artificial intelligence (AI), retrieval-augmented generation (RAG) has emerged as a groundbreaking technology that is transforming the way we interact with and leverage AI systems. RAG combines the strengths of information retrieval and generative AI models to create powerful applications that can access and utilize vast amounts of data to generate highly accurate, contextually relevant, and informative responses.
As AI continues to permeate various industries and domains, understanding and mastering RAG has become increasingly crucial for developers, researchers, and businesses alike. RAG enables AI systems to go beyond the limitations of their training data and access up-to-date and domain-specific information, making them more versatile, adaptable, and valuable in real-world scenarios.
As this book progresses, it serves as a comprehensive guide to the world of RAG, covering both fundamental concepts and advanced techniques. It is filled with detailed coding examples showcasing the latest tools and technologies, such as LangChain, Chroma’s vector store, and OpenAI’s ChatGPT-4o and ChatGPT-4o mini models. We will cover essential topics, including vector stores, vectorization, vector search techniques, prompt engineering and design, AI agents for RAG-related applications, and methods for evaluating and visualizing RAG outcomes.
The importance of learning RAG cannot be overstated. RAG is positioned as a key facilitator of customized, efficient, and insightful AI solutions, bridging the gap between generative AI’s potential and specific business needs. Whether you are a developer looking to enhance your AI skills, a researcher exploring new frontiers in AI, or a business leader seeking to leverage AI for growth and innovation, this book will provide you with the knowledge and practical skills necessary to harness the power of RAG and unlock the full potential of AI in your projects and initiatives.
Who this book is for
The target audience for this book encompasses a wide range of professionals and enthusiasts who are keen on exploring the cutting-edge intersection of RAG and generative AI. This includes the following:
- AI researchers and academics: Individuals engaged in the study and advancement of AI who are interested in the latest methodologies and frameworks, such as RAG, and their implications for the field of AI.
- Data scientists and AI engineers: Professionals who work with large datasets, aiming to leverage generative AI and RAG for more efficient data retrieval, improved accuracy in AI responses, and innovative solutions to complex problems.
- Software developers and technologists: Practitioners who design and build AI-driven applications and are looking to integrate RAG into their systems to enhance performance, relevance, and user engagement.
- Business analysts and strategists: Individuals who seek to understand how AI can be applied strategically within organizations to drive innovation, operational efficiency, and competitive advantage.
- Product managers in tech: Professionals responsible for overseeing the development of AI products, interested in understanding how RAG can contribute to smarter, more responsive applications that align with business goals.
- AI hobbyists and enthusiasts: A broader audience with a keen interest in AI, eager to learn about the latest trends, tools, and techniques shaping the future of AI applications.
This book is particularly suited for readers who have a foundational understanding of AI and are looking to deepen their knowledge of how RAG can transform business applications, enhance data-driven insights, and foster innovation. It appeals to those who value practical, hands-on learning, offering real-world coding examples, case studies, and strategies for implementing RAG effectively.
What this book covers
, , introduces RAG, a technique that combines large language models (LLMs) with a company’s internal data to enhance the accuracy, relevance, and customization of AI-generated outputs. It discusses the advantages of RAG, such as improved performance and flexibility, as well as challenges such as data quality and complexity. The chapter also covers key RAG vocabulary, the importance of vectors, and real-world applications across various industries. It compares RAG to conventional generative AI and fine-tuning and outlines the architecture of RAG systems, which consists of indexing, retrieval, and generation stages.
, , provides a comprehensive code lab that walks through the implementation of a complete RAG pipeline using Python, LangChain, and Chroma. It covers installing necessary packages, setting up an OpenAI API key, loading and preprocessing documents from a web page, splitting them into manageable chunks, embedding them into vector representations, and storing them in a vector database. The chapter then demonstrates how to perform a vector similarity search, retrieve relevant documents based on a query, and generate a response using a pre-built prompt template and a language model within a LangChain chain. Finally, it shows how to submit a question to the RAG pipeline and receive an informative response.
, , explores various practical applications of RAG in business, including enhancing customer support chatbots, automated reporting, e-commerce product descriptions and recommendations, utilizing internal and external knowledge bases, innovation scouting, trend analysis, content personalization, and employee training. It highlights how RAG can transform unstructured data into actionable insights, improve decision-making, and deliver personalized experiences across different sectors. The chapter concludes with a code example demonstrating how to add sources to RAG-generated responses, emphasizing the importance of citing information for credibility and support in applications such as legal document analysis or scientific research.
, , provides a comprehensive overview of the key components that make up a RAG system. It covers the three main stages: indexing, retrieval, and generation, explaining how they work together to deliver enhanced responses to user queries. The chapter also highlights the importance of the user interface (UI) and evaluation components, with the UI serving as the primary point of interaction between the user and the system, and evaluation is crucial for assessing and improving the RAG system’s performance through metrics and user feedback. While not exhaustive, these components form the foundation of most successful RAG systems.
, , explores security aspects specific to RAG applications. It discusses how RAG can be leveraged as a security solution by limiting data access, ensuring reliable responses, and providing transparency of sources. However, it also acknowledges the challenges posed by the black-box nature of LLMs and the importance of protecting user data and privacy. It introduces the concept of red teaming to proactively identify and mitigate vulnerabilities, and through hands-on code labs, it demonstrates how to implement security best practices, such as securely storing API keys and defending against prompt injection attacks using a red team versus blue team exercise. The chapter emphasizes the importance of ongoing vigilance and adaptation in the face of ever-evolving security threats.
, , provides a practical guide on creating interactive applications using RAG and Gradio as the UI. It covers setting up the Gradio environment, integrating RAG models, and creating a user-friendly interface that allows users to interact with the RAG system like a typical web application. The chapter discusses the benefits of using Gradio, such as its open source nature, integration with popular machine learning frameworks, and collaboration features, as well as its integration with Hugging Face for hosting demos. The code lab demonstrates how to add a Gradio interface to a RAG application, creating a process question function that invokes the RAG pipeline and displays the relevance score, final answer, and sources returned by the system.
, , addresses the crucial role of vectors and vector stores in RAG systems. It explains what vectors are, how they’re created through various embedding techniques, and their importance in representing semantic information. The chapter covers different vectorization methods, from traditional TF-IDF to modern transformer-based models, such as BERT and OpenAI’s embeddings. It discusses factors to consider when selecting a vectorization option, including quality, cost, network availability, speed, and compatibility. The chapter also explores vector stores, their architecture, and popular options such as Chroma,...




