--- license: mit library_name: sentence-transformers pipeline_tag: sentence-similarity base_model: - BAAI/bge-base-en-v1.5 - cross-encoder/ms-marco-MiniLM-L-6-v2 tags: - semantic-search - vector-database - chromadb - sentence-transformers - embeddings - reranking - two-stage-retrieval - information-retrieval - nlp - rag - bge-base - cross-encoder - python - fastapi - streamlit - docker - food-science - flavor-pairing - culinary-ai - recipe-recommendation - cooking - taste-chemistry --- # FlavorVector ![FlavorVector Benchmarks](assets/benchmark_dashboard.png) ![FlavorVector 10-Taste & Cuisine Coverage](assets/taste_coverage.png) **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. ## Repository Contents - `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. ## Evaluation Benchmarks 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`) | ## Standalone Usage ```python 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']}") ```