Home / use case

Paper to Portfolio: local Gemma 4 reads an old share certificate, Python does the maths

At a glance
Hardware
A CPU-only laptop with no GPU
Models & engines
Ollama running gemma4:e4b locally
Key gotcha
Gemma echoed Indian DD-MM-YYYY dates back and left out ratio fields when the schema did not require them; he fixed it by making every field required (0 when it does not apply) and parsing both date styles in code.

What they built

Many Indian families keep a few old share certificates in a drawer and have no idea what they are worth. The company may have changed its name, there may have been bonus issues, splits or a merger, and unclaimed dividends can mean the shares were moved to the government's Investor Education and Protection Fund (IEPF).

Paper to Portfolio works that out on his own laptop in about five minutes. You photograph the certificate, paste the company's corporate-announcement history, and get the lineage timeline, the share count and value today, a plain-language explanation in English, Hindi, Marathi, Bengali or Tamil, and a claim checklist.

His rule for the design is to let the model read and write, but never let it count. A share certificate carries a family's name, folio number and holdings, so with a local open-weight model the certificate never leaves the house.

Setup

  • Python 3.12 standard library only
  • Ollama running gemma4:e4b locally
  • One small web page, no framework, no cloud
  • A CPU-only laptop with no GPU
  • MIT-licensed code on GitHub (Rahullkumr/paper-to-portfolio)

How it works

  1. The certificate photo goes to Gemma through Ollama's chat API with a strict JSON schema: company, holder, folio, certificate_no, shares, face_value and issue_date. The page still shows the fields as editable boxes.
  2. Gemma reads the pasted filing history and returns only share-changing events with typed fields (give/per ratios, from_fv/to_fv for splits, into for a new name) and an evidence string copied word for word.
  3. ledger.verify() checks each evidence string really appears in the source text and rejects events with missing ratios or unreadable dates; invented events show in red.
  4. fractions.Fraction does the maths, flooring the share count after each step, and Gemma writes the summary only from the computed facts. The claim checklist is fixed text written by a person.

Results & numbers

  • On his test certificate Gemma got every field right on the first try.
  • Reading the certificate takes 38 to 84 seconds on his CPU-only laptop, depending on whether the model is already loaded, and tracing plus the summary takes about 3 minutes 15 seconds.
  • The fictional demo traces 100 shares from 1989 through two bonuses, a split, a merger and a rename to 1,125 shares, 11.25x.
  • Tests run without a model, so GitHub Actions runs them on every push.

Gotchas

  • Gemma echoed Indian DD-MM-YYYY dates back and left out ratio fields when the schema did not require them; he fixed it by making every field required (0 when it does not apply) and parsing both date styles in code.
  • A 40-year-old photocopy will be harder to read than his test certificate, which is why the fields stay editable.
  • The sample certificate and company are fictional, and the tool is general guidance, not legal or financial advice.
“let the model read and write, never let it count.”— Rahul Kumar

Do it yourself

  1. Install Ollama and pull gemma4:e4b.
  2. Clone Rahullkumr/paper-to-portfolio and run it with Python 3.12.
  3. Try the fictional specimen certificate and company history in the repo first.
  4. Photograph your own certificate and correct any fields the model misread.
  5. Paste the company's announcement history from the exchange website or annual reports and review the traced events.
  6. Confirm with the company's RTA or the IEPF Authority before filing anything.
Source: Rahul Kumar (DEV Community) · Published 2026-10-26 · Added 2026-10-27. This write-up summarizes the original source; see it for full details.

Similar setups

Receipt Box: Gemma 3 4B in Ollama sorts a freelancer's receipts and VAT on the laptop

E. Smith built Receipt Box, a receipt and invoice sorter for freelancers where Gemma 3 4B with vision, running in Ollama on the user's own machine, reads vendor, date, total, VAT, currency and category from photos and PDFs.

E. Smith (DEV Community) · 2026-10-28

Séance: local Whisper and Gemma 4 turn a grandmother's Malayalam voice notes into a searchable family archive

Clivin John built Séance, which transcribes and translates his grandmother's voice notes on his laptop, has Gemma 4 write memory cards, and answers questions only with her exact, verified words.

Clivin John (DEV Community) · 2026-10-31

A read-only Gemma 4 agent on Ollama that explains what fills a Mac's disk

A sysadmin's one-file Python agent lets Gemma 4 on Ollama dig through his home folder and write a Markdown report on disk usage, while code and a four-line macOS sandbox-exec profile make sure it can only look.

DEV Community (MediBlackSand) · 2026-11-30

PatchPal TinyAgent: a coding agent on a 4B model and a 6GB laptop GPU

WiseProbe adapted its PatchPal coding agent to run Gemma 4 E4B or Qwen3.5 4B through Ollama on a 6GB RTX A1000, using handoff-note compaction and capped file reads to work inside a 16K or 32K window.

WiseProbe Blog · 2026-11-25