Searching for information in personal archives often becomes a challenge when you remember the context but forget the exact wording. Standard tools like ripgrep are effective only for literal text matches, which led to the creation of anygrep, a CLI utility that indexes notes, PDF documents, and images in a unified semantic space. It allows users to find files by meaning, even when searching for error screenshots or Japanese notes using English queries.
Technically, anygrep is based on Google's EmbeddingGemma 2 model, converted to the int8 ONNX format. This allows complex computations to run directly on the CPU, avoiding reliance on PyTorch or GPUs. The developer optimized the image processing pipeline by porting the logic to NumPy, which ensures high accuracy of vector embeddings while consuming significantly fewer resources compared to full-scale machine learning libraries, making it accessible for standard hardware.
The tool's performance on a CPU is quite acceptable for local use. Indexing 10,000 images takes about 3.5 hours, while text-based searches happen almost instantly after the model loads. Importantly, the tool supports flexible image token budget settings, allowing users to choose the balance between processing speed and visual detail, which is critical for recognizing small text on screenshots or complex diagrams within a reasonable timeframe.
To address the issue of imprecise matches, the developer implemented a hybrid search mechanism. If a query contains specific identifiers or numbers, anygrep uses SQLite FTS5 for exact string matching. This prevents the semantic model from ignoring important technical data, such as invoice numbers or error codes, ensuring the reliability of results in professional scenarios where precision is just as important as semantic understanding.
One of the main challenges of semantic search is excessive result noise. To mitigate this, a dynamic relevance threshold was introduced, based on median scores compared to a reference dataset. This allows the tool to filter out irrelevant results even when the query is short or abstract. Users can also utilize the --weak flag to view results that did not pass the primary filter, providing transparency into the search process.
The tool also solves the problem of near-duplicates by using word-pair hash signatures for text files. This allows for grouping similar documents, such as monthly payslips, without losing unique data. anygrep is a fully local solution, requires no telemetry, and ensures data privacy, as the index is stored in a standard SQLite file on your device, making it an excellent choice for managing private archives securely.
🔗 Original Source: Read Original Article
