HimanshuGoyal2004/doc-qa-docker
2
Document Q&A with LLMs, Docker, and Hugging Face
This project is a web-based application that allows you to chat with your documents. You can upload a document (PDF, DOCX, TXT, etc.), and the application will process it to answer your questions based on its content.
The application is built with:
- Backend: Python, LlamaIndex, Groq, and Cohere.
- Frontend: Gradio for the user interface.
- Containerization: Docker for easy deployment.
How it Works
- Document Parsing: When you upload a document, it's parsed using LlamaParse to extract the text content.
- Embeddings: The extracted text is then converted into vector embeddings using Cohere's embedding model.
- LLM Interaction: When you ask a question, the application uses the Groq API (with Llama 3) to find the most relevant information in the document and generate a response.
Running the Application with Docker
Prerequisites
- Docker installed on your machine.
- API keys for:
- LlamaParse (LLAMACLOUDAPI_KEY)
- Groq (GROQAPIKEY)
- Cohere (COHEREAPIKEY)
Steps
- Build the Docker Image:
docker build -t document-qa .- Run the Docker Container:
Replace your_llama_cloud_key, your_groq_key, and your_cohere_key with your actual API keys.
docker run -p 7860:7860 \
-e LLAMA_CLOUD_API_KEY="your_llama_cloud_key" \
-e GROQ_API_KEY="your_groq_key" \
-e COHERE_API_KEY="your_cohere_key" \
document-qa- Access the Application:
Open your web browser and go to http://localhost:7860.
Deploying to Hugging Face Spaces
You can deploy this application to Hugging Face Spaces directly from this repository.
Steps
- Create a new Hugging Face Space:
- Go to huggingface.co/new-space.
- Give your Space a name.
- Select Docker as the Space SDK.
- Choose "Docker from scratch".
- Create the Space.
- Upload the files:
- Upload
app.py,requirements.txt, andDockerfileto your Hugging Face Space repository.
- Add Secrets:
- In your Space's settings, go to the Secrets section.
- Add the following secrets with your API keys:
LLAMA_CLOUD_API_KEYGROQ_API_KEYCOHERE_API_KEY
- Deploy:
- Hugging Face will automatically build the Docker image from your
Dockerfileand deploy the application. Once the build is complete, your application will be live.
