This repository is designed for a workshop that introduces the basics of creating a generative AI application. The workshop is structured in a way that gradually introduces the participants to various aspects of building such an application. Here's a brief overview of each script in the repository and its role in the workshop:
This script is used to introduce the concept of generating responses using a hosted API. It uses the Groq API to simulate a conversation with a customer service professional from a leading E-Commerce company called AcmeCorp. The script takes a user's question and generates a professional and polite response.
This script is used to demonstrate how to templatize requests. It loads a JSON file containing various prompts and returns the prompt corresponding to a given string. This allows for more dynamic and flexible generation of responses.
This script is used to introduce the concept of document ingestion and text processing. It loads documents from a specified directory, splits them into chunks, and creates embeddings for each chunk using a pre-trained HuggingFace model. It then creates a FAISS index from these embeddings and saves it to a local directory.
This script is used to demonstrate how to use the FAISS index created by ingest.py to perform similarity searches. It loads a pre-trained HuggingFace model and a FAISS index from a local directory. It then enters a loop where it takes user input, performs a similarity search on the FAISS index using the input, and prints the content of the most similar document.
This script is used to demonstrate how to a simple classifier that will rephrase the original question and use this along with the search index results to generate an answer to the question based on the search index
- Introduction to Generative AI and its applications.
- Demonstration of generating responses using a hosted API with
simple_prompt.py. - Discussion on how to templatize requests with
prompt_template.py. - Introduction to document ingestion, text processing, and creating embeddings with
ingest.py. - Demonstration of how to use a FAISS index to perform similarity searches with
search_index.py. - Demonstrate how to use a classifier and then use this to generate a new answer in
query_module.py - Q&A and wrap-up.
Before running the scripts, you need to set an environment variable GROQ_API_KEY to your Groq API key.
For Mac/Linux users, you can do this in the terminal:
export GROQ_API_KEY=your_api_key
For Windows users, you can do this in the command prompt:
set GROQ_API_KEY=your_api_key
Replace your_api_key with your actual Groq API key.
Next, create a virtual environment:
For Mac/Linux users, you can do this in the terminal:
python3 -m venv venv
For Windows users, you can do this in the command prompt:
python -m venv venv
Then, activate the virtual environment:
For Mac/Linux users, you can do this in the terminal:
source venv/bin/activate
For Windows users, you can do this in the command prompt:
.\venv\Scripts\activate
After setting the environment variable and activating the virtual environment, you'll need to install the required dependencies listed in requirements.txt. You can do this with pip:
pip install -r requirements.txt
Then, you can run each script with Python:
python simple_prompt.py
python prompt_template.py
...
Please note that these scripts are designed to work together, and some may require the output of others to function correctly. For example, 3_ingest.py must be run before 4_search_index.py to create the FAISS index that the latter script loads.
If you'd like to contribute to this project, please feel free to submit a pull request or open an issue. We appreciate your help!
This project is licensed under the terms of the MIT license.