FlavorVector is a standalone, local-first semantic cooking substitution, flavor-pairing, and pantry flavor-bridge engine grounded in food-science chemistry and volatile aroma compounds. This repository includes the complete codebase, Streamlit UI, FastAPI service, pre-indexed ChromaDB database, and bundled transformer weights for offline execution.
models/bi_encoder/ — Bundled BAAI/bge-base-en-v1.5 dense retrieval model (~438 MB).models/cross_encoder/ — Bundled cross-encoder/ms-marco-MiniLM-L-6-v2 reranker (~91 MB).chroma_db/ — Pre-built persistent vector store (143 vectors across flavor_substitutions and flavor_pairings).flavor_atlas.json — Exported structured food-science substitution rules and ingredient compound profiles.app/ — Core retrieval engine (engine.py), live web synthesis (live_fetcher.py), ratio scaler (balancer.py), and FastAPI endpoints (main.py).streamlit_app.py — Interactive Streamlit dashboard with 10-taste Plotly radar charts.scripts/ & tests/ — Atlas builders, 25-case benchmark runner, PNG chart generator, and pytest suite.Benchmarked across 25 culinary edge cases on NVIDIA GeForce RTX 5060 Laptop GPU:
| Category | Metric | Stage 1 (bge-base-en-v1.5) |
Two-Stage (+ Cross-Encoder) |
|---|---|---|---|
| Accuracy | Hit Rate@1 | 100.0% | 100.0% |
| Accuracy | Hit Rate@3 | 100.0% | 100.0% |
| Ranking Quality | Mean Reciprocal Rank (MRR) | 100.0% | 100.0% |
| Ranking Quality | NDCG@3 | 100.0% | 100.0% |
| Latency | Substitutions (p50 / p95) | 6.67 ms | 28.95 ms / 30.81 ms |
| Latency | Flavor Pairing (p50 / p95) | — | 36.38 ms / 41.52 ms |
| Latency | Pantry Flavor Bridge (p50 / p95) | — | 60.04 ms / 62.85 ms |
| Throughput | Sustained QPS | — | 35.1 QPS (/substitute) · 26.6 QPS (/pair) |
import sys
from huggingface_hub import snapshot_download
# Downloads the full repo (bundled bi-encoder, cross-encoder, chroma_db, and app)
local_dir = snapshot_download(repo_id="Srihari2020/FlavorVector", repo_type="model")
sys.path.insert(0, local_dir)
from app.engine import FlavorEngine
engine = FlavorEngine()
subs, _ = engine.search_substitutes(
query="what can replace buttermilk and give the same tanginess in pancakes?",
top_k=3,
)
for hit in subs:
print(f"#{hit['rank']} ({hit['relevance_score']*100:.1f}%): {hit['substitute']}")
models/bi_encoder/model.safetensors 418 MiBmodels/cross_encoder/model.safetensors 87 MiBchroma_db/140b49ef-4890-4dc9-a8dc-fbe2c7e4c232/data_level0.bin 313.7 KiBchroma_db/27b86271-f8e4-4070-b62f-53c53012e97c/data_level0.bin 313.7 KiBchroma_db/8c466417-0f2a-47a0-9d5d-571ab9a0a8b9/data_level0.bin 313.7 KiBchroma_db/9aee08b4-2b42-40db-9c8a-3d0965c92da2/data_level0.bin 313.7 KiBchroma_db/b302856e-1a94-4882-b06b-ec34ca18d293/data_level0.bin 313.7 KiBchroma_db/ce7ed54d-b23e-4073-932d-1e875bc21ce8/data_level0.bin 313.7 KiBchroma_db/140b49ef-4890-4dc9-a8dc-fbe2c7e4c232/length.bin 0.4 KiBchroma_db/27b86271-f8e4-4070-b62f-53c53012e97c/length.bin 0.4 KiBchroma_db/8c466417-0f2a-47a0-9d5d-571ab9a0a8b9/length.bin 0.4 KiBchroma_db/9aee08b4-2b42-40db-9c8a-3d0965c92da2/length.bin 0.4 KiBchroma_db/b302856e-1a94-4882-b06b-ec34ca18d293/length.bin 0.4 KiBchroma_db/ce7ed54d-b23e-4073-932d-1e875bc21ce8/length.bin 0.4 KiBchroma_db/140b49ef-4890-4dc9-a8dc-fbe2c7e4c232/header.bin 0.1 KiBchroma_db/27b86271-f8e4-4070-b62f-53c53012e97c/header.bin 0.1 KiBchroma_db/8c466417-0f2a-47a0-9d5d-571ab9a0a8b9/header.bin 0.1 KiBchroma_db/9aee08b4-2b42-40db-9c8a-3d0965c92da2/header.bin 0.1 KiBchroma_db/b302856e-1a94-4882-b06b-ec34ca18d293/header.bin 0.1 KiBchroma_db/ce7ed54d-b23e-4073-932d-1e875bc21ce8/header.bin 0.1 KiBchroma_db/140b49ef-4890-4dc9-a8dc-fbe2c7e4c232/link_lists.bin -chroma_db/27b86271-f8e4-4070-b62f-53c53012e97c/link_lists.bin -chroma_db/8c466417-0f2a-47a0-9d5d-571ab9a0a8b9/link_lists.bin -chroma_db/9aee08b4-2b42-40db-9c8a-3d0965c92da2/link_lists.bin -chroma_db/b302856e-1a94-4882-b06b-ec34ca18d293/link_lists.bin -chroma_db/ce7ed54d-b23e-4073-932d-1e875bc21ce8/link_lists.bin -BAAI/bge-base-en-v1.5