Untitled

Anonymous
Plain Text
11/04/2026 11:21 PM
7.0 KB
13
No Index
Never
# Token Optimization and Local Translations

> [Root entry point](./agents.md): section 1 at the start of a session; sections 2-5 in full before local translation. Measurement evidence only when needed in [Lessons Learned 3](./Lessons%20Learned.md#3-completed-model-experiments-2026-10-28).

## 1. Context and responsibility

- Use existing context; inspect files deliberately before changes. Batch independent reads/checks; make/validate coherent changes, do not repeat identical full outputs without a new reason.
- Load mandatory rules once; load long project/experience sections only when task-relevant. Handle small tasks directly; delegate only substantial independent work, and do not duplicate the same review.
- Smallest appropriate validation: code with build/tests, docs with consistency/links and `git diff --check` in the repository. Do not reduce quality, requirements, or security/approval gates for savings. Do not run models for control-file changes.
- Keep raw prompts, responses/measurement logs outside Git; report only totals/concrete failure examples. Local tokens are not Copilot tokens/credits; count setup/review/switching/failures too. **No measured positive net Copilot savings.**
- Model policy since 2026-10-28: only `gemma4:e4b` (E4B) and `qwen3.6:27b` (Qwen), **only serial translation drafts under section 2**. Do not install/use removed models as fallbacks; new models/broad tests require an explicit request.
- Programming, debugging, test development/planning/acceptance, code review, and GitHub/documentation administration remain in the Copilot workflow. Run tests deterministically; local agent experiments do not justify an autonomous test/merge path.

## 2. Required language route

| Route | Language codes / procedure |
|---|---|
| E4B first | `es`, `pt`, `ko`, `ar`, `hi`, `ru`, `pl`, `tr`, `vi`, `th` |
| Qwen directly | `fr`, `zh-CN`, `ja`, `fi`, `he` |
| English | `en`: use source directly, no back-translation |
| German | `de`: edit/review directly |
| Irish | `ga`: Qwen draft plus targeted central language correction; no autonomous approval |
| Other/untested | Qwen plus content review; do not infer quality from a related language family |

All results remain machine-generated drafts requiring content review; there is no complete native-speaker sign-off. Small stylistic roughness is tolerable, but not the wrong language, major meaning errors, or lost conditions/placeholders. No blanket "E4B for all, Qwen only on automatic alarm" and no unlimited repair loop: correct centrally or use a reviewed Qwen draft, then review content again.

## 3. Local API and serial operation

1. Only `http://127.0.0.1:11434`; no cloud inference/downloads/global Ollama/driver changes. If connection is refused, one `ollama ls` may be used to start it under the approval granted on 2026-10-29 (about 15 seconds), then check the API again. Pause/ask only after failure or an actual firewall block; do not work around it.
2. Check `/api/tags` and `/api/ps`; do not unload other people's models, and pause if another user/process is using it. Historical lists/VRAM values are not current state.
3. **Never run parallel requests, model loads, or Ollama workers.** Group languages: load the relevant model, process sequentially, unload it, confirm `/api/ps` is empty, only then switch models.
4. `/api/chat`: `think: false`, `stream: false`, `keep_alive: "5m"`, `temperature: 0`, `seed: 42`, `num_ctx: 4096`. Set `num_predict` to suit text (the 14-text catalog at the time used 1600). Require exact JSON key/string schema where supported. Thinking fields must be empty, no think tags, `done_reason: "stop"`; reject truncated responses. UI context defaults are not request context; more context has no proven quality gain.
5. Provide an unambiguous English source with domain context: "battery level" rather than "Charge", inclusive/strict thresholds, device vs. category. Explain related labels/tooltips together; preserve `{0}`/`{1}` exactly and unmasked.
6. Unload your own models in `finally`, including on failure, and confirm the final state. Deliberately stop/check the end of your own telemetry helpers; do not touch other people's processes/models.

## 4. Resources before loading and between requests

- At least **8 GiB free RAM/commit** and **1.5 GiB measured GPU headroom**; account for desktop/GPU usage and context/compute needs. If insufficient, do not load or abort; intermediate checks do not guarantee a continuous upper bound.
- Aim for maximum useful GPU offload **within reserves**, not maximum VRAM use at any cost. First use Ollama's automatic layer selection and inspect actual placement; do not reuse historical blanket `num_gpu` caps such as 37/65. Manually limit only when demonstrated necessary and based on current budget. Prefer E4B fully on GPU and Qwen with as many suitable GPU layers as possible; never promise full residency based only on file size or hardware name.
- Model/package size and `/api/ps size_vram` do not fully prove VRAM usage (E4B misleadingly reported about 0.34 GiB). Use independent Windows process/adapter counters and state the sampling cadence. "100% GPU" proves neither full residency nor low total load.
- When resources are scarce, orderly release only your own models/helpers. Never stop user applications yourself; no driver resets or blanket cache/shader cleanup as a VRAM trick. Measure again after release and reload the model if needed; lower desktop usage does not prove that an already loaded model was automatically redistributed.

## 5. Validation and project tools

- Before writing: exact keys/completeness, non-empty values, placeholders **including counts**, literal `\n`, Unicode, brand names, and expected script. Then read for meaning/target language; format alone does not reliably detect e.g. incorrect Latin-script language/UI terms.
- Integrate only reviewed texts in the project format and run existing language-file tests; BatteryBuddy: UTF-8 without BOM, `LanguageFileTests`.
- Check that helpers exist in the current project and what they can do. BatteryBuddy's `tools/translate-lang-keys.ps1` is an older one-model/all-languages importer, defaults to Qwen, and has **no language routing or complete resource/semantic guard**; do not use it with E4B for all languages.
- After research cleanup, the remaining tools there were the importer, `tools/ollama-translation-validation.ps1`, `tools/test-ollama-translation-validation.ps1`, and language-file tests as development tools, not runtime dependencies. Check what's present before use.

Research is complete; there is no dependency on the old lab repositories/fixtures and no request to clean them up. Historical research state: BatteryBuddy commit `3a220e7`, e.g. `git show 3a220e7:docs/ollama-final-two-models.md`; [PR #157](https://github.com/Dergln/BatteryBuddy-Intern/pull/157), [#159](https://github.com/Dergln/BatteryBuddy-Intern/pull/159). Evidence is in Git/PR history, raw data outside the product repository; no archive branch needed. Paths/measurements are BatteryBuddy examples, not requirements for new projects.
Editor is loading...
Leave a Comment