Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

semlayer

The open-source semantic layer that infers itself — skip the quarter of hand-writing dbt YAML.

Point it at your warehouse. It profiles every column, discovers the foreign keys nobody declared, decodes the status columns, finds the business rules hiding in your aggregate tables, and writes the whole thing down as an open, portable semantic layer — with confidence, provenance, and lifecycle on every single claim — ready for any AI agent to consume over MCP.

pip install -e ".[warehouses]"
semlayer init snowflake            # generates the minimal-grant setup script
semlayer infer snowflake -o layer.yaml \
  --context ./docs/ --context ./etl-repo/CLAUDE.md   # optional: your wikis/dictionaries as priors
semlayer review layer.yaml         # accept/reject what the engine inferred
semlayer mcp layer.yaml            # serve it to Claude, Cursor, or any MCP client
semlayer lint layer.yaml query.sql  # check any SQL (yours or an agent's) against the layer
semlayer drift layer.yaml snowflake  # catch schema changes (cron- and CI-friendly)

Why

AI agents fail on real warehouses: frontier models solved just 21.3% of Spider 2.0's enterprise-warehouse tasks at publication (vs ~91% on the earlier academic Spider 1.0) — and even today's best agentic scaffolds only reach ~30%. The fix is a semantic layer — but every existing tool (dbt, LookML, Cube, Snowflake semantic views) makes humans write it by hand, and it goes stale the day someone runs an ALTER TABLE.

On our messy-warehouse benchmark (cryptic names, zero declared constraints, hidden business rules), an agent using the inferred layer answers 87% of business questions correctly vs 42% from the raw schema (+107% relative), 89% when it also runs the layer's SQL linter — and the errors it fixes are the silent kind: raw-schema "total revenue" happily sums cancelled orders; a fan-out join quietly triples a total. Full benchmark, methodology changes included, and where we DON'T help →

What gets inferred

Examples from the test suite
Semantic types + roles sts_cd → status code; tot_amt → monetary measure with sum/avg aggregations; PII flagged recall-first
Keys & joins 104/104 undeclared FKs on TPC-DS-style naming, F1 = 1.0 on our messy fixture — with zero of the seeded false-FK traps accepted (statistics alone never auto-include; naming + LLM must corroborate)
Enum decodes C=Completed, X=Cancelled — joined from the decode dimension the engine itself discovered
Business rules "these aggregate tables reconcile only when sts_cd <> 'X'" — found by hypothesis-testing, scoped to revenue metrics (scope: measures), never to counts; inherited by a child fact only when its line amounts provably sum to the parent's total
Grain, SCD2, ratios "one row per ord_id"; cust_mstr is SCD2 with eff_start_dt/eff_end_dt/is_curr_flg and an as-of join rule; avg_tot_amt_per_order = revenue / orders
SQL linting check_sql (MCP) / semlayer lint (CLI): deterministic checks of any SQL against the layer — missing required filters, fan-out sums, deprecated tables, SCD2 without a validity window, hallucinated columns, vacuous correlated subqueries — each with a fix hint
Metrics, routing, deprecation revenue/count metrics with contract-legal filters; "use ord_hdr, avoid ord_hdr_legacy (superseded)"
Descriptions every table + column, LLM-written from evidence via join-graph context propagation, judged 0.82–0.89 correct+useful by an independent model
Your docs as priors --context ingests data dictionaries, wiki exports, CLAUDE.md files — and tells you where they're wrong: doc-vs-data contradictions go to review, never silent override (guide)

Everything lands with confidence (calibrated, with the misses published), provenance (which signals produced it), and lifecycle (inferred → reviewed → certified, plus deprecated/orphaned), governed by a normative consumer contract that makes silent misuse — summing across a fan-out, joining SCD2 at current-row, filtering on guessed decodes — non-conforming, not merely unwise.

Cost & privacy

  • ~$0.70 per 100 tables end-to-end on the cheap model tier, with your own API key (measured cost model). LLM calls are escalation-only; ~80% of columns resolve from statistics alone.
  • --no-llm: fully deterministic mode, zero API calls, still useful (0.81 typing accuracy on the messy fixture) — for orgs where LLM access needs procurement.
  • --no-sample-egress: cell values never leave for the LLM; measured cost ≈ 1 point of accuracy.
  • Read-only, minimal-grant: semlayer init generates the grant script; the live test suite (tests/test_snowflake_live.py, runnable against your own account) proves the reader persona cannot write.
  • Telemetry: anonymous command counts spooled locally only — nothing leaves your machine in this release; opt out with SEMLAYER_TELEMETRY=off. (details)

Honest scope (beta)

  • Best on messy warehouses. On clean, well-named schemas our benchmark shows raw DDL is already sufficient — we publish that negative result rather than hide it. If your warehouse is tidy TPC-DS, you may not need us.
  • Warehouses: Snowflake, BigQuery, DuckDB (+ Iceberg on S3 via the DuckDB bridge). Exporter: dbt (losses reported, never silent). LLM: Anthropic API (Bedrock/Vertex routing is next).
  • Not included: hosted service, ontology enrichment (it failed our own ablation gate — receipts), LookML/RDF exporters.
  • The eval harness ships in this repo — fixtures, gold layers, competency questions, benchmark runner. Run our numbers yourself: python fixtures/build.py && pytest tests/ -q.

Beta feedback

Running the beta? File the Beta feedback form (attach the *.report.json the CLI writes next to your output — timings and counts only, never your schema or data), or email hello@semlayer.dev for anything sensitive.

Layout

spec/ format schema + consumer contract · src/semlayer/ the engine · fixtures/ 9 eval warehouses + golds + CQ suites · docs/ benchmark, cost model, spike reports · ARCHITECTURE.md how it works

License: Apache-2.0.

Metadata

Release files for semlayer 0.4.0b4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for semlayer 0.4.0b4
File Size Uploaded Provenance Actions
semlayer-0.4.0b4.tar.gz 145.7 kB With provenance Details for semlayer-0.4.0b4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for semlayer 0.4.0b4
File Interpreter ABI Platform Actions
semlayer-0.4.0b4-py3-none-any.whl Python 3 none any Details for semlayer-0.4.0b4-py3-none-any.whl

Total release size: 268.1 kB

Release files / semlayer-0.4.0b4.tar.gz

Download URL semlayer-0.4.0b4.tar.gz
Size 145.7 kB
Tags Source
SHA-256 checksum
How to use checksums
501ef9fc13e478145c601978013ff1010ca4005644192c529e40a00f9d3b4abe
BLAKE2b-256 checksum
How to use checksums
17f4bb721fddea92bda6ca36e8740da2280a16fc7ff0bc347c1204e7bc8ff0a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / semlayer-0.4.0b4-py3-none-any.whl

Download URL semlayer-0.4.0b4-py3-none-any.whl
Size 122.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e7ff4415715ef9e2c023ecb1a0aad08d87b2437d107b224e4f4b7d394ffc00b
BLAKE2b-256 checksum
How to use checksums
6aad75e146c021bb7e51545f380b2640506a09ac34087b3f0ad68636d4561693
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Security for semlayer 0.4.0b4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for semlayer-0.4.0b4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page