Skip to content

jpbow/semantic-search-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Semantic Search CLI

A simple command-line tool for crawling directories, converting documents to markdown, and performing semantic search using hybrid dense/sparse embeddings with AI-powered responses.

Supported File Types

  • PDF (.pdf)
  • Microsoft Excel (.xlsx)
  • Microsoft Word (.doc, .docx)
  • Microsoft PowerPoint (.ppt, .pptx)

Project Structure

src/
├── main.rs           # Main application logic and CLI interface
├── cli_ui.rs         # Terminal UI components and styling
├── ai.rs             # OpenAI-compatible API client
└── qdrant_client.rs  # Qdrant vector database operations

Installation & Quick Start

Prerequisites

  • Docker
  • Rust 1.70+
  • OpenAI API key (or compatible API like Google Gemini)
  1. Install required system packages on Ubuntu/Debian:
sudo apt update
sudo apt install -y libssl-dev pkg-config
  1. Clone the repository:
git clone <repository-url>
cd semantic-search-cli
  1. Install dependencies:
cargo build --release
  1. Set up environment variables:
cp env.example .env
# Edit .env with your API keys and configuration

AI config

  • OpenAI: Use https://api.openai.com/v1/chat/completions with gpt-3.5-turbo or gpt-4
  • Google Gemini: Use https://generativelanguage.googleapis.com/v1beta/openai/chat/completions with gemini-2.5-flash
  • Other OpenAI-compatible APIs: Configure URL and model as needed
  1. Start the Qdrant container
docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant
  1. Run!
# Process all supported files in a directory:
cargo run -- --directory data

# Perform semantic search across processed documents:
cargo run -- --search "What are the safety requirements for tower installation?"

# Only process files modified since a specific timestamp:
cargo run -- --directory data --since 1640995200  # Unix timestamp

Command Line Options

  • --directory, -d: Directory to crawl (default: data)
  • --since, -s: Only process files modified since this Unix timestamp
  • --embed: Convert files to markdown and print content
  • --search: Perform semantic search with the given query

Embedding Models Used

  • Dense: BGESmallENV15 (384 dimensions)
  • Sparse: SPLADEPPV1
  • Reranker: JINARerankerV1TurboEn

Search Process

  1. Generate dense and sparse embeddings for the query
  2. Perform vector similarity search in Qdrant
  3. Combine results using Reciprocal Rank Fusion (RRF)
  4. Rerank top results using the reranker model
  5. Generate AI response based on retrieved context

Releases

# Tag release
git tag -a 0.2.0 -m "Message"

# Push tag and CI does the rest
git push --tags

About

Vectorize and search documents, locally!

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages