A Zettelkasten-inspired knowledge base with Embeddings-Based Retrieval
ZKB is a command-line tool for managing a Zettelkasten-inspired knowledge base of markdown notes. It helps you organize, link, and analyze your notes efficiently, while also providing powerful question-answering capabilities through Embeddings-Based Retrieval (EBR).
- Scan and index markdown notes
- Find orphaned notes (notes not linked to by any other note)
- Detect broken links between notes
- Find backlinks to a specific note
- Create, read, update, and delete notes
- Search notes based on content or metadata
- Generate and index question-answer pairs from notes
- Query the knowledge base using natural language questions (EBR)
-
Clone the repository:
git clone https://github.com/witt3rd/zkb.git
-
Install dependencies:
pip install .
python -m zkb.cli [--data-dir DATA_DIR] [--db-path DB_PATH] {command} [args]
Available commands:
scan
: Scan notes and update the databasefind-orphans
: Find orphaned notesfind-broken-links
: Find broken linksfind-backlinks {filename}
: Find backlinks to a specific note
You can set the following environment variables or use a .env
file:
DATA_DIR
: Directory containing markdown notes (default: "data/")DB_DIR
: Directory for the SQLite database (default: "db/")
ZKB incorporates Embeddings-Based Retrieval (EBR) through the qa-store library. This feature enables:
- Automatic generation of question-answer pairs from your notes.
- Indexing of these pairs using embeddings for efficient retrieval.
- Natural language querying of your knowledge base.
EBR allows you to ask questions about your notes and receive relevant answers, even if the exact wording doesn't match. This powerful feature enhances the discoverability and utility of your knowledge base.
- ZKB scans markdown files in the specified directory.
- It parses each note, extracting metadata, content, and links.
- The extracted information is stored in an SQLite database.
- Question-answer pairs are generated from the notes and indexed using embeddings.
- Various operations can be performed on the indexed data, including EBR-based querying.
- Scanning notes: Parses markdown files, extracts metadata and links, and updates the database.
- Finding orphaned notes: Identifies notes that are not linked to by any other note.
- Detecting broken links: Finds links that point to non-existent notes.
- Finding backlinks: Discovers which notes link to a specific note.
- Creating/Reading/Updating/Deleting notes: Manages individual notes in the knowledge base.
- Searching notes: Finds notes based on content or metadata.
- Generating and indexing QA pairs: Creates question-answer pairs from notes and indexes them for retrieval.
- Querying the knowledge base: Uses natural language questions to retrieve relevant information from the notes.
- Note: Represents a markdown note with properties like filename, full path, metadata, content, and links.
- Database: SQLite database with two main tables:
notes
: Stores information about each note (id, filename, full_path, title)links
: Stores links between notes (from_note, to_note, display_text)
- QA Knowledge Base: Stores and indexes question-answer pairs generated from notes.
- ZKB: Main class that orchestrates the operations.
- Database: Handles database operations.
- Note: Represents and parses individual markdown notes.
- CLI: Provides the command-line interface.
- QuestionAnswerKB: Manages the generation, indexing, and retrieval of QA pairs.
We're constantly working to improve zkb. Here are some features and enhancements we're planning to implement:
- Implement a web-based user interface
- Add support for tags and categories
- Improve the natural language processing capabilities
- Implement a plugin system for extensibility
- Add visualization tools for exploring the knowledge graph
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- 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 licensed under the MIT License - see the LICENSE file for details.
Donald Thompson - @dt_public - [email protected]
Project Link: https://github.com/witt3rd/zkb