2026-11-03 · Prompt Optimization
GLM's strength in both Chinese and English is well recognized, and with the GLM-5 flagship series, the GLM-4 multimodal family, and an open-weights ecosystem, many people use it directly for multilingual writing, translation, and customer-service scripts. In practice, though, you often hit an awkward moment: you ask for a Japanese reply and it slips in Chinese, or starts in Japanese and drifts back to English halfway through. That's usually not a model problem—it's a prompt that never clearly "locks" the language. Here are a few fixes you can apply right away.
Tacking "reply in Korean" onto the end of a long prompt is a recipe for it being ignored. Place language requirements in three spots: the start of the system prompt, the start of the user message, and inside the output example itself. GLM is sensitive to instruction placement—the earlier and more structured, the more reliably it's followed.
Another common trap: asking in Chinese but requesting English output. The model has a strong tendency to mirror the question's language. The fix is to explicitly state "regardless of the input language, output only the target language," and include one example.
Rather than spending two hundred words on "no mixing languages," give a sample paragraph in the target language. GLM mimics few-shot examples closely—it follows their language, format, and tone. This is especially noticeable for localized copy and support scripts.
The template below suits multilingual content production; swap the variables and go:
You are a multilingual content writer.
[Output language rules — highest priority]
1. Use only: {target language, e.g., Japanese}
2. No Chinese, English, or third languages allowed — including headings,
punctuation, and unit labels
3. If a proper noun has no established rendering in the target language,
transliterate it and keep the original in parentheses
[Task]
Topic: {topic}
Audience: {audience, e.g., tech blog readers in Japan}
Tone: {tone, e.g., friendly and professional}
Length: {word count or paragraph count}
[Output example — language and format must match this]
{a short opening paragraph in the target language}
[Output requirements]
Output the body text only. No explanations, no preamble.
This works in the GLMMODEL playground and with the BigModel API alike; in API use, put it in the system-role message.
Multi-turn chats are where language drift happens most: you ask one follow-up in Chinese, and the model switches. Two countermeasures:
1. Hard-code the language rule in the system prompt (see the template below) so it persists across the session; 2. Every few turns, open the user message with a light reminder like "(keep outputting in the target language)"—cheap and surprisingly effective.
A session-level system prompt template, also usable with tool calls and agent flows:
You are {role name}, an assistant serving users in {target language}.
[Language lock]
- All replies use only {target language} for the entire session
- Even if the user writes in another language, keep replying in {target language}
- Reasoning, transitions, lists, and code comments (when needed) all in {target language}
- Leave code itself untranslated only where translation is impossible
[Behavior]
- When calling tools, pass parameters in {target language} (unless the tool protocol requires otherwise)
- Reply structure: conclusion first, then bullet points, no longer than {N} words
Note that last rule on tool parameters: in agent development, if GLM's tool-call arguments flip languages, downstream parsing gets flaky. Agreeing on this upfront saves real debugging time.
If what you actually want is high-quality content in one language from Chinese or English source material, don't ask GLM to do it in one shot. Split it: first have it produce a structured intermediate draft (outline or bullet points, in a language you can check); then use the lock template above to have it rewrite directly in the target language based on that draft. For languages far from Chinese—Japanese, Korean especially—the two-step approach is usually more controllable than one-shot generation.
Before shipping, skim once: is the whole output in one language? Did any heading or bullet slip through? Is punctuation in target-language style (full-width for Japanese, for instance)? Are number and unit formats right? When the GLM-4 multimodal family handles multilingual tasks with images, text inside the image can pull output back toward the original language—one glance at the beginning of the reply catches it.
Language locking comes down to three things: state the requirement precisely, supply the right example, and remind the model in long sessions. Save the two templates above as your go-to snippets, validate the format with a couple of playground runs, then move them into the BigModel API or your agent pipeline—output stability across languages will improve noticeably right away.
本文为使用方法整理,内容选自网上公开资料,供参考;本站为非官方资讯站,产品能力以官方页面为准。