没有不值得去解决的问题,也没有不值得去学习的技术!

A Tour of Go Multilingual Translation Project: Revisiting Token Protection Through the Swap Problem

Figure 1: The first raw-input experiment for flowcontrol/6 passes the unified automatic validation directly

作者:

在

,

Over the past few days, I have continued working on the A Tour of Go multilingual translation project.

One of the previous development focuses was protecting structures within the .article pages that should not be arbitrarily translated or modified by the large language model, such as inline code, link targets, preformatted code, emphasis structures, and .play directives.

The overall approach was roughly:

Plaintext
Complete course page
↓
Identify structures to protect
↓
Replace with protected token / sentinel
↓
GLM-5.2 full-page translation
↓
Restore protected token
↓
Unified automatic validation
↓
Pass → ready
Fail → retry / blocked

This solution has been working properly, and after multiple rounds of calibration using representative pages, the capabilities for structure protection, restoration, and validation have become increasingly complete.

However, as the protection rules continued to grow, I started to reconsider a more fundamental question:

Before feeding the input to the large language model, is it really necessary to do so much processing on the original course page?

On August 10, 2026, I conducted a real experiment specifically around this question.

The final result did not simply prove that “the new approach is better”; rather, it gave me a clearer understanding of how much to protect, where to protect it, and how to balance translation quality against program complexity.


1. What really made me reconsider the input architecture was the swap issue from the day before

Previously, I encountered an issue where inline code was displaced due to adjustments in Chinese word order.

However, this issue was later recognized, and the corresponding validation rules have been relaxed. Therefore, it was not the direct cause for reconsidering the input architecture this time.

What really started to make me seriously doubt whether “massive token protection is necessary” was the swap issue I encountered the day before.

To ensure that certain original contents were absolutely not modified by GLM-5.2, the program would first replace them with protected tokens, allowing the model to complete the full-page translation around these placeholders.

This approach has obvious advantages in terms of structural safety, but it also means:

Plaintext
Input the model actually sees
≠
A Tour of Go original page

When a real identifier like swap is replaced by a placeholder with no business semantics, the model can no longer directly understand:

Plaintext
swap

Whether it is a function name, a code identifier, or an ordinary English word.

The more complex the protection layer, the less real context the model can actually see.

More troublingly, the protection itself introduces new program logic:

Plaintext
Identify
→ Tokenize
→ Token integrity validation
→ Restore
→ Boundary handling
→ Order and quantity comparison

In other words, we originally added protection to prevent the large language model from making mistakes, but the protection system itself has started to become a complex subsystem that requires continuous maintenance.

The swap issue made me start to rethink:

If the final output must already pass strict automatic validation, does the input end really need to protect so much content?

Thinking about it another way:

Could we let GLM-5.2 see the real English original page as much as possible, protect only the very few machine structures that the model truly cannot touch, and then leave more safety responsibility to the unified validator?

This is the real starting point of this architecture experiment.


2. First, add a --raw-input experimental mode

I did not directly delete the already mature default protection flow; instead, I added a parameter specifically for experimentation:

Plaintext
--raw-input

Once enabled, the program still follows the original rules:

Plaintext
ReadCatalog
→ BuildSourceCatalog
→ HydrateCatalogSources
→ Extract complete production page based on page_id

In other words, the complete source content corresponding to a browser course page is still correctly extracted by the program.

Only the subsequent part changes.

Default mode:

Plaintext
Page.Source
↓
protectTranslation
↓
GLM-5.2
↓
restore
↓
ValidateCandidate

--raw-input:

Plaintext
Page.Source
↓
GLM-5.2
↓
ValidateCandidate

It no longer performs massive protected token replacement, nor does it perform post-translation restoration.

But one thing is very important:

--raw-input does not bypass any output validation.

GLM-5.2’s output must still pass the existing:

Plaintext
present single-page parsing
directive validation
link target validation
in-link code validation
normal inline code validation
preformatted content validation
emphasis/font span validation
Section topology validation
directive placement validation
terminology rules

That is to say, the new experiment is not:

Trusting that the large language model will not make mistakes.

Rather:

Allowing the model to make mistakes, but the program must catch them.


3. flowcontrol/6: The first raw-input real request passes directly

The first real test page chosen was:

Plaintext
flowcontrol/6

Execute:

Bash
go run ./cmd/tour-i18n translate run \
    --locale zh-CN \
    --id flowcontrol/6 \
    --dev \
    --raw-input

The result passed directly:

Plaintext
status: ready
token_valid: true
present_valid: true
passed: true
Figure 1: The first raw-input experiment for flowcontrol/6 passes the unified automatic validation directly
Figure 1: The first raw-input experiment for flowcontrol/6 passes the unified automatic validation directly

The terminal displays here:

Plaintext
attempts: 4

After checking the real audit logs later, I confirmed that this does not mean raw-input retried 4 times consecutively.

Attempts 1 through 3 were historical audits left by the previous default protected-token flow.

The real raw-input was only:

Plaintext
attempt 4

And it passed on the first try.

The actual token usage for this call was:

Plaintext
prompt:     1318
completion:   85
total:      1403

Compared to the previous default approach for the same page, which used over 2300 tokens in a single run, the input volume has decreased significantly.

However, I am not going to conclude from this single page that:

The translation quality of raw-input is definitely higher than the default approach.

A more accurate conclusion would be:

After reducing protected tokens, GLM-5.2 can directly see more real page content, while still passing the existing unified validation on the first try, at least for this page.

This proves that “massive tokenization” is not the only path to reliable translation.

If certain structures can actually be exposed directly to the model, and the validator can reliably check them, then there is indeed clear room for simplification on the input side.


4. Here we need to distinguish between “initial machine translation quality” and “final published quality”

raw-input has a very intuitive potential advantage:

The model sees more of the original context.

Therefore, the Chinese text the model generates initially might be more natural, and the language organization suffers from less placeholder interference.

But this does not mean:

raw-input will definitely translate better than the default protected-token approach in the end.

What the project ultimately delivers is not the candidate that GLM-5.2 spits out on the first try.

Even if we continue using the current default approach, after all course pages are translated, we can still perform unified human polishing and fine-tuning.

Therefore, the final published quality will likely be:

Plaintext
Default protected-token
+ Complete automatic validation
+ Unified pre-release polishing

And:

Plaintext
raw / minimal-protect
+ Complete automatic validation
+ Unified pre-release polishing

Reaching a similar level.

The former might even end up being better.

So what really needs to be compared in this experiment is not simply:

Which approach produces prettier Chinese on the first translation?

But the overall engineering cost:

Plaintext
Input processing complexity
Real context the model can see
Structural failure probability
Number of retries
Token consumption
Restore complexity
Whether the validator can reliably catch errors
Long-term maintenance cost
Final published quality

Translation quality is certainly very important, but it is not the only metric.


5. methods/24 quickly proved: completely raw also has obvious risks

If we only look at flowcontrol/6, it is easy to become overly optimistic:

Should we just send the original content directly for all pages?

So for the second test page, I chose one with a much more complex structure:

Plaintext
methods/24

This page contains:

Plaintext
.play methods/images.go

It also has multiple links, link targets, 9 inline codes, image.Rectangle within link labels, a static preformatted Go code block, and *Note* emphasis/font spans.

After the first raw-input run:

Plaintext
present_valid: false

Error reported:

Plaintext
methods/24: candidate present structure:
present parse:
methods.article:21: no match for zh-cn
Figure 2: Under completely raw input, the first experiment for methods/24 fails at the present parsing stage
Figure 2: Under completely raw input, the first experiment for methods/24 fails at the present parsing stage

After further reviewing GLM-5.2’s complete response, the reason was very clear.

The original page was:

Plaintext
.play methods/images.go

The model generated on its own:

Plaintext
.play methods/images.go /zh-cn/methods/24

In other words, GLM-5.2 seemed to think it was “improving” this content by adding a path to it.

But for Go present, this is not natural language.

It is a machine directive.

So the parser continued parsing the appended content as a directive parameter, ultimately reporting:

Plaintext
no match for zh-cn

I ran another independent raw-input experiment.

This time GLM did not append:

Plaintext
/zh-cn/methods/24

But instead changed it to:

