MediQuery is a chatbot for health care. Patient can give their symptoms based on that model will predict and give suggestions.
MediQuery AI is a chatbot designed to answer medical queries with precision and speed. Leveraging Sentence Transformers for semantic search, Pinecone for efficient vector storage and retrieval, and Streamlit for an intuitive user interface, this project provides accurate and contextually relevant answers to healthcare-related questions.
- Semantic Search:
- Uses state-of-the-art embeddings to find answers based on the meaning of user queries.
- Dynamic Query Refinement:
- Refines ambiguous or incomplete queries using OpenAI's GPT-3.5 model.
- Real-time Chat Interface:
- An interactive chatbot built with Streamlit and Streamlit Chat.
- Scalability:
- Pinecone ensures fast and efficient similarity searches even with large datasets.
- Python: Backend processing and integration.
- Streamlit: Frontend for user interaction.
- Sentence Transformers: For semantic embeddings.
- Pinecone: A vector database for storing and searching embeddings.
- OpenAI GPT-3.5: For query refinement and enhanced context understanding.
- NLTK: Text preprocessing (optional, if enabled).
- Provide a scalable and accurate chatbot for answering medical queries.
- Integrate advanced semantic search for relevant responses.
- Enable a user-friendly web-based interface for interaction.
- Ensure the project can handle large datasets with minimal latency.
mediquery-ai/
├── backend.py # Backend logic for dataset processing and Pinecone integration
├── main.py # Streamlit application for chatbot UI
├── utils.py # Utility functions for query refinement and embeddings
├── requirements.txt # Required Python dependencies
├── README.md # Project documentation
└── icliniq_medical_qa_2.csv # Medical Q&A dataset (or use a provided link)
First, clone the repository to your local machine:
git clone https://github.com/<your-username>/mediquery-ai.git
cd mediquery-aiTo ensure a clean environment, create and activate a Python virtual environment:
python -m venv env
env\Scripts\activatepython3 -m venv env
source env/bin/activateInstall the required libraries using requirements.txt:
pip install -r requirements.txtIf requirements.txt is not available, install dependencies manually:
pip install streamlit sentence-transformers langchain langchain-community pinecone-client tqdm pandas openai nltk- Sign up at Pinecone.io.
- Create an API key and note down your API key and region.
Update the backend.py and utils.py files with your API key and region:
PINECONE_API_KEY = "your-pinecone-api-key"
PINECONE_REGION = "your-region" # e.g., us-east-1Run backend.py to process the dataset and populate the Pinecone index:
python backend.pyThis script:
- Processes the dataset and generates embeddings.
- Uploads the embeddings to Pinecone along with metadata.
- Sign up at OpenAI.
- Generate an API key from the dashboard.
Add your API key to utils.py:
openai.api_key = "your-openai-api-key"Start the chatbot application using Streamlit:
streamlit run main.pyOpen the URL provided in the terminal (e.g., http://localhost:8501) to interact with the chatbot.
-
Ask a Question:
- Enter your medical query into the chatbot, such as:
What are the symptoms of pneumonia?
- Enter your medical query into the chatbot, such as:
-
View Responses:
- The chatbot retrieves the most relevant answer(s) and displays them along with their similarity scores (if enabled).
-
Refined Queries:
- If a query is ambiguous, the chatbot refines it using OpenAI GPT-3.5.
How can I lose weight?
[
{
"metadata": {
"question": "How can I lose weight?",
"answer": "To reduce weight, you should maintain a calorie deficit and exercise regularly."
},
"score": 0.89
},
{
"metadata": {
"question": "What are some weight loss tips?",
"answer": "Avoid sugary foods, eat more protein, and stay hydrated."
},
"score": 0.85
}
]- Ensure the Pinecone index is populated:
index.describe_index_stats()
- Verify the API key and region configuration.
If a module is missing, ensure all dependencies are installed:
pip install -r requirements.txtIf you receive an error about exceeding your OpenAI quota:
- Check your usage on the OpenAI dashboard.
- Upgrade to a paid plan if necessary.
- Multilingual Support:
- Add multilingual embeddings for broader accessibility.
- Dynamic Dataset Updates:
- Allow users to upload and index new datasets.
- Cloud Deployment:
- Deploy the chatbot on platforms like AWS, Azure, or GCP for wider access.
- GPT Integration for Answers:
- Use GPT to generate or refine answers dynamically.
- Hugging Face for pre-trained Sentence Transformer models.
- Pinecone for vector storage and retrieval.
- Streamlit for frontend development.
- OpenAI for GPT query refinement.
This project is licensed under the MIT License.
Ensure requirements.txt includes:
streamlit
sentence-transformers
langchain
langchain-community
pinecone-client
openai
tqdm
pandas
nltk
Let me know if you need any further refinements!