Skip to content

renantmagalhaes/semantic-vault

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Semantic Vault β€” AI-Powered Semantic Search for Your Markdown Notes

πŸ” Ask questions to your knowledge base with OpenAI, Gemini, or Local LLMs
πŸ—‚οΈ Tag Generator Included β€” Perfect for Obsidian Vaults


πŸ“– Overview

Semantic Vault brings semantic search to your Markdown and text notes, optimized for Obsidian users but adaptable to any folder with .md or .txt files. Ask natural language questions and get relevant answers based on your notes.

Includes an AI-powered tag generator to enrich your notes automatically β€” great for organizing Obsidian vaults.

alt text

alt text


πŸš€ Features

βœ… Semantic Search with Embeddings β€” Find relevant notes intelligently, no file limits!
βœ… AI-Powered Semantic Search (Chat interface)
βœ… Beautiful Web Interface β€” Modern browser-based UI
βœ… Supports OpenAI, Gemini, and Ollama Local LLMs
βœ… CPU-Only Embeddings β€” No GPU required, runs efficiently on any machine
βœ… Markdown & Text File Support (.md and .txt files)
βœ… AI Tag Generation Script β€” YAML Compatible
βœ… Easy Setup with requirements.txt


πŸ› οΈ Requirements

  • Python 3.9+
  • Dependencies (use the provided requirements.txt)
pip3 install -r requirements.txt
  • No GPU Required β€” Semantic search runs efficiently on CPU
  • Optional:

πŸ“‚ Project Structure

semantic-vault/
β”œβ”€β”€ semanticVault.py      # Main Semantic Search Script
β”œβ”€β”€ auto_tag_generation.py # AI Tag Generator for Markdown Notes
β”œβ”€β”€ templates/
β”‚   └── index.html        # Web UI template
β”œβ”€β”€ .embeddings_cache/    # Cached embeddings (auto-generated)
β”œβ”€β”€ requirements.txt      # Python dependencies
β”œβ”€β”€ .env                  # API keys configuration (create this)
└── README.md

πŸ”§ Setup

1. Clone the Repository

git clone https://github.com/renantmagalhaes/semantic-vault.git
cd semantic-vault

2. Install Dependencies

pip3 install -r requirements.txt

3. Configure Environment

Create a .env file:

OPENAI_API_KEY="your_openai_key_here"
GEMINI_API_KEY="your_openai_key_here"

Only required if using OpenAI or Gemini models.


πŸ’‘ Semantic Search Usage

1. Set Your Vault Path

Edit semanticVault.py:

VAULT_PATH = "/path/to/your/obsidian/vault"

2. Configure Semantic Search (Optional)

Semantic search is enabled by default and works with unlimited files! Edit semanticVault.py:

USE_SEMANTIC_SEARCH = True  # Enable semantic search (recommended)
TOP_K_NOTES = 10            # Number of most relevant notes to use (adjust as needed)

Benefits:

  • βœ… No file limits β€” Works with vaults of any size
  • βœ… Cost efficient β€” Only sends relevant notes to LLM (saves API costs)
  • βœ… Better accuracy β€” Finds semantically relevant notes, not random ones
  • βœ… CPU-only β€” No GPU required, runs on any machine

3. Choose Your AI Model

In semanticVault.py:

USE_MODEL = "openai"  # Options: "openai", "gemini", "ollama"

Note: Semantic search works with all three providers! The embeddings are generated locally using CPU, then only the most relevant notes are sent to your chosen LLM.

4. Run the Search Tool

CLI Mode (Command Line):

python3 ./semanticVault.py

Ask your question in the terminal, get AI-driven answers based on your notes.

Web Interface Mode (Recommended):

python3 ./semanticVault.py --web

Then open your browser to http://localhost:5000 to access the beautiful web interface!

The web UI features:

  • 🎨 Modern, responsive design with gradient themes
  • πŸ’¬ Chat-style interface for natural conversations
  • πŸ“Š Real-time statistics (note count, model type)
  • ⚑ Smooth animations and loading indicators
  • πŸ“± Mobile-friendly responsive layout

How Semantic Search Works

  1. First Run: Generates embeddings for all your notes (one-time, ~1-5 minutes depending on vault size)

    • Embeddings are cached automatically in .embeddings_cache/
    • Uses lightweight CPU-only model (all-MiniLM-L6-v2)
  2. Subsequent Queries:

    • Finds the top K most relevant notes using semantic similarity
    • Only sends those relevant notes to the LLM (saves costs!)
    • Typically finds results in <1 second
  3. Automatic Updates: Embeddings are regenerated only when notes change

Performance:

  • First run: 10-30 seconds (small vault) to 2-5 minutes (large vault)
  • Subsequent queries: Near-instant (uses cached embeddings)
  • No GPU needed: Runs efficiently on CPU

🏷️ AI Tag Generator for Notes

Enrich your notes with relevant, AI-suggested tags.

Usage

python3 ./auto_tag_generation.py

Optional flags:

Flag Description
--dry-run Preview changes, no files modified
--force Overwrite all existing tags with new ones

Edit tag_generation.py:

VAULT_PATH = "/path/to/your/obsidian/vault"
USE_MODEL = "openai"  # or "gemini" or "ollama"

βœ… Tags are inserted in YAML frontmatter β€” ideal for Obsidian users.


πŸ–₯️ Ollama Local LLM (Optional)

Prefer privacy or offline capabilities? Run fully local models with Ollama.

Install Ollama

curl -fsSL https://ollama.com/install.sh | sh

For Linux/macOS or check latest guides on ollama.com.

Pull Models

Examples:

ollama run mistral
ollama run llama3

Edit:

USE_MODEL = "ollama"
OLLAMA_MODEL = "mistral"

Supports lightweight, privacy-friendly models locally.


🌟 Future Plans

  • Full-featured Obsidian Plugin (Separate project)
  • Persistent chat mode to refine questions without losing context
  • More advanced tag generation modes
  • CLI improvements and advanced filters
  • Custom embedding models and fine-tuning options

πŸ“’ Contributing

Open to contributions β€” PRs, issues, suggestions welcome!


πŸ“œ License

MIT License β€” Free to use, modify, and distribute.


πŸ€– Acknowledgments

  • OpenAI
  • Google Gemini
  • Ollama
  • Sentence Transformers (for semantic search embeddings)
  • Inspired by Obsidian Copilot

✨ Stay in Control of Your Knowledge β€” Search Smarter

About

πŸ” Ask questions to your knowledge base with OpenAI, Gemini, or Local LLMs πŸ—‚οΈ Tag Generator Included β€” Perfect for Obsidian Vaults

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors