hxebolax / TranslateAdvanced

Traductor Avanzado para NVDA es un complemento que permite traducir textos usando Google Translate, DeepL, LibreTranslate y Microsoft Translator. Ofrece traducción simultánea, historial y gestión de claves API. Fácil de configurar y usar, con teclas rápidas y opciones personalizables en el menú de NVDA.
GNU General Public License v2.0
5 stars 6 forks source link

Issues With Open AI System Prompt #14

Open dangero2000 opened 10 hours ago

dangero2000 commented 10 hours ago

Hello, I believe there is an issue with the way the Open AI system prompt is written in the code. Given how Open AI is not a translation engine specifically, sometimes it will add things when it is not appropriate to do so. I have also had it transliterate Japanese into English rather than translating it. This could be fixed by allowing the user to set the system prompt themselves through one of the addon dialogues. In the meantime, however, I could probably fix the system prompt myself and submit a pull request, provided you can point me to where it's written. I've been working with GPT for a while now, so I'm pretty confident I could fix the problem if you don't mind.

dangero2000 commented 9 hours ago

I have discovered the problem. The system prompt is not persistent enough. What I mean is, GPT is not as intelligent as people think. Basically, you have to explain things like you're giving orders to a 5-year-old. This is what I have changed my system prompt to: {"role": "user", "content": f"You are strictly a translator. Translate the following text exactly as is to the language specified by the ISO 639-1 code '{self.target_language}'. Do not change proper names, idioms, or provide explanations for anything. Do not ignore text. Do not add anything extra to the text. You must always translate the text and never transliterate it unless it is a name or title. You must output the translated text exactly as is and nothing else: '{chunk}'"} I know this may seem a little excessive, but this is the way you have to talk to it in order to make it stay true to its task. Otherwise, you run into issues like this: Original Text: "はじめから:新しいセーブデータを作成し、ゲームをプレイします。" Translated Text: "hajimekara: create a new save data and play the game." It can also help if you give it specific examples of what not to do when translating. I have not done this yet, and I'm still working on my system prompt. If you like, I can submit a pull request when I'm done configuring it, unless you are planning to allow users to set their own system text through the addon itself. I think I mentioned this before, but as a language learner, it would be useful for me to set a custom system prompt in order to develop my language skills further. I would lose this prompt every time an update comes out with the current system in place. I know how to change the prompt in the code itself which is good enough for my use case for the time being, but others may not know what to do. Plus, it would be good to have a simple edit box for this in general anyway.

hxebolax commented 7 hours ago

Hello, I will work better on your second request.

Since you have been able to change the prompt, in this version it is now like this and I am starting to work on being able to customize the prompt for the user if they wish or leave the one that just passed here as predefined.

I am not sure when the custom prompt will arrive because I have a lot of work right now, but if a new version comes out and I am not able to finish said function, at least I will change the prompt to the one you are passing.

Thank you