Skip to content

Questions about the naturalness of translated text #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
anchor554 opened this issue May 26, 2025 · 3 comments
Open

Questions about the naturalness of translated text #279

anchor554 opened this issue May 26, 2025 · 3 comments

Comments

@anchor554
Copy link

I want to ask a question. The text translated automatically still feels very stiff. Can I add prompt words to make the translated content more natural? How can I adjust it? Thanks

@hitchkin
Copy link

hitchkin commented May 27, 2025

Yes, you can try to modify the current existing system prompt by manually editing it in modules/translation/base.py (ideally you'd fork the repo beforehand) which - depending on your prompting skills - could worsen, slightly (!) improve or not affect naturalness in a tangible way.

Which model do you normally use (and for which source <-> target lang. pair?)? Some models do perform better for certain lang. pairs.

Otherwise there is not much that can be done there (at least not quickly anyway*), you'll just have to wait for better models to be released.

----*will paste them into a seperate issue for better visibility-----

@anchor554
Copy link
Author

I am currently using openai, and the target language is French translated into simplified Chinese. Now the problem is that after I change the prompt word, the text cannot be displayed. I encountered an error and don’t know how to solve it. Please help me

Last login: Tue May 27 01:04:21 on ttys000
anchor@192 ~ % cd Desktop
anchor@192 Desktop % cd fanyi
anchor@192 fanyi % python3 comic.py
qt.qpa.fonts: Populating font family aliases took 115 ms. Replace uses of missing font family "Arial, Sans-serif" with one that exists to avoid this cost.
2025-05-27 01:16:29.462 Python[35291:446267] error messaging the mach port for IMKCFRunLoopWakeUpReliable
2025-05-27 01:16:30.441 Python[35291:446267] The class 'NSOpenPanel' overrides the method identifier. This method is implemented by class 'NSWindow'
2025-05-27 01:17:03.568 | INFO | modules.utils.inpainting:load_jit_model:110 - Loading model from: /Users/anchor/Desktop/fanyi/models/inpainting/anime-manga-big-lama.pt
2025-05-27 01:17:03.824 | INFO | modules.inpainting.base:call:83 - hd_strategy: Resize
2025-05-27 01:17:03.826 | INFO | modules.inpainting.base:call:108 - Run resize strategy, origin size: (1859, 1400, 3) forward size: (960, 723, 3)
2025-05-27 01:17:03.827 | INFO | modules.inpainting.base:_pad_forward:61 - final forward pad size: (960, 728, 3)
GPTTranslation translation error: 'GPTTranslation' object has no attribute 'encode_image'
2025-05-27 09:35:46.793 | INFO | modules.inpainting.base:call:83 - hd_strategy: Resize
2025-05-27 09:35:46.794 | INFO | modules.inpainting.base:call:108 - Run resize strategy, origin size: (1859, 1400, 3) forward size: (960, 723, 3)
2025-05-27 09:35:46.795 | INFO | modules.inpainting.base:_pad_forward:61 - final forward pad size: (960, 728, 3)
GPTTranslation translation error: 'GPTTranslation' object has no attribute 'encode_image'

Here are the changed parts in base.py

user_prompt = f"""{extra_context}

你是一位资深漫画翻译,请将下方法语对白翻译成自然、口语化、富有情绪和人物性格的中文对白
不要生硬直译,要像人物自己说话那样真实、有情绪。

原文:
{entire_raw_text}
"""

    entire_translated_text = self._perform_translation(user_prompt, system_prompt, image)

    # 🔽 把每一行翻译结果分配回文本框
    translated_lines = entire_translated_text.strip().split('\n')
    for blk, line in zip(blk_list, translated_lines):
        blk.text = line.strip()

@hitchkin
Copy link

hitchkin commented May 27, 2025

You did not change the system prompt. The system prompt itself is found in lines 126 -132 (modules/translation/base.py)
and starts with
return f"""You are an expert translator who translates {source_lang} to {target_lang}. You pay attention to style, formality, idioms, slang etc and try to convey it in the way a {target_lang} speaker would understand... etc.

Forgot to add this:

  • OpenAI is a bit too broad, what is the specific model (i.e. GPT-4.1, 4o, o3,...?). And in this case you should maybe give Gemma 3 a try, or Claude Opus 4 (through the custom option)
  • You can increase the temperature in the settings which would allow for more creative/liberal translations.
  • Only make those or any other changes - especially to the code - only if you are familiar enough with python/programming in general.

And this is more a fancy idea than a suggestion to be taken seriously:

  • If you are really invested in this and have enough resources (time, ML knowledge, money, enough high-quality data -> in your case the french and chinese version of novels) you can absolutely fine-tune a model yourself using the novels that interest you to create a dataset for the fine-tuning. Whether this makes sense cost–benefit wise, is a question you'll have to answer for yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants