Abstract
Generative AI has transitioned from the lab to the classroom, hospitals, software teams, and boardrooms. Large language models (LLMs), transformer-based foundation models, are at the heart of this paradigm change, with their ability to write texts, reason, summarize, translate, and code. However, these developments have left many students and researchers, as well as practitioners, with disjointed bits of knowledge. This book was developed with that knowledge in mind in order to streamline all that information in a single comprehensive and hands-on natural language processing (NLP) and generative AI guide. The book follows the path of the technology itself. Chapter 1 covers transformer architectures ranging from the self-attention mechanism to encoder-decoder and decoder-only architectures. The course also includes lectures on mixture of experts, scaling laws, pretraining, fine-tuning, alignment and multimodal models. Targeting prompt engineering and in-context learning is the focus of Chapter 2. It uses zero shot, few shot, chain of thought prompting, system prompts and context engineering as skills to learn and test. Chapter 3 focuses on LLM reasoning and test-time compute, presenting various ways in which deep learning systems can be extended to form reasoning models, self-consistency, and search over reasoning paths. As it is not possible to know everything, Chapters 4 and 5 discuss retrieval-augmented generation (RAG). They start with embeddings and vector databases, chunking strategies and semantic search. They then transition to advanced RAG β hybrid search, reranking, knowledge graphs, GraphRAG, and agentic RAG, all while also focusing on evaluation and LLMOps for production. The strands are woven together in Chapter 6 under the umbrella of agentic AI and AI agents. It examines the use of tools, the calling of functions, the memory of an agent, as well as planning and multi-agent systems and the way autonomous agents are transforming work. Chapter 7 ends with trustworthy and responsible AI. It speaks about hallucination, bias/fairness, explainability, data privacy, AI safety, AI ethics and AI governance, as without trust, the capability cannot be sustained. The chapters are designed with learning and reference in mind for each. It introduces the foundations and outlines the key techniques side-by-side in summary tables, covers present open challenges and future directions, and concludes with practical advice. Benchmarking and evaluation is handled very transparently with regard to the deficiencies in existing approaches β and I do hope readers will take the shortcomings as a challenge and a starting point for their own work. The working levels that the book is aimed at are graduate and undergraduate students, academic researchers, machine learning engineers, data scientists, and technology leaders. Can also be used as a textbook in the course where it was used or as a builder's handbook or as a literature map for those preparing an indexed study in a Scopus journal. I'm focusing more on enduring principles than fleeting tools because no one can stay current in a science that is evolving monthly. We hope this book empowers you to grasp generative AI, create responsibly, and shape the future of AI together.