Откройте страницу на десктопе
для корректного отображения схемы.
Полный data flow портфолио-проекта: offline-индексация схем (01) → online query pipeline на LangGraph (02) → слой LLM-провайдеров с кэшем (03) → eval-контур с residue-циклом (04). Подписи на стрелках — что именно течёт между узлами; цифры в кружках — порядок шагов happy path.
scripts/download_data.py → data/
schema_index/introspector.py
SQLAlchemy reflection (read-only): таблицы, колонки, PK/FK, top-K sample values, NULL count, distinct count.
schema_index/chunker.py
1 таблица = 1 card: имя + колонки + типы + samples + FK от/к + business-hints; fk_targets → metadata.
schema_index/indexer.py
Upsert со stable chunk_id — без дублей при переиндексации; API чтения — SchemaIndex.
ChromaDB · chroma_data/ (persistent)
scripts/build_fewshot_index.py
Q→SQL только из train · hard guard от dev-leakage.
mistral-embed · 1024-dim
CachingEmbeddingProvider → diskcache: реиндексация = 0 API.
in-memory dict
SchemaIndex.fk_graph из fk_targets. Не в Chroma: FK-рёбра не несут семантики.
вопрос на RU / EN
app/streamlit_app.py · 8 модулей
Chat + sample-вопросы · schema explorer · show-working trace · EN↔RU · режимы Accurate / Fast / Debug.
src/nl_sql/api/main.py
POST /ask · GET /databases · /healthz · /readyz · /eval/latest. X-API-Key + token bucket 60 req/min · Singletons DI.
liovina-nl-sql.hf.space
Docker free tier · UI + API в одном контейнере · deploy ≈ 90 с.
schema_index/retriever.py
Dense top-k=5 schema-чанков (filter db_id) → FK BFS ≤1 hop, бюджет 12 таблиц → few-shot k=3 (cross-db на BIRD) → extended samples 3→5 → dialect hints. Выход: ContextBundle.
JSON-скелет: tables · joins · filters · group_by · sort · limit
codestral-latest · T=0
Structured JSON: {sql, rationale, tables_used, confidence}. Шаблоны: cards | M-Schema (XiYan) | DAC (CHASE-SQL) + P3.F hints — 11 правил, gated db_id+phrase.
execution/guards.py · sqlglot
SELECT-only · no DML/DDL в дереве · 1 statement · function denylist (pg_sleep, load_extension…) · denied tables · ATTACH / PRAGMA block.
execution/runner.py → db/connection.py
SQLite: URI mode=ro + PRAGMA query_only + progress-deadline; Postgres: read-only транзакции + statement_timeout 30 s; row cap 10 000.
agent/nodes/repair_once.py
Ровно 1 повтор с error-context (guard repair_attempted): validate-fail / runtime-fail / empty (G) / critique-fail.
Row-shape проверка результата → не более 1 retry.
render/picker.py · formats.py
Чистый Python, эвристики по shape результата: Scalar · Sentence · Table · Line · Bar · Pie · Scatter.
mistral-large-latest
NL-caption ≤ 2 предложений; финализация trace (model, tokens, latency, confidence по каждому узлу).
PipelineRunResult
answer + SQL (подсветка) + rationale + confidence + caption + полный trace. Error taxonomy: invalid_sql · execution_timeout · execution_failed · empty_result · low_confidence · repair_failed
llm/providers/base.py · factory.py
PEP 544 runtime_checkable · build_provider(name) — смена модели = env var · ProviderError taxonomy. Embed-протокол отдельно.
llm/cache.py · diskcache
Ключ sha256(provider · model · system · prompt · T · max_tok): hit = 0 quota, 0 latency — основа $0-бюджета. В тестах — fake-провайдеры, CI без live API.
codestral-latest (SQL) · mistral-large (NL) · mistral-embed. La Plateforme free.
llama-3.3-70b · qwen3-32b · gpt-oss. TPM/TPD-bounded.
gpt-4o-mini · auth по PAT · OpenAI-compatible SDK.
deepseek-v4-flash:free + 24 беспл. reasoning/code-моделей.
local · qwen2.5-coder:7b — offline-слот bakeoff.
GPT-5.2 · Grok-4.1 · Claude-4.5 · Kimi-K2 (reasoning / Pro).
browser-orchestrator → Sonnet 4.6 (eval-only мост).
eval/dataset.py
BIRD Mini-Dev loader · dev_split(seed=0, n) — stable-prefix: n=50 ⊂ n=200 → кэш промптов переиспользуется.
eval/runner.py
Конфиги A · C · D · E · F (T-sweep 0.2–0.8) · G (B=BM25, N/I): A–D без repair, G + verify_retry_on_empty → eval/reports/*.json.
scripts/run_*.py
groq_voting · sonnet (GraceKelly) · helallao · openrouter · critique_retry · selfcon (T-sweep) · wide_schema · ensemble_vote. Работают по residue (misses) поверх v_N.
scripts/merge_voting_rescues.py
--reverify — re-exec через safe_compare_pred · archive_sweep / rescore → merged baseline vN+1.
eval/metrics/
execution_accuracy — BIRD-official set-equality · safe_compare_pred (pred-fail → False) · schema_recall@k.
scripts/
audit_rescore — row-by-row re-execution · p3f_acceptance — 11 gates (req/forbidden columns по AST) · error_taxonomy buckets · refresh_baseline_summary.
→ README headline · GET /eval/latest · HF redeploy. Lift trace: 47% (config A) → 94.0% (v31), 31 версия, каждая с negative/saturation evidence.