Create a quiz generator using Google Gemini, Langchain, Chroma, and Streamlit to explore LLMs and vector embeddings.
- Python version 3.11 or above
- Streamlit Documentation
- Google Cloud account
- Vertexai Documentation
To run the Quiz Builder:
- Install the necessary dependencies listed in
requirements.txt
. - Run the Streamlit application by executing
streamlit run xxx.py
in the terminal where xxx is the name of the py file you want to run. - Follow the instructions provided in the user interface to interact with the Quiz Builder.
- Go to the Google Cloud Platform and select "Get Started for free".
- Sign in using your Google Account and complete the billing requirements.
- Create a new project.
- Navigation -> Artificial Intelligence -> Vertex AI -> Enable All Recommended APIs
- Install the Google SDK using this link.
- Run the following command to initialize the SDK:
gcloud init
- Sign in using your Google Account credentials.
- Select an existing project or Create a new project
- Add your Gemini authentication.json to the gitignore file
- Install the streamlit framework
pip install streamlit
- Create a file uploader using
st.file_uploader()
that only accepts PDF's - Process the file using a PyPDFLoader
- Install the Langchain Vertex framework
pip install langchain_google_vertexai
- Initialize VertexAIEmbeddings Client
- Create a function to retrieve embeddings for a single query
- Create a function to retrieve embeddings for multiple documents
- Create a Chroma collection from the documents processed by the DocumentProcessor (from previous tasks)
- Split documents into chunks using Langchain's CharacterTextSplitter
- Create the Chroma collection
- Initialize DocumentProcessor, EmbeddingClient, and ChromaCollectionCreator from previous tasks
- Use Streamlit to capture user's inputs regarding quiz topic and desired number of questions
- Create a chroma collection from the processed documents
- Create a QuizGenerator Class
- Create a question template
- Enable a retriever using the vectorstore object
- Create chain with the retriever, template, and llm as to generate a question based off of the various ingested documents
- Loop the QuizGenerator and validate the questions uniqueness
- Enable the interface to handle all the quiz questions, move back and forth in the quiz, and display the correct answer and an explanation
- A GitHub repository for the project containing all the project files.
- Loom Video to show the approach. Loom Link
This project is licensed under the MIT License - see the LICENSE file for details.
Special thanks to the Radical AI team for allowing me to work on this AI Mission.