An advanced chatbot that harnesses the power of local LLMs to unlock hyper-precise answers from your document repository.
EcoAI is an innovative, cutting-edge chatbot designed to facilitate seamless interactions between users and their data. By leveraging local Large Language Models (LLMs) and a sophisticated retrieval pipeline, EcoAI enables users to engage in more productive, informative, and personalized conversations.
Standard retrieval systems often struggle to find the precise "nugget" of information within a large document chunk. Our system overcomes this with a novel two-level retrieval architecture that ensures the answers are not just relevant, but hyper-focused and accurate.
-
Document Processing & Propositioning:
- Instead of just chunking documents, the system first processes them into propositions. A proposition is a single, atomic fact or statement extracted from the text. This creates a highly granular and semantically rich knowledge base.
-
Level 1: Proposition-Based Retrieval:
- When a user asks a query, the system first searches against the database of propositions. This allows it to find the exact sentences or facts that are semantically closest to the user's question.
-
Level 2: Agentic Re-ranking & Contextualization:
- The retrieved propositions and their source documents are passed to a Re-ranking Agent. This agent, powered by an Ollama LLM, analyzes the propositions in their original context and intelligently re-ranks the source documents to select the best one for formulating a complete answer.
Follow these steps to set up and run the project on your local machine.
- Python 3.11 or higher.
- Ollama installed and running locally. You can download it from ollama.com.
First, clone the project repository to your local machine:
git clone <your-repository-url>
cd <your-repository-name>After installing Ollama, you need to pull the language model. Run the following command in your terminal:
ollama pull llama3.1:8b-instruct-fp16Note: You can use any model supported by Ollama. To change the model, simply update the LLM_MODEL_NAME variable in the source/config/llm_config.py file.
This project uses Poetry for dependency management. If you don't have it, run the appropriate command for your OS.
Linux, macOS, Windows (WSL):
curl -sSL [https://install.python-poetry.org](https://install.python-poetry.org) | python3 -Windows (PowerShell):
(Invoke-WebRequest -Uri [https://install.python-poetry.org](https://install.python-poetry.org) -UseBasicParsing).Content | py -Verify the installation by running poetry --version.
Navigate to the project root (where pyproject.toml is located) and run:
poetry installThis will create a virtual environment and install all required packages.
eval $(poetry env activate)
1. Prepare Your Data
- Create a folder named
datain the root of the project directory.
mkdir data- Place all your documents (
.pdf, .txt, .md,etc.) inside thisdatafolder.
The application will automatically create a vector_data folder to store the database on its first run.
2. Ingest Your Documents (First-Time Setup)
To have EcoAI process your documents and build its knowledge base, you need to run the ingestion pipeline once.
-
Open the app.py file in the root directory.
-
Find the line: app = StreamlitApp(load_docs=False)
-
Change it to: app = StreamlitApp(load_docs=True)
-
Save the file and run the application once from your terminal:
poetry shell
streamlit run app.py-
This will trigger the data loading process. You will see progress bars in your terminal as it processes the files.
-
IMPORTANT: After the process is complete and the app is running, stop the app (Ctrl+C in the terminal) and change the line in app.py back to app = StreamlitApp(load_docs=False). This prevents the app from re-processing the same files every time it starts
3. Launch the Application
First, activate the virtual environment using Poetry:
poetry shellThen, run the Streamlit app:
streamlit run app.pyThis will start a local web server and open the EcoAI interface in your browser.
IMPORTANT NOTE: The first time you run the application and submit a query, it may take longer to respond. This is because the embedding and re-ranker models are being downloaded and cached in the background. Subsequent runs will be much faster.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
-
Fork the Project
-
Create your Feature Branch (git checkout -b feature/AmazingFeature)
-
Commit your Changes (git commit -m 'Add some AmazingFeature')
-
Push to the Branch (git push origin feature/AmazingFeature)
-
Open a Pull Request
This project is distributed under the MIT License.