{"id":24373337,"url":"https://github.com/udit-rawat/quest","last_synced_at":"2025-12-24T13:40:16.812Z","repository":{"id":272921570,"uuid":"918169754","full_name":"udit-rawat/Quest","owner":"udit-rawat","description":"Quest is a on device RAG  that helps you quickly find solutions to coding problems. It searches through a database of answers and gives you clear, easy-to-understand solutions tailored to your question. Whether you're looking for explanations or code examples, Quest helps you find the right answer fast.","archived":false,"fork":false,"pushed_at":"2025-01-29T08:55:56.000Z","size":1227,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T11:16:05.840Z","etag":null,"topics":["deepseek-r1","hnsw","leetcode","ollama","ollama-api","qwen2","rag","sentence-transformers"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/udit-rawat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-17T11:40:57.000Z","updated_at":"2025-01-29T08:56:00.000Z","dependencies_parsed_at":"2025-01-17T13:32:55.287Z","dependency_job_id":null,"html_url":"https://github.com/udit-rawat/Quest","commit_stats":null,"previous_names":["udit-rawat/quest"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udit-rawat%2FQuest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udit-rawat%2FQuest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udit-rawat%2FQuest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udit-rawat%2FQuest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/udit-rawat","download_url":"https://codeload.github.com/udit-rawat/Quest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243205248,"owners_count":20253427,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deepseek-r1","hnsw","leetcode","ollama","ollama-api","qwen2","rag","sentence-transformers"],"created_at":"2025-01-19T05:10:48.298Z","updated_at":"2025-12-24T13:40:16.760Z","avatar_url":"https://github.com/udit-rawat.png","language":"Jupyter Notebook","readme":"# Quest\n\n**Quest** is a Retrieval-Augmented Generation (RAG) engine designed to assist with solving and explaining Data Structures and Algorithms (DSA) problems. It leverages a combination of retrieval-based methods and generative models to provide accurate and context-aware solutions to coding problems, explanations of concepts, and metadata about LeetCode-style questions.\n\n![Quest](templates/Quest.png)\n\n## Features\n\n- **Exact Matching Retrieval**: Quickly retrieves solutions for exact matches of problem titles from a curated dataset.\n- **Context-Aware Generation**: Generates detailed explanations and solutions for general queries using a generative model.\n- **Metadata Integration**: Provides metadata such as problem difficulty, related topics, and edge cases for retrieved solutions.\n- **Efficient Search**: Uses FAISS and HNSW for fast and accurate similarity search in high-dimensional spaces.\n- **Customizable**: Supports different models and configurations for retrieval and generation.\n- **Pre-Generated Solutions**: Includes **1800+ solutions in JSON format**, created using the `qwen2.5-coder:1.5b` model on a local machine.\n- **Optimized Inference Speed**: Reduced query retrieval time from 1 minute to 15 seconds and reasoning model time from 20 minutes to under 4 minutes.\n- **Dynamic Prompt Switching**: Implements dynamic prompt switching for Qwen and Deepseek models to prevent infinite reasoning loops.\n- **Unknown Query Handling**: Switches to model’s own inference for queries with confidence below 0.6 for better accuracy.\n- **HNSW Indexing**: Fine-tuned HNSW parameters for faster and more relevant query retrieval.\n- **Memory Buffer**: Retains past interactions for more contextually accurate responses over multiple queries.\n- **Dataset Generation**: Created an on-device dataset of over 1850 coding questions JSON, enriched with metadata.\n- **Reasoning Model Integration**: Integrated Deepseekr1 7B for complex problem-solving with optimized prompt templates.\n- **Frontend Interface**: Built with Flask and Bootstrap, featuring a clean and responsive design with interactive elements.\n- **Search and Query Optimization**: Optimized query engine with efficient indexing and metadata-based retrieval.\n- **Code Quality**: Well-structured code, easy to understand, extend, and deploy, hosted on GitHub for public access.\n\n---\n\n## Installation\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/udit-rawat/Quest.git\n   cd Quest\n   ```\n\n2. Install the required dependencies:\n\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n3. Unzip the `leetcode_solutions.zip` file to access the solutions in JSON format:\n   ```bash\n   unzip leetcode_solutions.zip -d src/DSAAssistant/components/\n   ```\n\n---\n\n## Setting Up Ollama\n\nTo use the generative models (`qwen2.5-coder:1.5b` and `deepseek-r1:1.5b`), you need to install Ollama and pull the required models.\n\n### Install Ollama\n\n- **macOS**:\n  Download and install Ollama from the official website:  \n  [Ollama for macOS](https://ollama.ai/download/mac)\n\n- **Windows**:\n  Download and install Ollama from the official website:  \n  [Ollama for Windows](https://ollama.ai/download/windows)\n\n### Pull the Models\n\nOnce Ollama is installed, pull the required models using the following commands:\n\n```bash\n# Pull qwen2.5-coder:1.5b\nollama pull qwen2.5-coder:1.5b\n\n# Pull deepseek-r1:1.5b\nollama pull deepseek-r1:1.5b\n```\n\n---\n\n## Usage\n\n### Running the RAG Engine\n\n1. Start the RAG engine:\n\n   ```bash\n   python app.py\n   ```\n\n2. Use the engine to query solutions or explanations. Example:\n   ```bash\n   Query: \"Explain the concept of dynamic programming.\"\n   ```\n\n---\n\n## Project Structure\n\n```\nQuest/\n├── app.py                          # Main application entry point\n├── requirements.txt                # List of dependencies\n├── .gitignore                      # Files and directories to ignore\n├── README.md                       # Project documentation\n├── src/\n│   ├── DSAAssistant/               # Core components of the RAG engine\n│   │   ├── components/\n│   │   │   ├── retriever2.py       # LeetCode retriever implementation\n│   │   │   ├── rag_engine.py       # RAG engine implementation\n│   │   │   ├── leetcode_hnsw.index # Pre-built HNSW index\n│   │   │   ├── leetcode_metadata.pkl # Metadata for LeetCode problems\n│   │   │   ├── leetcode_solutions.zip # Zipped JSON solutions\n│   │   │   └── ...                 # Other components\n│   │   └── ...                     # Additional modules\n│   └── ...                         # Other source files\n└── ...                             # Configuration and other files\n```\n\n---\n\n## Configuration\n\nThe RAG engine can be configured using the following parameters:\n\n- **Retriever**:\n\n  - `index_path`: Path to the HNSW index file.\n  - `metadata_path`: Path to the metadata file.\n  - `model_name`: Name of the sentence transformer model for encoding.\n\n- **Generation**:\n  - `ollama_url`: URL for the Ollama API (if using a remote model).\n  - `model_name`: Name of the generative model.\n  - `temperature`: Controls the randomness of the generated output.\n  - `top_p`: Controls the diversity of the generated output.\n\nExample configuration:\n\n```python\nretriever = LeetCodeRetriever(\n    index_path=\"path/to/leetcode_hnsw.index\",\n    metadata_path=\"path/to/leetcode_metadata.pkl\",\n    model_name=\"all-MiniLM-L6-v2\"\n)\n\nrag_engine = RAGEngine(\n    retriever=retriever,\n    ollama_url=\"http://localhost:11434/api/generate\",\n    model_name=\"qwen2.5-coder:1.5b\",\n    temperature=0.4,\n    top_p=0.9\n)\n```\n\n---\n\n## Contributing\n\nContributions are welcome! If you'd like to contribute to **Quest**, please follow these steps:\n\n1. Fork the repository.\n2. Create a new branch for your feature or bugfix:\n   ```bash\n   git checkout -b feature/your-feature-name\n   ```\n3. Commit your changes:\n   ```bash\n   git commit -m \"Add your feature or fix\"\n   ```\n4. Push your branch:\n   ```bash\n   git push origin feature/your-feature-name\n   ```\n5. Open a pull request and describe your changes.\n\n---\n\n## Acknowledgments\n\n- **FAISS** and **HNSW** for efficient similarity search.\n- **Sentence Transformers** for encoding text into embeddings.\n- **Ollama** for providing the generative model API.\n\n---\n\n## Contact\n\nFor questions or feedback, feel free to reach out:\n\n- **Udit Rawat**\n- GitHub: [udit-rawat](https://github.com/udit-rawat)\n- Email: [uditrawat1905@gmail.com](mailto:uditrawat1905@gmail.com)\n\n```\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fudit-rawat%2Fquest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fudit-rawat%2Fquest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fudit-rawat%2Fquest/lists"}