{"id":26541377,"url":"https://github.com/darkzard05/rag-system-ollama","last_synced_at":"2026-04-12T04:36:50.428Z","repository":{"id":280933972,"uuid":"943657068","full_name":"darkzard05/rag-system-ollama","owner":"darkzard05","description":"A Retrieval-Augmented Generation (RAG) Chatbot powered by Ollama LLM that provides document-based Q\u0026A using uploaded PDF files. Built with LangChain and FAISS, this chatbot allows users to interact with document contents through an intuitive Streamlit interface.","archived":false,"fork":false,"pushed_at":"2025-03-21T07:34:39.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T08:28:47.556Z","etag":null,"topics":["faiss","langchain","nlp","ollama","rag","streamlit"],"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/darkzard05.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-06T04:02:28.000Z","updated_at":"2025-03-21T07:38:58.000Z","dependencies_parsed_at":"2025-03-13T08:19:17.856Z","dependency_job_id":null,"html_url":"https://github.com/darkzard05/rag-system-ollama","commit_stats":null,"previous_names":["darkzard05/rag-system-ollama"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkzard05%2Frag-system-ollama","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkzard05%2Frag-system-ollama/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkzard05%2Frag-system-ollama/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkzard05%2Frag-system-ollama/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darkzard05","download_url":"https://codeload.github.com/darkzard05/rag-system-ollama/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244890792,"owners_count":20527153,"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":["faiss","langchain","nlp","ollama","rag","streamlit"],"created_at":"2025-03-22T01:20:17.872Z","updated_at":"2025-12-30T23:54:44.042Z","avatar_url":"https://github.com/darkzard05.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RAG System with Ollama \u0026 LangGraph\n\nThis project is a Streamlit web application that allows you to chat with your PDF documents using a local Large Language Model (LLM) powered by Ollama. It leverages the RAG (Retrieval-Augmented Generation) pattern, LangChain, and LangGraph to provide contextual answers based on the content of your uploaded files.\n\n## Key Features\n\n-   **Chat with Your PDFs:** Upload a PDF file and ask questions about its content.\n-   **Powered by Local LLMs:** Uses Ollama to run LLMs locally on your machine, ensuring privacy and control.\n-   **Selectable Embedding Models:** Choose from a list of different sentence-transformer models for document embedding.\n-   **Hybrid Search:** Combines dense vector search (FAISS) and keyword-based search (BM25) for robust and accurate document retrieval.\n-   **Built with LangGraph:** The RAG pipeline is orchestrated as a graph, making the logic clear and extensible.\n-   **Interactive UI:** A user-friendly interface built with Streamlit, including a PDF viewer.\n-   **Caching:** Caches processed documents (vector stores) to ensure fast re-loading of previously analyzed files.\n-   **Semantic Chunking:** Supports advanced semantic chunking based on embedding similarity for better context preservation.\n\n## Setup and Installation\n\n### 1. Prerequisites: Install Ollama\n\nYou must have Ollama installed and running on your system.\n\n1.  Download and install Ollama from the [official website](https://ollama.com/).\n2.  Pull the LLM model you intend to use. The default model in this project is `gemma3:8b` (configurable).\n    ```sh\n    ollama pull gemma3:8b\n    ```\n\n### 2. Clone the Repository\n\n```sh\ngit clone \u003crepository-url\u003e\ncd rag-system-ollama\n```\n\n### 3. Create a Virtual Environment (Recommended)\n\n```sh\n# For Windows\npython -m venv venv\n.\\venv\\Scripts\\activate\n\n# For macOS/Linux\npython3 -m venv venv\nsource venv/bin/activate\n```\n\n### 4. Install Dependencies\n\nInstall all the required Python packages from `requirements.txt`.\n\n```sh\npip install -r requirements.txt\n```\n\n## How to Run\n\nOnce the setup is complete, you can run the Streamlit application with the following command:\n\n```sh\nstreamlit run src/main.py\n```\n\nThe application will open in your default web browser.\n\n## Project Structure\n\n```\n.\n├── .env.example\n├── config.yml\n├── readme.md\n├── requirements.txt\n└── src/\n    ├── config.py          # Loads settings from config.yml\n    ├── graph_builder.py   # Defines the RAG workflow using LangGraph\n    ├── main.py            # Main entry point for the Streamlit app\n    ├── model_loader.py    # Handles loading LLMs and embedding models\n    ├── rag_core.py        # Core RAG logic (document loading, splitting, embedding)\n    ├── schemas.py         # Data schemas (e.g., GraphState)\n    ├── semantic_chunker.py# Custom semantic chunking logic\n    ├── session.py         # Manages the Streamlit session state\n    ├── ui.py              # Contains all Streamlit UI rendering functions\n    └── utils.py           # Utility functions (e.g., decorators)\n```\n\n## Configuration\n\nThe main behavior of the application can be configured in the `config.yml` file:\n\n-   **`models`**: Set the default Ollama model, preferred embedding models, etc.\n-   **`rag`**: Configure the RAG pipeline, such as chunk size, retriever settings, semantic chunking parameters, and ensemble weights.\n-   **`ui`**: Change UI messages and container heights.\n\n## License\nThis project is distributed under the MIT License. See the `LICENSE` file for more details.\n\n---\n\u003ca name=\"korean\"\u003e\u003c/a\u003e\n# LangGraph \u0026 Ollama 기반 RAG 챗봇 (한국어)\n\n**LangGraph, 앙상블 리트리버(BM25 \u0026 FAISS), Ollama, Streamlit 기반의 고도화된 PDF 챗봇**\n\n이 프로젝트는 정교한 RAG(Retrieval-Augmented Generation) 시스템을 구현하며, 핵심 파이프라인이 **LangGraph**를 사용한 상태 머신으로 구조화되어 있습니다. 사용자는 PDF 문서를 업로드하고 Ollama를 통해 로컬에서 실행되는 LLM과 대화할 수 있습니다.\n\n![RAG Chatbot Preview](image/image1.png)\n\n## 🔑 주요 기능\n\n- **LangGraph 기반 아키텍처**: RAG 파이프라인(검색 -\u003e 컨텍스트 구성 -\u003e 답변 생성)을 그래프로 구축하여 워크플로우를 투명하고 수정하기 쉽게 만듭니다.\n- **고도화된 하이브리드 검색**: 키워드 기반 검색(BM25)과 의미 기반 검색(FAISS)을 결합한 **앙상블 리트리버**를 사용하여 더 정확하고 문맥에 맞는 결과를 제공합니다.\n- **의미론적 청킹(Semantic Chunking)**: 단순 길이 기반이 아닌, 임베딩 유사도를 기반으로 문맥 단위로 텍스트를 분할하여 검색 품질을 높입니다.\n- **강력한 로컬 LLM (Ollama)**: 개인 정보 보호를 위해 Ollama로 로컬에서 LLM을 실행합니다.\n- **효율적인 캐싱**: 벡터 저장소와 모델을 캐싱하여, 앱을 재실행하거나 동일한 파일을 다시 로드할 때 속도가 매우 빠릅니다.\n- **대화형 UI**: 손쉬운 문서 업로드, 모델 선택, 채팅 및 나란히 보는 PDF 뷰어를 위해 Streamlit으로 구축된 사용자 친화적인 인터페이스입니다.\n\n---\n\n## ⚡ 빠른 시작\n\n### 📋 사전 준비 사항\n- **Python**: 3.10 이상\n- **Ollama**: 로컬 모델 사용 시, Ollama가 설치되어 있고 서버가 실행 중이어야 합니다.\n  - 설치는 [Ollama 공식 웹사이트](https://ollama.com)를 참조하세요.\n- **시스템 리소스**: 로컬 모델(7B 이상) 구동을 위한 충분한 RAM/VRAM이 권장됩니다.\n\n---\n\n### 💻 설치 및 실행\n\n1.  **저장소 클론**\n    ```bash\n    git clone \u003crepository-url\u003e\n    cd rag-system-ollama\n    ```\n\n2.  **(권장) 가상 환경 생성 및 활성화**\n    ```bash\n    python -m venv venv\n    \n    # Windows\n    venv\\Scripts\\activate\n    \n    # macOS/Linux\n    source venv/bin/activate\n    ```\n\n3.  **필요한 Python 패키지 설치**\n    ```bash\n    pip install -r requirements.txt\n    ```\n\n4.  **Ollama 모델 다운로드**\n    기본 설정 모델인 `gemma3:8b`를 다운로드하거나, 원하는 모델을 선택하세요.\n    ```bash\n    ollama pull gemma3:8b\n    ```\n    - 이 명령을 실행하기 전에 Ollama 서버가 실행 중인지 확인하세요.\n    - `config.yml`의 `default_ollama` 설정을 원하는 모델로 변경할 수 있습니다.\n\n5.  **Streamlit 애플리케이션 실행**\n    ```bash\n    streamlit run src/main.py\n    ```\n\n6.  웹 브라우저에서 `http://localhost:8501`로 접속하여 애플리케이션을 사용합니다.\n\n## 📁 파일 구조\n```\n.\n├── config.yml        # 애플리케이션 설정 파일\n├── requirements.txt  # 의존성 패키지 목록\n└── src/\n    ├── main.py            # 앱 진입점\n    ├── ui.py              # UI 렌더링 로직\n    ├── session.py         # 세션 상태 관리\n    ├── rag_core.py        # RAG 핵심 로직 (문서 처리, 검색)\n    ├── graph_builder.py   # LangGraph 워크플로우 정의\n    ├── semantic_chunker.py# 의미론적 청킹 구현체\n    ├── model_loader.py    # 모델 로딩 및 캐싱\n    ├── schemas.py         # 데이터 스키마\n    ├── config.py          # 설정 로더\n    └── utils.py           # 유틸리티 함수\n```\n\n## ⚙️ 설정\n\n- **모델 및 파라미터**: `config.yml` 파일에서 다음 항목들을 조정할 수 있습니다.\n  - `models`: 기본 LLM 및 임베딩 모델\n  - `rag`: 청킹 전략(Semantic Chunking 등), 리트리버 가중치, 검색 파라미터(k)\n  - `ui`: UI 메시지 및 레이아웃 설정\n\n## 📄 라이선스\n이 프로젝트는 MIT 라이선스 하에 배포됩니다. 자세한 내용은 `LICENSE` 파일을 참조하세요.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkzard05%2Frag-system-ollama","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarkzard05%2Frag-system-ollama","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkzard05%2Frag-system-ollama/lists"}