Skip to content

feat(ios): learn per-thumb adaptive touch offsets in 1.7 KB - #3196

Open
kitlangton wants to merge 1 commit into
devfrom
ios-kb-thumb-offsets
Open

kitlangton wants to merge 1 commit into
devfrom
ios-kb-thumb-offsets

Conversation

@kitlangton

Copy link
Copy Markdown
Collaborator

Adaptive touch on iOS now learns left and right thumb offsets separately in a 1.7 KB file and adapts within about 100 clean words.
In Settings › Labs › Adaptive touch (off by default), Spatial autocorrect shifts its invisible tap centers toward where each thumb actually lands without moving drawn keycaps, hit targets, or swipe paths. Centered typists see zero change.

❌ Before

  1. Unsplit iPhone keyboards pooled left and right thumbs into a single row average, so opposing left and right thumb drifts canceled out.
  2. Pitch width used a 10-column width rather than each layout's actual character pitch, skewing 11-column layouts by about 10%.
  3. Unmodified non-words and reverted corrections could enter the 400-tap ring buffer, and the store wrote 23,588 bytes synchronously.

✅ After

  1. A 4-level Empirical Bayes hierarchy (0 -> Global -> Left/Right Thumb Zone -> Key) with smooth recency decay learns each thumb zone independently per layout, orientation, and one-handed inset bucket.
  2. Pitch normalization matches the spatial decoder across every layout, clamps personal centers to ±0.22 × ±0.24 key pitches, and keeps neighboring keys at least 0.75 pitches apart.
  3. Only attested words inside unshifted key targets within a 0.85-pitch Huber taper teach the model, persisted to a memory-mapped 1,728-byte App Group file off the main thread.
- tap -> row average (left + right pooled) -> 4x200 ring -> +/-0.30 keycap -> 23,588 B sync write
+ tap -> attested word & 0.85p Huber gate -> Global -> ThumbZone -> Key EMA -> +/-0.22x0.24p clamp -> 1,728 B async write

📊 Numbers: seeded Monte Carlo typing benchmark across 4 shifted-thumb personas (portrait uniform, opposing left/right thumbs, one-handed inset, and wide landscape) after ~100 warmup words, plus 500 centered-typist words and 1,050-word tap autocorrect regression gate.

Measure Before After
Persisted bias store size 23,588 B 1,728 B
Cold mappedIfSafe load (median, 50 runs) — 0.14 ms
Shifted-thumb Top-1, full engine (4 × 100 words) 82.50% (330/400) 92.25% (369/400, +9.75 pp, +39/-0)
Shifted-thumb Top-1, spatial decoder (4 × 100 words) 82.25% (329/400) 97.25% (389/400, +15.00 pp, +60/-0)
Centered-typist Top-1 (500 words) 98.60% (493/500) 98.60% (493/500, 0 mismatches)
Clean-word false positives (300 + 1,050 words) 0.00% 0.00%

The new ThumbOffsetBenchmarkTests suite fails without the v2 hierarchy and passes 4/4 tests; full HEXMobileTests passes 1,056 tests (0 failed, 5 skipped).

👀 Read: ios/HEXShared/FullKeyboard/AdaptiveTouchBias.swift around promote(context:geometry:), where 3-stage shrinkage, unimodal variance gating, and pairwise neighbor anti-compression meet. The rest is routine.

🔍 Planned iOS keyboard accuracy and memory pass · no user reports · measured in Simulator XCTest benchmarks

Checks run
  • python3 scripts/code-shape.py --check: pass (0 hard problems)
  • xcodebuild test -project HEXMobile.xcodeproj -scheme HEXMobile -only-testing:HEXMobileTests: 1,056 passed, 0 failed, 5 skipped
  • xcodebuild test -project HEXMobile.xcodeproj -scheme HEXMobile -only-testing:HEXMobileTests/AutocorrectBenchmarkTests: 98.67% Top-1 (1,036/1,050), 0.00% clean-word false positives

Upgrade Labs Adaptive touch to a 4-level hierarchical Empirical Bayes and
exponentially weighted bias model (0 -> Global -> HandZone -> Key) backed by a
fixed 1,728-byte binary in the App Group container:

- Split unsplit keyboards into left and right thumb zones and unify pitch
  normalization on characterWidth + gap alongside TypingDecoder.
- Gate label admission on attested words, unshifted hit rectangles, a 0.85-pitch
  Huber taper, unimodal spread checks, and zero-contamination rollback for
  reverted or backspace-edited words.
- Clamp personal key centers to +/-0.22 x +/-0.24 key pitches with pairwise
  horizontal neighbor anti-compression (>= 0.75 pitch separation).
- Add seeded Monte Carlo benchmarks and corruption fuzzing across centered and
  shifted-thumb personas.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant