xushengfeng/lime

大模型驱动的拼音输入法

What it solves

Traditional input methods rely on fixed dictionaries and rules, which often produce awkward or wrong candidates. LIME instead uses a small language model (Qwen3-0.6B) to predict text, and lets your pinyin keystrokes guide the model's next-token choice. This combines the speed of a normal input method with AI-like word association and long-phrase completion.

How it works

The project runs a local AI server (Node.js + Hono). The Rime input method front-end sends your key presses (pinyin syllables) to this server, which feeds them into the language model. The model's next-token probabilities are filtered by your pinyin, and the resulting candidate words or phrases are returned to the front-end. You pick one, and the selection is committed back to the server as context for future predictions.

The core engine (in src/engine/core) manages model sessions, context, and token indexing. Candidate algorithms in src/engine/algorithms implement the selection and ranking logic. Two built-in algorithms are provided: lime-v1 filters the model's next-token probabilities by pinyin and does long-phrase completion; dict-llm-v1 first drafts candidates from a word list and then uses the LLM to rank them, supporting multi-word splits and wildcards.

Who it's for

Developers or power users who want an open-source, AI-enhanced pinyin input method and are comfortable running a local server and configuring Rime. It is not for non-technical end users. The README warns that keystrokes contain private data, so the server should never be exposed on public or untrusted networks.

Highlights

  • Uses a compact Qwen3-0.6B model in IQ4_XS quantisation, aiming for near-normal typing speed while adding intelligent association.
  • Supports fuzzy pinyin, double-pinyin (several popular schemes plus custom), and the apostrophe syllable separator.
  • Offers both lime-v1 (pure LLM-based) and dict-llm-v1 (dictionary + LLM ranking) algorithms, with quality/fast modes.
  • Provides a demo web UI at demo.html and an API for integration.
  • Includes a benchmark suite to measure character coverage against baselines; on several classic Chinese texts, LIME's top-1 character coverage improves over traditional dictionary-based methods by roughly 10–11 percentage points, while staying competitive on others.
  • Supports optional HiAE encryption between the Rime front-end and server to avoid sending the bearer key in plaintext.
  • Can use models from Ollama as an alternative to the local GGUF file.
  • No data persistence: the server forgets all context after restart (by design).

Related

  • Project
  • Project
  • Project
  • Project