Multi-scale document search with φ-weighted decay. Search meaning, not just text.
Project description
fractal-search
Multi-scale document search with φ-weighted decay. Search meaning, not just text.
What it does
Documents are indexed at three scales — document, section, paragraph — like a fractal. Search results are weighted by the golden ratio (φ = 1.618) so direct matches score highest and related matches decay naturally.
Document level → weight: 1.0
Section level → weight: 1/φ ≈ 0.618
Paragraph level → weight: 1/φ² ≈ 0.382
Related terms → weight: 1/φ³ ≈ 0.236
Install
pip install fractal-search
CLI Usage
# Search file contents
fsearch "your query" ~/Documents/
# Search filenames only
fsearch "bazinga deploy" ~/Projects/ --names
# Clean output (just paths, pipeable)
fsearch "darmiyan" ~/Research/ --paths-only
# JSON output
fsearch "trust dimension" . --json
# Verbose with pattern explanations
fsearch "SSRI calcium" ~/papers/ -v --max 20
Python API
from fractal_search import FractalSearchEngine
engine = FractalSearchEngine()
# Add individual documents
engine.add("doc1", "My Paper", "Content about fractals...")
engine.add("doc2", "My Notes", "Something about cooking...")
# Or index a directory
engine.add_directory("~/Documents/", extensions=('.md', '.txt', '.py'))
# Search
results = engine.search("fractal patterns")
for r in results:
print(f"{r.score:.1f} {r.title} {r.doc_id}")
print(f" terms: {r.matching_terms}")
print(f" snippet: {r.snippet[:100]}")
How it works
- Multi-scale fingerprinting — Each document is tokenized at three levels (whole → sections → paragraphs), creating a self-similar index structure
- φ-weighted decay — Results at deeper index levels are weighted by 1/φ per level, using the golden ratio as the optimal relevance decay
- Co-occurrence sub-indexing — Frequently co-occurring terms create sub-indices (fractal branching), so searching "SSRI" also surfaces "sertraline" and "emotional blunting"
- Adaptive depth — Search depth auto-adjusts based on query complexity using Fibonacci sequence modulation
Why φ?
The golden ratio is the fixed point of self-reference: φ - 1 = 1/φ. It's the optimal boundary between local relevance (this paragraph) and global relevance (the whole document). This isn't arbitrary — it's the same ratio that appears in natural information structures from DNA to galaxies.
Author
Abhishek Srivastava — github.com/0x-auth
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fractal_search-0.1.1.tar.gz.
File metadata
- Download URL: fractal_search-0.1.1.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6af0c68cd53f00ddccc7da64990bdeb5bcf3dca57f2213f54fa01869b9548a0
|
|
| MD5 |
08577eedd7d2d0cea9f8ebd309ffdca3
|
|
| BLAKE2b-256 |
9c767904e8b0e151911b0fd175531b1e31b2626b89a26afe9790f28e2157061e
|
File details
Details for the file fractal_search-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fractal_search-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edf9ae2992c5857c5b685867523a265e58206d35126ba3a497a44186ad41b18a
|
|
| MD5 |
e8b43a8099f88290d2485c845bc142e4
|
|
| BLAKE2b-256 |
b2a10914b198b12f0441d462d1f7a67ab19c6f12e0b1f20b2ed0ba23bdeeb7cc
|