Understanding AI and RAG: A Deep Dive into Modern Language Models