Skip to content

Commit

Permalink
Merge pull request #32 from severian42/dev
Browse files Browse the repository at this point in the history
Refactor/Update

Here's a summary of the key changes in this release:

1. Major UI and functionality updates:
   - New interactive user interface with comprehensive features
   - Support for local models and OpenAI-compatible APIs
   - Real-time 2D/3D graph visualization
   - Enhanced file and settings management
   - Improved querying capabilities

2. Expanded compatibility:
   - LLM agnostic: Support for Ollama and custom base URLs/models
   - Flexible embedding options

3. New features:
   - Custom configurable graph visuals
   - Preset query/indexing library options
   - Improved error handling and logging

4. Documentation updates:
   - Revised installation and setup instructions
   - Updated usage guide for new UI features
   - Expanded troubleshooting section

5. Backend improvements:
   - Numerous bug fixes and optimizations
   - Updated dependencies and requirements

6. Roadmap updates:
   - Added recently completed features
   - Outlined upcoming planned improvements

7. File changes:
   - Major updates to app.py and other core files
   - New cache and output files from testing
   - Updated settings.yaml and requirements.txt

8. Removed visualize-graphml.py as functionality is now integrated into the main app
  • Loading branch information
severian42 authored Jul 19, 2024
2 parents 5f2e3ba + 45170bb commit 5c26db0
Show file tree
Hide file tree
Showing 603 changed files with 9,705 additions and 448 deletions.
Binary file modified .DS_Store
Binary file not shown.
173 changes: 131 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,181 @@
# 🕸️ GraphRAG Local with Ollama and Gradio UI
# 🕸️ GraphRAG Local with Interactive UI

Welcome to **GraphRAG Local with Ollama and Interactive UI**! This is an adaptation of Microsoft's [GraphRAG](https://github.com/microsoft/graphrag), tailored to support local models using Ollama and featuring a new interactive user interface.

*NOTE: The app gained traction much quicker than I anticipated so I am working to get any found bugs fixed and suggested improvements integrated. Right now it is fully functional, tested only on my Mac Studio M2 though.

The next update is a major refactor and overall improvement in all the areas so it has unfortunately taken a bit longer than expected. I am trying to be fluid with the adjustments and so will try to update as often as possible.

Changes being made right now and tested:

- LLM agnostic: Use Ollama or set your own base URL and local model for LLM and Embedder
- Launch your own GraphRAG API server so you can use the functions in your own external app
- Dockerfile for easier deployment
- Experimental: Mixture of Agents for Indexing/Query of knowledge graph
- Custom configurable graph visuals
- Preset Query/Indexing library options to quickly and easily harness all the GraphRAG args
- More file formats (CSV, PDF, etc)
- Web search/Scraping

Feel free to open an Issue if you run into an error and I will try to address it ASAP so you don't run into any downtime*
Welcome to **GraphRAG Local with Interactive UI**! This is an adaptation of Microsoft's [GraphRAG](https://github.com/microsoft/graphrag), tailored to support local models and featuring a comprehensive interactive user interface.

## 📄 Research Paper

