Kivi plan
Last updated 2026-11-05.
1. Goal
A Spanish voice assistant, "Kivi" (Home Assistant pipeline "Kiwi"), with low latency and high accuracy on home commands. General questions, live information and follow-ups are routed to Kiais. The MVP is home control; everything else is a later improvement.
2. Current architecture (live 2026-11-05)
satellite (LG webOS TV, ESPHome API)
-> HA openWakeWord (wake word still `alexa`)
-> Whisper large-v3-turbo int8 on the GTX 1060
custom image agil/wyoming-whisper 3.8.1.1, verbs prompt + live HA names
-> HA built-in intents first (prefer_local_intents)
-> miss: Kiais fast, through the core llama_cpp integration
-> Piper TTS
| Measure | Value |
|---|---|
| Whisper latency, p50 | 0.91 s |
| Local (built-in intent) commands, end to end | about 1 s |
| Kiais commands | about 4.1 s |
| Kiais general questions | about 2.3 s (first words about 0.9 s) |
| Verbs prompt, clean synthetic audio | 82 to 88% correct |
| Verbs prompt, synthetic audio at 0 dB SNR | 46 to 57% correct |
The accuracy rows come from synthetic Spanish audio, not real household use; see Small local models and STT hint list. Detail on each part: Conversation agent evaluation, Kiais as the conversation agent, Conversation agent design, Whisper image build.
3. Decisions log (2026-11-05)
| Decision | Why |
|---|---|
Core llama_cpp integration to reach Kiais, not litellm or an own component |
Least to maintain; verified with prefer_local_intents (Kiais integration). |
| The verbs prompt ships with the custom Whisper image; the verbs-only fallback on 2.4.0 is not needed | The canary passed and 3.8.1.1 is live (image build). |
| No local fallback LLM | Kiais availability is treated as Home Assistant's own (Decisions 2026-11-05). |
| No small LLM on the GTX 1060 (router, STT corrector or home agent) | Rejected by measurement (Small local models). |
| Transcripts re-enabled in Loki for the Whisper stream, 180-day retention | Needed to validate against real usage; see section 5. |
| No audio collection for now | Superseded the same day by the next row. |
| Audio collection on (owner approval 2026-11-05): Home Assistant keeps the audio of every pipeline run for 90 days, including the continuous wake-stage room audio while the satellites listen | Real household audio for wake word, AEC / front-end and speech-to-text work. Cluster storage only, no backup, agents see counts and sizes only; section 5 and the data register (datasets 5 and 6). |
| Local models only for any decision model; no cloud API | Privacy; no household text leaves the cluster or the workstation. |
4. Workstreams
| Workstream | Status | Next step | Gate / decision owner | |
|---|---|---|---|---|
| a | Wake word "Kivi" | Training | Retrain with word-level SNR augmentation, evaluate against alexa |
Owner approves deploy |
| b | Whisper | Done (3.8.1.1 live) | Confirm the hint-list effect on real commands | Owner provides real commands |
| c | Real-usage validation | Collecting | Offline replay of the collected transcripts | Owner reviews samples |
| d | Decision model ("Kivi decider") | Validating value | P0 zero-shot baselines and headroom analysis | Headroom meaningful, then owner |
| e | Whisper fine-tuning | Collecting audio (from 2026-11-05) | Fine-tune only after the AEC work, on the collected request audio | Owner (approved the collection 2026-11-05) |
| f | Later / backlog | Not started | See below | Owner |
a. Wake word "Kivi"
- Custom model in openWakeWord format, trained on the workstation. Doc: Kivi wake word (in progress).
- First runs collapsed: the default augmentation sets the SNR against the whole window, so the positives end up too noisy and the training pushes a huge weight on the negatives. Retraining with word-level SNR augmentation.
- Baseline to beat,
alexaon synthetic audio: recall 63% / 38% / 21% at clean / 10 dB / 0 dB; false accepts 0.2 to 0.4 per hour of Spanish speech. - Deploy needs the owner's approval. Rollback: set the satellite's
wake_word_idback toalexa.
b. Whisper
- Done: 3.8.1.1 live with the verbs prompt and live Home Assistant names.
- Next: confirm the hint-list effect with the owner's real commands; investigate the "Pon" heard as "Con" error; Renovate on the private image repository; manual image bumps in this repository until then.
c. Real-usage validation (data)
Transcripts stay in Loki for 180 days (section 5). Replay on the workstation uses derived datasets that are deleted at the end of the experiment, at most 30 days. Plan:
- Offline replay of the transcripts against Home Assistant's built-in sentences and the real entities.
- Measure the miss rate and classify each miss: misheard (STT), phrasing gap, other.
- Turn the classes into fixes: aliases, custom sentences, hint-list changes.
Log policy and the data register: Log policy, data register.
d. Decision model ("Kivi decider")
Validate the value first; build nothing before there is headroom over the built-in intents.
utterance (STT text)
-> HA built-in intents
match: execute (about 1 s)
miss: Kivi decider (small local model)
-> home command: execute the intent through HA
-> everything else: Kiais (general questions, live info, follow-ups)
| Phase | What | Detail |
|---|---|---|
| P0 | Zero-shot baselines: Laya, Quyet-1.0-Tiny, embedding + fuzzy matching | Decision models (in progress) |
| P0 | Broader synthetic dataset kivi-fake-v1: fake homes, phrasing styles, negatives including TV dialogue; headroom analysis |
Decider PoC (in progress) |
| P0 | Real-usage replay after a few days of data (workstream c) | |
| P1 | Data, only if headroom is meaningful | |
| P2 | Fine-tune Quyet-1.0-Tiny; optional local teacher: pplx-decider-v1.1-27b (open weights) or Laya | |
| P3 | Gates: wrong actions at most 0.5%; at least 50% of built-in misses rescued; p95 below 150 ms; at most 800 MB on the GTX 1060 (fp32, Pascal) | Any miss of a gate stops the line |
| P4 | Integration: decider HTTP service plus a small Home Assistant custom conversation agent that delegates to Kiais; shadow mode first; structure borrowed from home-assistant-laya, not installed | Owner approves each live step |
Related project: home-assistant-laya
allenporter/home-assistant-laya (Apache-2.0,
read 2026-11-05 at 8803550, laya==0.4.24; source reading only, nothing installed or run) is a
Home Assistant custom component (HACS) with a conversation agent entity around the same Laya model.
It is the closest existing match for P4, but it is a prototype, not a base to run as is.
What it does (documented, from the source):
- Pipeline. Selected as the pipeline's conversation agent. It builds a shortlist (at most 5
intents, 10 areas, 20 entities, lexical matching on names), asks one Laya forward pass five typed
questions (intent, compound, target entity, target area, entity or area), and on a confident
answer executes the HA intent (
intent.async_handle, slotsname,area,domain,brightness,temperature). On low confidence or a "compound" request it callsconversation.async_converseon a configured fallback agent, so a chain Laya, then Kiais is a config option. Withprefer_local_intentsthe pipeline tries the built-in intents first (HA behaviour as in Kiais integration; not yet tried with this non-LLM agent, hypothesis until the shadow run). - Entities. Only those exposed to Assist (
async_should_expose), but if none are exposed it silently uses all states. Controllable domains only. - Gate. Per-question probability of the chosen option against
confidence_threshold0.40 (the README describes a normalised formula, the code uses the raw probability) andcompound_threshold0.70. Our zero-shot study needed 0.6 to 0.85 and the threshold did not transfer between phrase sets (Decision models). - Hardware. In-process PyTorch in the HA executor via the
layapackage; the README quotes about 1.2 GB of RAM, 100 to 250 ms on a CUDA GPU and 1.5 to 3.0 s on CPU for a full home context (author estimates, not measured by us).idle_timeoutdefaults to 0, so the weights are unloaded after every request and reloaded on the next.
Why it does not fit as is:
- No Spanish. The component calls
laya.load()with no checkpoint, which is the English-only root checkpoint (ModernBERT-large); the multilingual one is never selected. Instructions, stopwords, the domain words and the number regexes (%, "degrees") are English; "grados" or "por ciento" are not parsed. Tests and the evaluation home are English only. - No evidence for our gates. No accuracy, wrong-action or rescue numbers; the benchmarks are the model card's latency. The slot set excludes volume and media actions, which we planned to cover.
- Wrong-action risk by design. An area target with no domain word in the utterance is sent as
areaonly (hypothesis: what HA does with it is unchecked). - Hard to deploy in our cluster.
requirementsmakes HA pip-installlaya(torch, transformers, and a newvegamldependency) into the HA container; issue 6 reports the install failing on HA OS. Issue 7 (remote Laya service) is open without a reply. - Maturity. Created 2026-09-20, one release (0.1.0). The author's 45 commits are from 2026-09-20
and 21; since then only Renovate bumps (53 commits). 9 stars, 1 fork, 3 open issues. CI runs
pytest, ruff, hassfest and HACS validation; about 900 lines of integration tests, speculative-engine unit tests and slow live tests
on an English fake home.
hacs.jsonsays HA 2024.04 but the code uses the newer conversation entity API; unproven against our HA 2026.10.4. - Privacy and supply chain. Inference is local and the integration code makes no network
calls of its own. HA installs
layafrom PyPI at runtime and the package downloads weights from Hugging Face on first load (revision pinned insidelaya, safetensors and JSON only, notrust_remote_code). The integration passes no hash. Not reviewed:laya0.4.24 beyond a read ofloadandserve;vegamlnot reviewed at all.
What is reusable:
laya[serve]already ships an HTTP server (FastAPI,POST /v1/systemoneand/batch, bearer key, idle unload,LAYA_THREADS,LAYA_MODELSto pickmultilingual,LAYA_CUDA_AMP=fp32to avoid fp16 autocast on Pascal). That covers the "decider HTTP service" half of P4 without code of ours, for Laya only (Quyet needs its own service).DecisionEngine(speculative/scoring/engine.py) is a small abstract class (async_predict(state, questions)), so aRemoteEnginethat calls the server over HTTP is roughly 60 lines. This is the change issue 7 asks for.- The 5-stage
DecisionFlow(request, retrieval, hydration, scoring, resolution) and its fixtures are a useful reference for the HA side: exposure handling, intent introspection, originating-area prior, fallback viaasync_converse.
How it changes P4 (proposal, owner decides):
- Build our own thin HA agent for P4, borrowing the structure; do not install this component.
Reasons: Spanish, our gates, shadow mode, our own question design and parsing (already measured
in
decision_models/) and the model choice are all ours, so the reusable part is the ~190-lineconversation.pypattern and theDecisionEngineseam, both Apache-2.0 (keep the licence header and attribution if code is copied). - Serve over HTTP outside HA:
laya[serve]for Laya, a minimal service for Quyet; HA never imports torch. - Add what is missing, in this order: Spanish number and domain parsing; the
multilingualor fine-tuned checkpoint; a per-question threshold fitted onkivi-fake-v1and real replay and checked on held-out phrases; a shadow mode (log the decision, always fall through to Kiais, no device action); no "all states" fallback; area-only targets rejected unless the domain is known; unload disabled (idle_timeout> 0 equivalent) so p95 can be measured. - Contribute only small, upstreamable pieces if useful (remote engine for issue 7, a
modeloption), after P3 says the line continues. There is no sign of maintainer activity beyond the first two days, so do not depend on upstream merges. - Reference result, not a reason to skip P3. This project does not change the P0 finding: zero-shot Laya multilingual was near chance on action and area in Spanish; the component adds no fine-tuning or Spanish data. The P3 gates stay as they are.
e. Whisper fine-tuning (audio collection started, fine-tuning later)
Audio collection started on 2026-11-05 on the owner's approval: Home Assistant's assist_pipeline
debug recording keeps the request audio and the continuous wake-stage room audio of every run for
90 days, on the cluster volume home-assistant-voice-recordings (data register,
datasets 5 and 6). Fine-tuning itself still waits: only if real data shows ASR errors dominate, and
after the AEC / front-end work. Then LoRA on large-v3-turbo, evaluated on a held-out real set against
the base model. The wake-stage audio also serves the wake word (workstream a) and AEC work.
Related project: paulglavin/VoicePipeline (reviewed 2026-11-05)
Not adopted. A server-side Wyoming STT wrapper: offline DTLN noise suppression, Silero VAD, WeSpeaker speaker ID and English STT; no AEC and no wake word. MIT, a single-author hobby project with no tests. Ideas borrowed into this plan:
- Review and labelling loop for the recorded audio, needed before the recordings can train the wake word, AEC or STT: the stored WAV with its transcript and scores, a Pending queue of low-confidence items, owner confirm or reject, and an append-only labels table.
- Experiment: a blind noise suppressor arm (DTLN or RNNoise; off, on and a 50 % blend) in the synthetic noise benchmark and the live A/B runner. Expected gain is modest; AEC remains the main fix.
- Parked: speaker ID, for per-person replies or for rejecting TV voices.
f. Later / backlog
- Phase-2 learning collector: alias proposals from misses, within the transcript retention window (STT hint list and learning).
- Kiais stream tool-call chunk fix (optional; Kiais integration).
- AEC / front-end and false-wake work, in the satellite repository.
- Cleanup of old Home Assistant entries.
5. Data handling
Purpose-limited: transcripts are collected only to validate the assistant on real usage, in Loki (global 180-day retention, no separate stream rule), and analysed locally; derived replay datasets on the workstation are deleted at the end of the experiment, at most 30 days. Agents see aggregates only (counts, miss rates, categories); no transcript text goes to any AI service or cloud. Samples are shown only to the owner. Nothing private is committed to git. Transcripts expire with the 180-day retention; stopping means reverting the exception commit. Audio of every pipeline run (request audio and the continuous wake-stage room audio) is kept for 90 days on a cluster volume from 2026-11-05, on the owner's approval; agents never open or listen to it and report counts and sizes only. Policy and checked locations: Log policy; data register.
6. Open decisions for the owner
- Approve the deploy of the custom "Kivi" wake word once it beats
alexa(rollback is one setting). - Provide real commands (or a review session of samples) to confirm the hint-list effect and the "Pon" / "Con" error.
- Decide, after the P0 headroom analysis, whether the decider goes on to P1 and P2.
- Choose the optional local teacher for P2 (pplx-decider-v1.1-27b or Laya), if the project reaches it. Related: for P4, confirm "own thin agent, borrowing the home-assistant-laya structure" instead of installing or forking that component (workstream d).
- Approve any live Home Assistant change: shadow-mode conversation agent, entity cleanup.
- Decided 2026-11-05: audio collection is on (90 days, including wake-stage room audio). Household consent is the owner's responsibility.
- Confirm whether the 180-day transcript retention stays or is shortened once the validation is done.