跳到內容

上下文提示

--context 選項告訴 LLM 你正在翻譯什麼內容,幫助它解決歧義詞彙並選擇合適的術語。

Terminal window
yaku --to zh-TW --context "Kubernetes 文件" -f guide.en.md

yaku 會將以下內容附加到系統提示詞:

Context: this text is about Kubernetes 文件. Use appropriate domain terminology.

沒有上下文時,LLM 僅從文字本身推測領域。這對大多數翻譯都夠用,但有些詞彙在不同領域有不同意思:

英文詞彙一般翻譯搭配 --context "networking"搭配 --context "swimming"
pool資源池游泳池
port港口網路連接埠海港
table桌子路由表桌子
branch分支分支(git)樹枝
Terminal window
yaku --to zh-TW --context "PostgreSQL database administration" -f backup-guide.en.md

LLM 會使用資料庫專用術語:「交易」、「索引」、「查詢」 — 而非一般用途的對等詞。

Terminal window
yaku --to zh-TW --context "formal business email to a client" -f email-draft.en.txt

LLM 會調整為正式語氣,使用適合商業溝通的繁體中文措辭。

Terminal window
yaku --to zh-TW --context "medical research paper, cardiology" -f abstract.en.md

LLM 會使用標準醫學術語,而非口語化的替代說法。

--context 設定整體領域,再用術語表鎖定特定詞彙:

Terminal window
yaku --to zh-TW \
--context "Kubernetes documentation" \
--glossary k8s-terms.yaml \
-f guide.en.md

術語表鎖定確切詞彙(例如 “pod” → “Pod”),而 --context 引導 LLM 處理其餘內容。

在潤飾模式中,--context 可調整語氣和正式程度:

Terminal window
echo "The server go down again yesterday and we need to fixe it ASAP" | \
yaku --mode polish --to en --context "incident report for engineering leadership"

輸出:

The server experienced an unplanned outage yesterday and requires immediate remediation.
  • 保持簡短。 一個短語就夠了:"Kubernetes docs""legal contract""casual blog post"
  • 盡量具體。 "PostgreSQL administration""database" 好。
  • 用來控制語氣。 "formal email""casual chat" 之類的上下文會影響寫作風格,不只是術語選擇。