{"id":26400535,"url":"https://github.com/amiorhmn/rag-chatbot-from-scratch","last_synced_at":"2026-04-16T14:10:53.096Z","repository":{"id":282749862,"uuid":"949471538","full_name":"amiorhmn/RAG-Chatbot-from-Scratch","owner":"amiorhmn","description":"A command-line RAG Chatbot application built from scratch","archived":false,"fork":false,"pushed_at":"2025-03-18T04:07:07.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-11T19:41:20.742Z","etag":null,"topics":["chatbot","ollama","rag","rag-application","rag-chatbot","rag-implementation","scratch-implementation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amiorhmn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-03-16T14:41:42.000Z","updated_at":"2025-03-18T04:07:10.000Z","dependencies_parsed_at":"2025-03-16T19:06:22.471Z","dependency_job_id":null,"html_url":"https://github.com/amiorhmn/RAG-Chatbot-from-Scratch","commit_stats":null,"previous_names":["amiorhmn/rag-from-scratch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/amiorhmn/RAG-Chatbot-from-Scratch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amiorhmn%2FRAG-Chatbot-from-Scratch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amiorhmn%2FRAG-Chatbot-from-Scratch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amiorhmn%2FRAG-Chatbot-from-Scratch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amiorhmn%2FRAG-Chatbot-from-Scratch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amiorhmn","download_url":"https://codeload.github.com/amiorhmn/RAG-Chatbot-from-Scratch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amiorhmn%2FRAG-Chatbot-from-Scratch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267436733,"owners_count":24086898,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["chatbot","ollama","rag","rag-application","rag-chatbot","rag-implementation","scratch-implementation"],"created_at":"2025-03-17T14:26:41.717Z","updated_at":"2026-04-16T14:10:53.056Z","avatar_url":"https://github.com/amiorhmn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RAG-Chatbot-from-Scratch\nA simple command-line RAG (Retieval Augmented Generation) chatbot application built from scratch. No external framework or library has been used except *requests* and *scikit-learn* modules. It uses a locally hosted LLM via *Ollama* to generate embedding and response to user's query based on relevant information from a text file.\n\n## Features\n- Implementation of RAG from scratch without any third party framework\n- Uses locally hosted open-source LLM and embedding model\n- Advanced prompting for LLM input\n- Command-line interface\n- Handling of error during document loading\n- Exit program via `KeyboardInterrupt` or `exit` and `quit` keywords\n\n## Conversation Example\n```\n(.venv) PS C:\\Users\\Amio\\Desktop\\RAG-Chatbot-from-Scratch\u003e python main.py\nPlease enter the path of your document: cat-facts.txt\nDocument loaded with 150 entries.\nAsk a question: What do cats eat?\nChatbot: According to the context, cats eat about five mice per meal.\nAsk a question: How long does a cat live? \nChatbot: According to the provided context, the average life span of a domestic cat is 14 years.\nAsk a question: quit                         \n(.venv) PS C:\\Users\\Amio\\Desktop\\RAG-Chatbot-from-Scratch\u003e\n```\n\n## Requirements\n- *Ollama* for hosting open-source embedding and large language models\n- *Requests* library for communicating with the models\n- *Scikit-learn* library for calculating `cosine-similarity` during retrieval step\n\nThis specific example uses *Gemma3* model for response generation and *all-minilm* for embedding generation. The models can be changed from the `utils.py` file.\n\n## Structure of the code\nThe application contains two files:\n- main.py\n- utils.py\n  - `get_embeddings`\n  - `retrieve`\n  - `generate_response`\n\nThe `utils.py` contains three functions. Each of them does a specific task in the RAG pipeline. The app is run from the `main.py` file.\n\n## How to run\n1. Install *Ollama* from [ollama.com](https://ollama.com)\n2. Download an embedding model and a text model (e.g. *all-minilm* and *Gemma3*)\n   ```\n   ollama pull all-minilm\n   ollama pull gemma3\n   ```\n3. Clone the repository\n   ```\n   git clone https://github.com/amiorhmn/RAG-Chatbot-from-Scratch.git\n   cd RAG-Chatbot-from-Scratch\n   ```\n4. Create and activate a virtual environment\n   ```\n   python -m venv .venv\n   source .venv/bin/activate  # On Windows, use `.venv\\Scripts\\activate`\n   ```\n5. Install the requirements\n   ```\n   pip install -r requirements.txt\n   ```\n6. Run the app\n   ```\n   python main.py\n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famiorhmn%2Frag-chatbot-from-scratch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famiorhmn%2Frag-chatbot-from-scratch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famiorhmn%2Frag-chatbot-from-scratch/lists"}