Repository navigation
Conversation
The on-device model saw only the current sentence, so its words and phrases lost the topic at every new sentence. Generation now receives the buffered text before the word, earlier sentences included; a clipped buffer starts at its first whole sentence so the start moves only when a sentence is clipped. Statistical words keep the current sentence. Changing text now cancels pending results instead of resetting the worker, so the worker extends its prepared context rather than evaluating it again; clearing the buffer still resets it. The libraries and worker assets are pinned to switchify-prediction PR #38, which adds the 128-token context, and the bundle manifest records it. They must be re-pinned to the merged library before this ships. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Closing without merging: #1073 was closed as won't fix on 2026-10-17. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1073
Depends on switchifyapp/switchify-prediction#38 (library issue switchifyapp/switchify-prediction#37).
What changes
prediction::context::extractgainstext: all buffered text before the prefix, earlier sentences included. The statisticalbeforeis unchanged and still holds only the current sentence. In a clipped buffer,textstarts at the first whole sentence, so its start moves only when a whole sentence is clipped; with no sentence end, only the clipped word is dropped, as before.partialhandling is unchanged.Predict::predicttakes theContext.Modelgives the statistical predictorbeforeand givesgenerate/generate_phrasesthetext. The 16 KiB limits are the library's and are unchanged.Predict::cancel/Refiner::cancelinstead ofreset. Pending results are still dropped, but the companion keeps its prepared context, so the next keystroke extends it instead of evaluating up to 128 tokens again. Clearing the buffer (Enter, Tab, window change, outside input, keyboard close) still callsresetand discards the context. Buffer rules, learning and privacy are unchanged. Nothing is logged.Cargo.toml,Cargo.lockandscripts/prediction-neural.jsonare updated: bundlecontext_tokens128,revision,library_revision, andprepared_artifactworker pins for all four targets. Model and tokenizer bytes are unchanged.docs/word-prediction.mdanddocs/neural-prediction.mdare updated.Tests
All tests use fakes; none type or move the pointer.
context.rs: earlier sentences reachtext, whilebeforeandprefixstay as today, including CJK sentence ends, clipping with and without a sentence end, andpartial.model.rs: statistical words are identical whether or not earlier text is present, the phrase request keeps the full text, andcancelclears pending state.worker.rs: the predictor receives the current sentence and the full text while typing. Typing callscanceland neverreset; Enter resets.Benchmarks
These are Windows figures from the library PR (
generation_evaluate.py, 1,000 queries, AMD Ryzen AI 9 HX 370), all in ms.docs/six-predictions.md's app integration benchmark, which resets each query with five short fixed texts and would not exercise long contexts. macOS was not measured.Validation
All run locally on Windows with Node 24.19 and Rust 1.97.1:
npm run prediction-model: the network fetch failed (ECONNRESET), so I seeded verified resources from the main checkout. After the re-pin, the script fetched the prepared workers and verified them offline.npm run lintpasses.npm testpasses: 300 vitest tests and 12 node tests.npm run buildpasses.cargo fmt --checkpasses.cargo clippy --all-targets -- -D warningspasses.cargo testpasses: 796 passed, 5 ignored.🤖 Generated with Claude Code