Plaintext
.play methods/images.go /src/methods/images.go

Two independent requests both actively modified .play, which is enough to show that:

Machine directives like .play are not suitable for being left entirely to the model to generate freely.


6. GLM also actively “improves” link display formats

The raw-input experiment for methods/24 also revealed another very interesting issue.

The 4 link targets were always correctly preserved.

The existing 9 inline codes were not lost either.

The static Go code block was also kept correct line by line.

However, the model would actively adjust the format of the link display text.

For example, the original:

Plaintext
[[/pkg/image/#Image][Package image]]

GLM would generate:

Plaintext
[[/pkg/image/#Image][`image` package]]

The last link’s:

Plaintext
image/color package

Was also changed to:

Plaintext
`image/color` package

From the perspective of normal technical Chinese reading habits, this formatting is even quite reasonable.

But from the perspective of this project’s structural principles, the model arbitrarily added inline code spans that did not exist in the source page.

Therefore, the validator should still reject it.

This illustrates a fundamental risk of completely raw input:

The model does not just translate; it occasionally takes the initiative to “optimize” structures it thinks can be optimized.

For ordinary articles, this might be an advantage.

For a translation project that needs to maintain a structural correspondence with the upstream .article, this is sometimes a mistake.


7. So I began experimenting with a third path: --minimal-protect

At this point, both extremes had exposed problems.

The original approach:

Plaintext
Massive protected tokens

Has strong structural control, but the input and restoration logic is becoming increasingly complex.

Completely raw:

Plaintext
Original page
→ GLM

The program is obviously simpler, but machine structures might be actively rewritten by the model.

So I started testing a third path:

Only protect machine structures that have real evidence proving they are high-risk.

To this end, I added:

Plaintext
--minimal-protect

The first version did not re-protect inline code, links, emphasis, or static code blocks.

It only protected the complete:

Plaintext
.play methods/images.go

It would be replaced with a unique token, for example:

Plaintext
⟪GTI18N_d80f0d46_000001⟫

The rest of the page was still handed over to GLM-5.2 in an almost original state.

After the model returned, this token was restored to:

Plaintext
.play methods/images.go

The result was very clear:

The .play issue completely disappeared.

GLM retained this token exactly as is, exactly once.

The restoration also precisely generated:

Plaintext
.play methods/images.go

It no longer appended:

Plaintext
/zh-cn/...

Or:

Plaintext
/src/...

This shows that the minimal protection direction is indeed effective.

At least for .play:

Leaving the model with no modification rights at all is more stable than relying on prompt instructions to “please do not modify”.


8. After only protecting .play, the remaining problems became clearer

Once .play was stably handled, I ran methods/24 again.

This time, the present directive parsing failure no longer occurred.

Instead, it showed:

Plaintext
link inline code at link index 1 count mismatch:
expected 0, actual 1
Figure 3: After protecting only the .play directive, the directive issue disappeared, but the model added inline code formatting to the link labels on its own
Figure 3: After protecting only the .play directive, the directive issue disappeared, but the model added inline code formatting to the link labels on its own

After checking the response, I confirmed that:

Plaintext
Package image

Was still changed to:

Plaintext
`image` package

And:

Plaintext
image/color package

Also again became:

Plaintext
`image/color` package

In other words, minimal protection did solve the first class of problems.

At the same time, it exposed the next class of real risks more clearly:

Plaintext
Machine directives
→ Should be directly protected

Normal link labels
→ Model still needs to translate them
→ But cannot change the span structure on its own

At this point, the easiest thing to think of is:

Then just continue to protect image and image/color.

But after careful analysis, I found that this does not actually solve the problem.

Assume:

Plaintext
Package image

Becomes:

Plaintext
Package ⟪TOKEN⟫

GLM could very well still generate:

Plaintext
`⟪TOKEN⟫` package

The token itself was not changed.

After restoration, it is still:

Plaintext
`image` package

So:

Protecting a string itself is not equivalent to protecting the structural boundaries around that string.

If we continue expanding in this direction, it is easy to end up with more and more boundary tokens again.


9. Try again: let the validator’s failure feedback truly enter the next request

The project’s official translation flow originally supported limited full-page retries.

After the previous candidate failed validation, feedback could be generated and passed to the next full-page translation.

But in development mode:

Plaintext
--dev

Previously, each command execution only performed one attempt.

This meant that although the previous multiple experiments were executed consecutively, they actually belonged to different processes.

The later round did not truly receive the previous round’s validation failure.

To verify:

Without adding new protections, just telling the model exactly what went wrong—can it correct itself?

I also added:

Plaintext
--dev-attempts

For example:

Plaintext
--dev \
--dev-attempts 2

This way, two attempts could be executed consecutively within the same TranslationRunner.Run.

The feedback generated after the first failure would actually be added to the second user prompt.

For the case where inline code was added to link labels, the feedback was also made more specific:

Plaintext
The previous output added inline code formatting to the link display text that did not exist in the source page.
Do not add backticks or inline code markers to link labels that were originally plain text;
preserve the existing link targets and existing inline code structures from the source page.
Normal link display text can still be translated normally.
Please re-translate the complete page.

This did not hardcode:

Plaintext
methods/24
image
image/color

So it still serves as reusable general feedback.


10. After continuing the experiment, a new font span issue appeared

The final real experiment used:

Bash
go run -mod=readonly ./cmd/tour-i18n translate run \
    --locale zh-CN \
    --id methods/24 \
    --dev \
    --dev-attempts 2 \
    --minimal-protect

Ultimately, attempt 7 still did not pass:

Plaintext
font span count mismatch:
expected 10, actual 9
Figure 4: After adding continuous retries and targeted feedback, a new font span structural issue was exposed
Figure 4: After adding continuous retries and targeted feedback, a new font span structural issue was exposed

At this point, the whole experiment had started to reveal a very representative path:

Plaintext
Completely raw
↓
.play is rewritten

Only protect .play
↓
Link labels actively get inline code added

Add precise feedback and continuous retries
↓
New font span structural issue appears again

This does not mean the minimal-protect direction is wrong.

On the contrary, it has already proven:

Plaintext
.play

Such a machine structure is very suitable for minimal protection.

And many other structures are actually more stable than I initially expected.

What really needs to be guarded against is:

If we immediately add a new protection rule every time we discover a new failure, we will likely end up right back at “massive tokenization”.

Just reimplemented all over again.


11. Therefore, I decided to stop further optimization here

Theoretically, we could still continue.

Seeing:

Plaintext
font span count mismatch

Then add emphasis/font span protection.

Then test .image.

Then test other directives.

Continue validating more preformatted content and complex links.

From a purely technical research perspective, these are all valuable.

But the project’s real goal is not:

To write a theoretically perfect translation protection framework.

The real goal remains:

Completing the A Tour of Go Simplified Chinese translation, and establishing a stable process that can be expanded to other languages later.

Moreover, continuing this kind of high-frequency architecture experiment presents a very practical issue:

Every time a phenomenon is discovered, Codex needs to read the repository, analyze the audit, modify the program, add tests, and then run GLM experiments.

Development resources are not infinite.

If we continue pursuing theoretical perfection, it will likely slow down the actual translation work instead.

So this time I decided:

To wrap up the experiment here for now, and not proactively expand minimal-protect further.


12. How should we evaluate the default approach vs. raw-input now?

After this round of experiments, I actually do not think we should simply say:

raw-input is better.

Or:

The default protected-token is better.

The two approaches solve different problems.

The default approach’s advantages are obvious:

Plaintext
More mature structural control
Already validated through multiple rounds of representative pages
Automatic validation system is already adapted
Can continue official production translation right now

The potential advantages of raw-input or minimal-protect are equally obvious:

Plaintext
Model sees more real context
Prompt input is shorter
Fewer protected tokens
Restore logic could be significantly simplified
Long-term program maintenance costs could be lower

As for translation quality, we also cannot just compare the first machine output.

Because the context is more complete, raw-input might directly produce a more natural first draft.

But after the current default approach completes all pages, unified human polishing, terminology adjustment, and detail fine-tuning can still be done.

Therefore, the final result could well be:

Plaintext
Default protected-token approach
+ Automatic validation
+ Later human polishing

With a final quality comparable to raw-input, or even surpassing it.

So what really interests me about this experiment is not just the translation quality.

More importantly:

Is there a way to make the input processing and restoration program simpler without sacrificing structural safety.


13. The long-term direction I am more optimistic about now

If we continue to simplify the current architecture in the future, I am now more inclined towards:

Plaintext
Complete original page first
↓
Only protect a few truly high-risk machine structures
↓
GLM-5.2 full-page translation
↓
Minimal restoration
↓
Strict unified validator
↓
Targeted retry feedback

This can also be summarized as:

Plaintext
Give the model as much real context as possible
Try not to give the model modification rights for machine control structures
Final safety is guaranteed by the unified validator

This is more lightweight than “tokenizing all dangerous content”.

And it is also more reliable than:

Plaintext
Completely raw

However, this is just a long-term direction left by this experiment.

It is not yet mature enough to directly replace the current official process.


14. Save the experiment results, but restore the official translation scene

Although this round of experiments has temporarily stopped, all code and real audits have been preserved.

Ultimately forming two commits:

Plaintext
62b1b1a feat: add translation input experiment and minimal protection capabilities
35259cf docs: record translation input architecture experiment conclusions

These saved:

Plaintext
--raw-input
--minimal-protect
--dev-attempts
Targeted retry feedback
Real request / response / validation audits

During the experiment, because --dev was used, the states of flowcontrol/6 and methods/24 temporarily changed.

After ending the experiment, I restored:

Plaintext
status.tsv
candidate

Back to their states before the official experiment.

Final check:

Plaintext
flowcontrol/6  ready
methods/24     ready
Working tree clean

The two commits have also been synced to:

Plaintext
origin/main
Figure 5: Experiment code, real audits, and project status conclusions are committed, keeping the official translation status clean
Figure 5: Experiment code, real audits, and project status conclusions are committed, keeping the official translation status clean

This way, this round of experiments was neither lost nor did it pollute the currently confirmed official translation results.

If we research the input architecture again later, we can continue directly based on these real attempts, rather than starting from scratch.


15. Next step: return to the actual course translation

After the experiment ends, the current official translation path remains unchanged for now:

Continue using the already mature protected-token flow.

Next, we return to the previously established plan:

Start automatic trial runs for normal pending pages.

No more proactively enumerating all possible structural risks for the remaining dozens of pages.

If most normal pages can pass directly, then we will just keep moving forward.

Only when new failures actually occur will we analyze:

Plaintext
Whether the model actually translated incorrectly
Or if it is a protection layer issue
Or if the validator still has a gap

And then only solve the problems that actually appear.

This is more in line with the project’s current stage than constantly predicting future edge cases before the official translation even begins.


Summary

The initial question of this round of experiments was actually very simple:

Before feeding it to GLM-5.2, is it really necessary to do so much token protection?

flowcontrol/6 proved:

Without large-scale protection, the complete original page can also directly pass the existing unified validation, and the input is more concise.

methods/24 again proved:

Completely raw is not enough to stably protect machine structures like .play; the large language model will proactively “help” modify them.

And --minimal-protect further proved:

A small amount of machine structure protection supported by clear evidence is indeed effective.

But continuing the experiment led to new issues like link labels and font spans, which also reminded me:

If we continue to add a protection rule for every failure that appears, we might ultimately end up back with a complex token system.

Therefore, this did not lead to the conclusion that “the existing approach should be immediately overthrown”.

The current default approach is mature enough to continue completing the remaining pages.

Moreover, after all pages are translated, a unified round of human polishing and fine-tuning can be done to further improve the final translation quality.

The real value left by this round of experiments is that it made the possible future simplification direction clearer to me:

Prioritize the original page, reduce unnecessary tokens, protect only truly high-risk machine structures, and then use a strict validator and targeted retry feedback to hold the security boundary.

As for whether it is worth ultimately switching to this architecture, there is no need to rush a decision now.

Let’s just keep the actual translation project going.

After the first phase of Simplified Chinese is nearly complete, re-evaluating based on the real failure rate, token consumption, program complexity, and final human polishing results will likely be more valuable than continuing to pursue a theoretically optimal solution right now.

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系