For more details on the original GraphRAG implementation, please refer to the [GraphRAG paper](https://arxiv.org/pdf/2404.16130).

## 🌟 Features

- **Local Model Support:** Leverage local models with Ollama for LLM and embeddings.(I highly recommend using the 'sciphi/triplex' Ollama model for Indexing your data) ('ollama pull sciphi/triplex')
- **Cost-Effective:** Eliminate dependency on costly OpenAI models.
- **Local Model Support:** Leverage local models for LLM and embeddings, including compatibility with Ollama and OpenAI-compatible APIs.
- **Cost-Effective:** Eliminate dependency on costly cloud-based models by using your own local models.
- **Interactive UI:** User-friendly interface for managing data, running queries, and visualizing results.
- **Real-time Graph Visualization:** Visualize your knowledge graph in 3D using Plotly.
- **Real-time Graph Visualization:** Visualize your knowledge graph in 2D or 3D using Plotly.
- **File Management:** Upload, view, edit, and delete input files directly from the UI.
- **Settings Management:** Easily update and manage your GraphRAG settings through the UI.
- **Output Exploration:** Browse and view indexing outputs and artifacts.
- **Logging:** Real-time logging for better debugging and monitoring.
- **Flexible Querying:** Support for global, local, and direct chat queries with customizable parameters.

![GraphRAG UI](ui.png)

## 🗺️ Roadmap

**Important Note:** GraphRAG Local UI is currently a major work in progress. As we strive to make the application more stable with local LLMs, users should expect to encounter some bugs. We appreciate your patience and feedback during this development phase.

*The app gained traction much quicker than anticipated, so we are actively working to fix bugs and integrate suggested improvements. While it is currently functional, it has been primarily tested on a Mac Studio M2.*

My vision for GraphRAG Local UI is to become the ultimate GraphRAG app for local LLMs, incorporating as many cool features and knowledge graph tools as possible. I am continuously working on improvements and new features.

### Recent Updates
- [x] LLM agnostic: Use Ollama or set your own base URL and local model for LLM and Embedder
- [x] Custom configurable graph visuals
- [x] Preset Query/Indexing library options to quickly and easily harness all the GraphRAG args

### Upcoming Features
- [ ] Dockerfile for easier deployment
- [ ] Launch your own GraphRAG API server for use in external applications
- [ ] Experimental: Mixture of Agents for Indexing/Query of knowledge graph
- [ ] Support for more file formats (CSV, PDF, etc.)
- [ ] Web search/Scraping capabilities
- [ ] Enhanced error handling and user feedback
- [ ] Improved performance and scalability
- [ ] Advanced graph analysis tools
- [ ] Integration with popular knowledge management tools
- [ ] Collaborative features for team-based knowledge graph building

I am committed to making GraphRAG Local UI the most comprehensive and user-friendly tool for working with knowledge graphs and local language models. Your feedback and suggestions are much needed in shaping the future of this project.

Feel free to open an Issue if you run into an error, and we will try to address it as soon as possible to minimize any downtime you might experience.

## 📦 Installation and Setup

Follow these steps to set up and run GraphRAG Local with Ollama and Interactive UI:
Follow these steps to set up and run GraphRAG Local with Interactive UI:

1. **Create and activate a new conda environment:**
```bash
conda create -n graphrag-ollama -y
conda activate graphrag-ollama
conda create -n graphrag-local -y
conda activate graphrag-local
```

2. **Install Ollama:**
Visit [Ollama's website](https://ollama.com/) for installation instructions.
4. **Install the required packages:**
2. **Install the required packages:**
```bash
pip install -r requirements.txt
```

4. **Launch the interactive UI:**
3. **Launch the interactive UI:**
```bash
gradio app.py
```

or

```bash
python app.py
```

6. **Using the UI:**
- Once the UI is launched, you can perform all necessary operations through the interface.
- This includes initializing the project, managing settings, uploading files, running indexing, and executing queries.
- The UI provides a user-friendly way to interact with GraphRAG without needing to run command-line operations.
4. **Access the UI:**
Open your web browser and navigate to `http://localhost:7860` to access the GraphRAG Local UI.

## 🖥️ Using the GraphRAG Local UI

### Data Management

1. **File Upload:**
- Navigate to the "Data Management" tab.
- Use the "File Upload" section to upload .txt files to the input directory.

2. **File Management:**
- View, edit, and delete uploaded files in the "File Management" section.
- Use the "Refresh File List" button to update the list of available files.

### Indexing

1. **Configure Indexing:**
- Go to the "Indexing" tab.
- Set the root directory (default is "./ragtest").
- Optionally upload a config file.
- Adjust other parameters like verbosity, caching, and output formats.

Note: The UI now handles all the operations that were previously done through command-line instructions, making the process more streamlined and user-friendly.
2. **Run Indexing:**
- Click "Run Indexing" to start the indexing process.
- Monitor progress in real-time through the output box and progress bar.
- Use "Stop Indexing" if you need to halt the process.

### KG Chat/Outputs

1. **Explore Indexed Data:**
- Select an output folder from the dropdown.
- Browse through the folder contents and view file information and content.

2. **Visualize Graph:**
- Select a GraphML file from the output folder.
- Click "Visualize Graph" to generate a 2D or 3D visualization of your knowledge graph.
- Customize the visualization using the "Visualization Settings" accordion.

### LLM Settings

1. **Configure LLM and Embeddings:**
- Set API base URLs and keys for both LLM and embeddings.
- Choose the service type (OpenAI-compatible or Ollama).
- Select models from the dropdown or refresh the list.

2. **Adjust Parameters:**
- Set the system message, context window, temperature, and max tokens.
- Click "Update LLM Settings" to save your changes.

### Querying

1. **Choose Query Type:**
- Select between global, local, or direct chat queries.

2. **Select Preset or Custom Options:**
- Choose a preset query option or customize your query parameters.

3. **Enter Your Query:**
- Type your query in the input box and click "Send Query" or press Shift+Enter.

4. **View Results:**
- See the chat history and responses in the chat interface.

### Other Settings

- Adjust additional GraphRAG settings in the "YAML Settings" tab as needed.

## 🛠️ Customization

Users can experiment by changing the models in the `settings.yaml` file. The LLM model expects language models like llama3, mistral, phi3, etc., and the embedding model section expects embedding models like mxbai-embed-large, nomic-embed-text, etc., which are provided by Ollama. You can find the complete list of models provided by Ollama [here](https://ollama.com/library).
Users can experiment with different models and settings:

- For OpenAI-compatible APIs: Use any model compatible with the OpenAI API format.
- For Ollama: Use models like llama2, mistral, phi-2, etc. Find the complete list of Ollama models [here](https://ollama.com/library).

## 📊 Visualization

The UI now includes a 3D graph visualization feature. To use it:
The UI includes a 2D/3D graph visualization feature:

1. Run indexing on your data.
2. Go to the "KG Chat/Outputs" tab.
3. Select the latest output folder and navigate to the GraphML file.
4. Click the "Visualize Graph" button.
5. Customize the visualization using the settings provided.

## 🚀 Advanced Usage

1. Run indexing on your data
2. Go to the "Indexing Outputs" tab
3. Select the latest output folder and navigate to the GraphML file
4. Click the "Visualize Graph" button
- **Custom CLI Arguments:** In the query interface, advanced users can add custom CLI arguments for more granular control over the query process.

## 📚 Citations

- Original GraphRAG repository by Microsoft: [GraphRAG](https://github.com/microsoft/graphrag)
- Ollama: [Ollama](https://ollama.com/)

---

## Troubleshooting

- If you can't run `gradio app.py`, try running `pip install --upgrade gradio` and then exit out and start a new terminal. It should then load and launch properly as a Gradio app
- On Windows, if you run into and encoding/UTF error, you can change it to the correct format in the YAML Settings menu
- Indexing Errors: These are still tough to debug a track down as it is dependant on your specific pipeline of llms and embedders. Right now it seems to call /v1/embeddings no matter what in the Index workflow, but I think I found a workaround that allows Ollama and other local options. I'll keep trying to reenforce the Indexing process to make it more stable and robust.

For any issues or feature requests, please open an issue on the GitHub repository. Happy knowledge graphing!
Loading

0 comments on commit 5c26db0

Please sign in to comment.