This repository demonstrates how to create a webpage retrieval system using model named mixtral-8x7b-32768 on Groq and LangChain with Streamlit for interactive querying. The app uses Ollama Embeddings to handle document vectorization and retrieval.
Follow the steps below to set up your environment on your local machine:
First, clone the repository to your local machine:
git clone <repository_url>
cd <repository_name>Install the required dependencies using pip:
The necessary packages include:
- Streamlit: for the web interface.
- LangChain: for webpage loading, splitting, and querying.
- FAISS: for vector-based document retrieval.
- Ollama: for embeddings.
To manually install some of the key dependencies:
pip install streamlit langchain faiss-cpu ollama python-dotenvInstall Ollama to pull Llama-2 (run cmd/powershell as admin in Windows):
choco install ollama #WindowsThen, pull the Llama-2 model using Ollama:
ollama pull llama2- Groq API Key: You will need a Groq API key.
os.environ["GROQ_API_KEY"] = "your_groq_api_key_here"
st.session_state.loader=WebBaseLoader("https://docs.smith.langchain.com/")Once you have the environment set up and the necessary dependencies installed, run the app using Streamlit:
streamlit run app.pyAfter starting the app, you can input your query in the text box and it will retrieve and answer based on the provided webpage.
Here’s an example of the app's interface:
- Webpage Loading: The app uses the
WebBaseLoaderfrom LangChain to load webpage from a URL. - Text Splitting: It splits the loaded webpages into chunks using
RecursiveCharacterTextSplitterfor efficient querying. - Embeddings: The webpage embeddings are generated using Ollama Embeddings, which are stored in FAISS for fast retrieval.
- Retrieval Chain: The system builds a retrieval chain using
ChatGroqand LangChain’s document chain functions. - Prompting: You can ask questions about the webpage, and the system will return relevant answers based on context from the webpage.
