Skip to content

Verify translations

This recipe repairs English translations in a 1,000-note Japanese deck. It uses a local YAML file so you can inspect the model’s work before changing Anki and resume safely if processing is interrupted.

Assume the deck is named Japanese Core 1k and each note has Japanese and Translation fields.

Open Anki, then export the notes:

Terminal window
anki-llm export "Japanese Core 1k" --output notes.yaml

A row looks like this:

- noteId: 1512345678901
Japanese: 猫は机の上にいます。
Translation: The cat is on the desk.
- noteId: 1512345678902
Japanese: 彼は毎日公園を散歩します。
Translation: He strolls in the park every day.

YAML keeps multiline fields readable and is easy to compare after processing. Anki can be closed after export. See Process a file for the file lifecycle and resume rules.

Create prompt-ja-en.md:

---
output:
field: Translation
require_result_tag: true
---
You are an expert Japanese-to-English translator.
Translate this Japanese sentence into English: {Japanese}
Guidelines:
- Preserve nuance and meaning.
- Write natural, idiomatic English.
- When practical, preserve clues to the original Japanese grammar.
Briefly analyze the sentence and translation choices. Put only the final
translation inside <result></result> tags.

The model can reason in its response, but only the final tagged value reaches the Translation field. See Write prompts for result-tag behavior.

First verify placeholder expansion without calling the model:

Terminal window
anki-llm process-file notes.yaml \
--output notes-translated.yaml \
--prompt prompt-ja-en.md \
--dry-run

Then process three translations and review the proposed changes:

Terminal window
anki-llm process-file notes.yaml \
--output notes-translated.yaml \
--prompt prompt-ja-en.md \
--model gemini-2.5-flash \
--preview

Check proper names, omitted subjects, tense, register, and sentences whose meaning depends on context. Revise the prompt and repeat until the sample is reliable.

Run the full batch:

Terminal window
anki-llm process-file notes.yaml \
--output notes-translated.yaml \
--prompt prompt-ja-en.md \
--model gemini-2.5-flash \
--batch-size 10

The output is saved incrementally. If the command stops, rerun the same command and output path. Completed rows are skipped, while failed rows remain eligible for retry.

The terminal summary reports successes, failures, elapsed time, token totals, and estimated cost. See the process-file reference for concurrency, limits, retries, and diagnostic logging.

Compare the original and processed files:

Terminal window
git diff --no-index notes.yaml notes-translated.yaml

Spot-check a representative sample, including short fragments, long sentences, slang, names, and cards with HTML. If a systematic error appears, adjust the prompt and run against a fresh output path or intentionally reprocess with the force option.

Open Anki again and update the original notes:

Terminal window
anki-llm import notes-translated.yaml --deck "Japanese Core 1k"

The exported noteId values identify existing notes, so the import updates them instead of creating replacements. The importer reports the valid destination fields and partitions rows into additions and updates. With all 1,000 exported IDs intact, this recipe produces 0 additions and 1,000 updates. The note type is inferred when the deck has a single type. See the import reference when you need an explicit note type or key field.