Currently Shipping AI into a real-estate acquisitions workflow Location San Mateo, CA Updated 2026-11-24
N° 037 / Writing / AI / Nov 23, 2026 / 2 min read

Writing the eval before the semantic layer

Sixty frozen questions showed what a dbt semantic layer changes when an LLM writes SQL over rental-housing data, and where my first version fell short.

Ask an agent something like “what’s the average apartment rent in Phoenix right now?” against raw tables and it writes SQL that runs and returns a number. Often the wrong one: it counts income-restricted communities, or mixes build-to-rent homes in with apartments. Nothing about the answer looks off.

So before building anything, I wrote 60 questions over public rental-housing data (rents I collect from listing pages, county permit and parcel records, public sale records), each with gold SQL and a frozen answer. Freezing them first meant the layer couldn’t be shaped around the test.

Then I had Claude build a dbt and MetricFlow semantic layer on DuckDB, where each definition lives once: which communities count, how concessions turn asking rent into effective rent, what counts as a sale comp. Haiku, Sonnet and Opus answered every question on the raw tables and again through the layer.

The first run was a letdown. Accuracy came out about even. The refusals explained it: 9 of the 60 questions needed columns the layer had dropped, like permit numbers and parcel IDs. Once those were added, accuracy on raw tables sat in the high fifties to high sixties, and through the layer it reached the high seventies to low eighties, roughly 16 to 19 points better for every model. Answers that ran cleanly but were wrong fell from about a third to between 15 and 20 percent. One asterisk: that fix targeted questions I’d already seen, so a clean number needs fresh ones.

The layer also needs one ID per property across sources. A resolver matches county parcels, sale records and rent listings: shared parcel number first, then a probabilistic match on name and location, then Haiku as tiebreaker on about one pair in twenty. On held-out Phoenix pairs it scored about 95% on both precision and recall. Tampa, run on the Phoenix model unchanged, found every labeled match at low-to-mid nineties precision. Most labels are drafts, though. I confirmed only 19 of about 250 by hand.

If a team asked where to start, I’d say write the questions before the layer, and count confident wrong answers separately from accuracy. On accuracy alone my first run looked like the layer did nothing, while the wrong-answer count was already dropping for every model.

The code: text-to-sql-eval, cre-semantic-layer and property-resolver.

End · ~383 words ⁂ Filed November 23, 2026
§ Continue reading All posts →
  1. 032 A missing total is not a zero Sep 26, 2026 · AI
  2. 033 A skipped test counted as a pass Sep 26, 2026 · AI
  3. 034 My tests passed. The next tool still read the wrong number. Sep 26, 2026 · AI