Skip to content

feat(neural): wire the LSTM engine into candidates (opt-in)#33

Open
mkpoli wants to merge 1 commit into
feat/neural-rsfrom
feat/neural-wire
Open

feat(neural): wire the LSTM engine into candidates (opt-in)#33
mkpoli wants to merge 1 commit into
feat/neural-rsfrom
feat/neural-wire

Conversation

@mkpoli

@mkpoli mkpoli commented Jun 22, 2026

Copy link
Copy Markdown
Owner

The final deployment step — puts the proven neural model on the on-device path.

Adds suggestions.engine = "ngram" (default) | "neural". With neural selected and the model bundled, the candidate window is driven by the LSTM with full recent-sentence context; otherwise — and as a fallback when the model is absent — the n-gram engine runs unchanged. Opt-in default ⇒ the shipped experience can't regress.

  • config: Engine enum + suggestions.engine.
  • text_service: committed_words — a sliding window (≤40) of recent committed words (the neural context); cleared on deactivation.
  • composition: commit() appends to it; refresh_candidates() streams the LSTM over BOS + window, ranks prefix completions by full-context logits, builds the list via CandidateList::from_words; falls back to n-gram if neural::global() is None.
  • candidates: from_words(...) constructor (+ test). neural: bos().

Clippy -D warnings clean (Windows target); candidate/from_words tests green via host harness.

⚠️ Needs a Windows run to verify in-IME behaviour + per-keystroke latency. The +7 KSR win over n-gram is proven offline; this realizes it on device.

Stack: feat/neural-export (int8 lstm.bin) → feat/neural-rs (module) → this. Merge in that order. Note: this adds suggestions.engine; when it lands alongside the self-documenting-config PR (#32), to_documented_toml + its test must be updated to include the new field (trivial follow-up).

Adds suggestions.engine = "ngram" (default) | "neural". When neural is selected
and the model is bundled, the candidate window is driven by the LSTM with full
recent-sentence context; otherwise (and as a fallback when the model is absent)
the n-gram engine is used unchanged. Opt-in default means the shipped experience
can't regress.

- config: Engine enum + suggestions.engine (default Ngram).
- text_service: committed_words — a sliding window (≤40) of recent committed
  words, the neural engine's context; cleared on deactivation.
- composition: commit() appends to it; refresh_candidates() streams the LSTM over
  BOS + the window, ranks prefix completions by full-context logits, and builds
  the list via CandidateList::from_words. Falls back to n-gram if global() is None.
- candidates: from_words(typed, completions, max) constructor (+ test).
- neural: bos() accessor.

Clippy -D warnings clean (Windows target); candidate + from_words tests green via
host harness.

⚠️ Needs a Windows run to verify the in-IME behaviour and per-keystroke latency.
The neural KSR win (+7 over n-gram) is proven offline; this lands the on-device
path to realize it.
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 41744529-0538-4440-b02f-5efbd6bfbee1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/neural-wire

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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