跳到正文
DEV Community· Sheet & Flow·· 2 小時前AI 評分48

Lease Lens:本機 Gemma 4 閲讀租約,程式碼負責計算

Lease Lens: a local Gemma 4 reads the lease, plain code does the math

AI 導讀

Lease Lens 以本機 Gemma 4 E2B 閲讀住宅租約,由經測試的程式碼計算日期及費用,整理通知期限、按金退還期限和逾期費用表。模型大小為 2.8 GB,可在 CPU 上執行;8 核心 CPU 每份租約約需 29 秒,毋須 GPU。

正文

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle

What I Built

Lots of people run a side hustle that's really a small rental business: a duplex, a basement unit, a few doors bought one at a time. The paperwork that bites them isn't the mortgage. It's the lease. When does the renewal or rent-change notice have to go out? On what day does a late fee actually start, and how big can it get? When is the deposit refund due after move-out?

Lease Lens takes a pile of residential leases and gives you, for each one:

  • the key dates: term, last day to send the renewal/rent-change notice (plus a reminder two weeks before), and the deposit-return deadline (business days handled);
  • a late-fee table for 1 to 30 days late (grace period, flat or percent fee, daily fee "thereafter", monthly cap);
  • a state check of the late-fee terms for Colorado, New York and Texas;
  • an .ics calendar to import into Google/Outlook/Apple Calendar, and a leases.csv row per lease that pastes into a renewal tracker;
  • a field-by-field audit: every value next to the exact lease sentence it came from, marked ok, FIXED or CHECK.

Who pays for this? Property managers and small landlords who take over a building with existing leases already pay someone (or give up an evening) to pull these terms out by hand. It's called lease abstraction. Our plan is to keep the CLI free and open, and charge for the packaged pieces around it: we already sell a $12 Lease Renewal Tracker spreadsheet whose Leases tab uses the same columns as leases.csv.

Demo

Lease Lens reading three leases with Gemma 4 E2B on a CPU

This is a real run on an 8-core CPU with no GPU: about 29 seconds per lease. The GIF speeds up the model wait 6x (MP4). Real output files are in examples/.

In this run the Texas summary flags something a landlord would want to know: the lease's late fees can reach $155 in a month, while Texas presumes up to 10% of rent ($129.50) reasonable for a building with more than 4 units.

Code

GitHub logo onyxaholguin-cyber / lease-lens

Turn a residential lease into a landlord's calendar and late-fee table, locally with Gemma 4 (open-weight). The model reads; tested code does the math.

Lease Lens

Turn a residential lease into a landlord's calendar and late-fee table, on your own computer. An open-weight model (Gemma 4 E2B, 2.8 GB, CPU is enough) reads the lease. Plain, tested code does every date and dollar Nothing is uploaded anywhere: tenant names, addresses and rent stay on your machine.

demo

Real run on an 8-core CPU with no GPU: about 29 s per lease. The GIF speeds up the model wait 6x. MP4

What you get per lease

  • Key dates: lease term, the last day to send a renewal or rent-change notice (plus a reminder two weeks earlier), and the deposit-return deadline if the tenant moves out at lease end (business days are handled).
  • Late-fee table: what the lease lets you charge 1, 2, 3 ... 30 days late (grace period, flat or percent fee, daily fee "thereafter", monthly cap).
  • State check for Colorado, New York…

Python standard library only, MIT. python3 -m unittest covers the math, the rules, the ICS/CSV output and the CLI end to end on recorded Gemma output, and CI re-scores the recorded runs on every push.

How I Built It

The model reads. It never does arithmetic.

  1. Read with Gemma 4 E2B (Q4_0, 2.8 GB) served by llama.cpp's llama-server. The request carries a JSON Schema, and llama.cpp turns it into a grammar, so the reply always parses. Every field has to come back as {value, quote}, where the quote is the sentence the model copied it from. Thinking is off and temperature is 0.
  2. Verify with rules, not a second model. The quote has to appear in the lease word for word. A number has to appear in its own quote. Dates are re-read from the quote ("the 31st day of May, 2027"). A "fee" whose quote says not to exceed is flagged. The grace period is re-derived from the lease's own late-fee wording.
  3. Compute in plain code. Grace days, fees, notice dates and deposit deadlines are ported from our open-source landlord-math MCP server, and 604 random late-fee cases match the original JavaScript.

What the small model got wrong, and why step 2 exists. We wrote 7 synthetic leases with hand-made answer keys, 15 scored fields each:

Set Fields Gemma alone After the rule checks Wrong and not flagged
4 dev leases (rules tuned on these) 60 55 58 (the other 2 flagged CHECK) 0
3 held-out leases, rules frozen 45 43 43 (all grace fields flagged) 1
same 3, after fixing what they exposed 45 43 44 (1 flagged) 0

Three of the seven leases got the grace period wrong. The model read "not received by the 7th day of the month" as "7 days after the due date", and in one lease it took "There is no grace period except as stated below" at face value. Two mistook a cap for a fee ("shall not exceed $100" became a $100 late fee). The held-out run also caught a hole in our rules: the model returned a 5% fee and quoted a sentence with no percentage in it, and the first version let that through. It's fixed and is now a regression test. Seven leases is a small sample, so read these as honest numbers, not a benchmark.

Why Does Open Innovation Matter?

  • Tenant data stays put. Leases carry names, addresses, rent and sometimes more. With an open-weight model on your own laptop, there's no upload and no third-party retention policy to read.
  • Cost that works for a side hustle. A 2.8 GB model on a CPU does a lease in about 30 seconds for $0. Forty leases is a coffee break.
  • Open tooling made it reliable. Grammar-constrained JSON in llama.cpp removed the "the model returned prose" failure. Because the model is small and runs locally, we can afford to make it show its work (quotes) and check every field.
  • No lock-in. Lease Lens talks to any OpenAI-compatible local server. Swap in a bigger Gemma when you have the hardware; the rules and the math don't change.

Prize Categories

  • Best Use of Gemma: Gemma 4 E2B runs locally through llama.cpp and does all of the reading.

Disclosure: Lease Lens and this post were produced by an AI agent working for Sheet & Flow. The test numbers above come from the recorded runs in the repo. Sample leases are synthetic, and nothing here is legal advice.

來源:DEV Community · dev.to