Cchangyu's picture
README.md update
7ae0094
|
Raw
History Blame Contribute Delete
3.08 kB
---
title: Fair Election Reporting RAG Chatbot
emoji: πŸ—³οΈ
colorFrom: blue
colorTo: indigo
sdk: streamlit
sdk_version: "1.39.0"
app_file: RAG챗봇_배포.py
pinned: false
license: mit
---
# πŸ—³οΈ Fair Election Reporting Guide RAG Chatbot
This retrieval-augmented generation (RAG) chatbot uses the Internet Election News
Deliberation Commission's approximately 105-page **2026 Fair Election Reporting Guide**.
It finds relevant information in the guide and answers questions **with source page numbers**.
## How to Use
1. Select a sample question in the sidebar, or enter your own question in the input field at the bottom.
2. Verify the `[νŽ˜μ΄μ§€ N]` citation shown with the answer against the original guide.
3. Ask follow-up questions; the chatbot uses the previous context to respond naturally (multi-turn conversation).
4. To start over, click **πŸ—‘οΈ λŒ€ν™” μ΄ˆκΈ°ν™”** in the sidebar.
## Technology Stack
| Component | Technology |
|---|---|
| Frontend | Streamlit |
| Embedding model | Gemini Embedding 001 (768 dimensions) |
| Vector DB | Chroma (prebuilt persistent store) |
| Generative model | Gemini 2.5 Flash-Lite |
| Deployment | Hugging Face Spaces |
## How It Works
```
질문 μž…λ ₯
↓
Gemini Embedding으둜 벑터화 (task_type=retrieval_query)
↓
Chroma DBμ—μ„œ 코사인 μœ μ‚¬λ„ Top-5 청크 검색
↓
검색 κ²°κ³Ό + μ‹œμŠ€ν…œ ν”„λ‘¬ν”„νŠΈ + λŒ€ν™” 이λ ₯ β†’ Gemini 2.5 Flash-Lite
↓
좜처 νŽ˜μ΄μ§€κ°€ ν‘œμ‹œλœ ν•œκ΅­μ–΄ λ‹΅λ³€ 생성
```
## Environment Variables
Add the following entry under **Settings β†’ Variables and secrets** in the Space:
- `GEMINI_API_KEY` β€” Obtain from Google AI Studio (https://aistudio.google.com/apikey)
## Run Locally
1. Install the dependencies (a virtual environment is recommended).
```bash
pip install -r requirements.txt
```
2. Create a `.env` file in the same directory and add the following line.
```
GEMINI_API_KEY=본인의_Gemini_API_ν‚€
```
3. Make sure the prebuilt `chroma_election_db/` directory is in the same location.
4. Run the app with Streamlit rather than invoking Python directly.
```bash
streamlit run RAG챗봇_배포.py
```
If the browser does not open automatically, open http://localhost:8501 in your browser.
## File Structure
```
.
β”œβ”€β”€ RAG챗봇_배포.py # 메인 μ•± (Streamlit μ§„μž…μ )
β”œβ”€β”€ requirements.txt # 의쑴 νŒ¨ν‚€μ§€
β”œβ”€β”€ README.md # 이 파일
└── chroma_election_db/ # 사전 λΉŒλ“œλœ 벑터 DB
β”œβ”€β”€ chroma.sqlite3
└── <UUID 폴더>/
```
The vector DB must be generated in advance with a separate build script.
The app does not perform chunking or embedding at runtime.
## Notes
- The chatbot's answers are based on the guide, but verify the **original guide** before using them for final decisions or citations.
- On the free tier, the Space may go to sleep after a period of inactivity, so the first request may take approximately 30 seconds.
- Separate usage limits and pricing policies apply to Gemini API calls.