This repo implements a production-ready, scalable Retrieval Augmented Generation (RAG)-powered LLM-based Open Generative (or Extractive) context-aware Question-Answering (QA) App that:
- Takes as input a new
query(orquestion); - Implements vector similarity search within the embedding space by seeking relevant contexts corresponding to the incoming
queryin the vector database; - Passes the relevant contexts as well as the
input queryto LLM; - LLM then produces the
answerto the inputquerywhile being aware of the relevant contexts related to the requestedquery.
This project also includes Fine-tuning a 20B parameters Large Language Model (LLM) in a multi-GPU cluster environment by leveraging the distributed training paradigm. Moreover, this repo develops scalable major ML workloads for contexts (load, embed, and index the contexts in the vector database) across multiple workers with different compute resources and serves the LLM App in a highly robust and scalable manner.
The below diagram shows the architectural design of this RAG-powered LLM App:
PythonStreamlitPEFT(for Parameter-Efficient Fine-Tuning)AccelerateRay(for distributed LLM Fine-Tuning)DatasetsTransformersPyTorchNumpyScikit-LearnDeta(To access Deta Vector Database)LangChainFastAPI(To serve production-ready LLM App)
Squad dataset is used to fine-tune Eleuther AI's GPT-Neo 20B LLM model, which comprises Title, Question, Answer, and Context for each of the 98.2k dataset IDs.
- The
Fine-Tuningprocess forGPT-NeoLLM model can be found infinetune.pyfile. - The code to create RAG-powered LLM Agent for
QAtask can be seen inqa_agent.pyfile. - To build the agent as production-ready API for
QAtask, it's worth delving deep intoserve.pyfile. - To seek prospects of using
Streamlitto deploy the LLM app, head tostreamlit.pyfile. - All hyperparameters to control
fine-tuningof the model are provided in the givenconfig.pyfile.
To learn more about how to use this LLM RAG-powered QA App, consider watching the following video:
