How mail gets delivered
The question
Why is an address written in that order? The recipient's name goes at the top, where no machine needs it, and the routing code goes at the bottom, where a human reader arrives last. Turn the question around and it answers itself: who reads an envelope, in what order, and what does each reader need?
The analog
Two readers, in sequence, with opposite requirements.
The first is a sorting machine, and it reads from the bottom. It wants the countrycountryThe top-level address component (an ISO country). Closed-vocabulary, so it is best handled by a deterministic matcher feeding a proposal rather than a retrained model head., then the postcodepostcodeThe country-specific postal code (US ZIP, French code postal, etc.). Mailwoman handles postcode parsing entirely by rule classifier — a regex problem, not an ML one., then whatever narrows the delivery office — the coarse fields, which is why they sit on the last line. Give it those and it can put the envelope on the right truck without understanding a word of the rest.
The second is a carrier, on foot or in a van, holding a tray already sorted into the order they walk. They read from the top: the name, the unitunitA subdivision of a building — apartment, suite, floor — that refines a street address. Mailwoman's unit component; a designator plus identifier forms a subpremise., the floor, the house numberhouse numberThe numeric or alphanumeric identifier of a building on a street. Mailwoman's house_number component; its position relative to the street name flips between locales.. The coarse fields are noise to them, because every envelope in the tray shares them.
The format is the compromise. Fine detail at the top for the human, coarse routing at the bottom for the machine, and the address is read in both directions by different parties on the same journey.
What happens in between
An envelope enters at a processing facility and passes an optical reader. If the reader resolves the address, a barcode is sprayed on the envelope and nothing reads the text again — the barcode carries the machine down to the delivery point, and the walk-sequence sort falls out of it.
The interesting part is what happens when the reader fails. The image is sent to a person. In the US that is the Remote Encoding Center in Salt Lake City, "the first such center in use and the last one still standing," which receives about 2.3 million address images a day, all day, all year. The reason one facility can absorb that is that the machines improved: in the 1990s they "were able to read fewer than half of the addresses," and today "about 99 percent are readable" (USPS).
Below the keying operators there is another layerlayerOne transformer block — attention plus a feed-forward network, with normalization and residual connections — applied to every position. Stacking layers lets the model build up richer representations; Mailwoman's encoder has 6., and it is the one no database has. The carrier knows the building whose mailbox number does not match its door, the new block that reuses the address of the warehouse that stood there, the household that moved in March. Below that, and only then, is return-to-sender.
The escalation ladder
Read those four layerslayerOne transformer block — attention plus a feed-forward network, with normalization and residual connections — applied to every position. Stacking layers lets the model build up richer representations; Mailwoman's encoder has 6. as a design and the postal system's attitude to ambiguity becomes explicit:
- The machine handles the easy majority for a cost close to zero.
- A person keys the residue, for a cost that is small but not zero.
- The carrier repairs what survives both, using knowledge that exists in one headattention headOne of several parallel attention computations in a layer, each free to focus on a different kind of relationship between tokens. Their outputs are concatenated — 'multi-head attention'. Mailwoman uses 4 heads. on one route.
- What survives all three is returned, not guessed at.
Nothing in that chain resolves an ambiguous address by picking the most popular candidate. Each layerlayerOne transformer block — attention plus a feed-forward network, with normalization and residual connections — applied to every position. Stacking layers lets the model build up richer representations; Mailwoman's encoder has 6. either resolves the item or hands it up to a more expensive reader with the ambiguity intact. That is a system built by people who found out what confident wrong answers cost.
What this implies for parsing
A parser sits above the first rung of that ladder, and it can imitate the ladder's discipline or
break it. Breaking it looks like answering a bare Springfield with one coordinate because one of
the 92 US places by that name is the most populous.
Mailwoman's default geocode path does exactly that, and it is worth being plain about it. A bare
Springfield comes back as Springfield, Missouri — the most populous — at the admin tier, with a
single entry in candidates. The underspecification is reported one field over, as
kind: locality_only: the input was a place nametoponymA proper name for a geographic place. with nothing beside it to disambiguate against. A
caller reading only the coordinate never sees that, which is the failure mode to design against.
Three habits keep the ladder's discipline where the pipelinestaged pipelineMailwoman's runtime architecture: a sequence of pure-function stages (normalize → query-shape → locale-gate → kind-classifier → phrase-grouper → classifier → decoder) connected by typed handoffs. Each stage is published as its own npm package. keeps it. Report a confidence per component, so that a downstream system can route the uncertain ones to a person the way a processing plant routes an unreadable image (Tune confidence thresholds). Repair what is mechanically repairable and leave the rest alone (Handle messy input). And separate "this string parsed" from "this address exists", which is the check a postal file answers and a parseaddress parsingThe process of decomposing a free-text postal address string into structured components — house number, street name, locality, region, postcode, and country — so a geocoder can resolve them to coordinates. cannot (Validate an address before you use it).
What it costs
The escalation modelneural classifierThe machine learning model at the core of Mailwoman's parser — a transformer encoder (~30M parameters) trained from scratch to do BIO token classification over addresses. It learns the 'grammar' of address formats; the gazetteer supplies the 'atlas.' is expensive for the postal service and cheap for the sender, and software inherits the same asymmetry pointing the other way. Surfacing uncertainty means your callers have to handle it: a confidence score nobody reads is worse than useless, because it looks like diligence. The value arrives only when something downstream — a review queue, a second data source, a form that asks the user again — is wired to the low-confidence branch.
Related
- Postcodes and ZIP Codes — the routing code the first reader needs.
- What an address is — why the instruction is addressed to an organization.
- Addressing around the world — the same two readers, in postal systemsexpectation-maximizationAn iterative algorithm that estimates model parameters when some variables are unobserved. In Mailwoman's matcher, EM learns the Fellegi-Sunter m and u parameters from unlabeled data — no training labels needed. that order the fields differently.