GPT prompt for translation in a specific type

I create a Website that should translate a given text to a language in a specific speech style. It should also be possible instead of a task to input a job that should be done before translating. Therefore I use two gpt prompts as shown below.
I use the gpt-4 openai model with temperature 0.
The problem is that gpt-4 sometimes translates a given task and doesn’t interpret the task itself. The other way around as well.

Can you help me improve the prompt?

Prompt for the translation mode:

You are a translator gpt that creates translations for different speech levels.

TASK: Do the following steps:\n
      1. correct spelling and grammatical mistakes of the text: ```". $userInput["prompt"] ."```.\n
      2. detect the language of the text: ```". $userInput["prompt"] ."``` .\n
      3. translate the text: ```". $userInput["prompt"] ."``` to the language " . $userInput["targetLanguage"]. ". 
         Do not interpret or change the text. The result should be a straigth translation to the text..\n
      4. compose the translated text in a style appropriate for a ". $person .".\n
\n
        
EXAMPLE: input: ```Das ist eiin Hund```; ```Deutsch```; ```child``` \n
      1. Das ist ein Hund \n
      2. Deutsch
      3. This is a dog
      4. child: This is a doggy; academic: This is a canine specimen; normal: This is a dog
        
OUTPUT: Only return a valid in json format as described below\n

RESPONSE_FORMAT: 
        {
            \"input\" : \"result of step 1.\",
            \"language\" : \"result of step 2.\",
            \"translation\" : \"result of step 4.\"
        }

Ensure the response can be decoded by PHP json_decode

Prompt for the task mode:

TASK: Do the following steps:\n
      1. ". $userInput["prompt"] .". 
      2. Translate the result to " . $userInput["targetLanguage"]. ".
      3. compose the translated text in a style appropriate for a ". $person .".\n
      4. detect the language of the text: ```". $userInput["prompt"] ."``` .\n

EXAMPLE: input: ```Writee a poem```; ```Deutsch```; ```child``` \n
      1. Write a poem \n
      2. In morgenroten gold'nem Schein, die Farben tanzen, wild und fein. Im leisen Flüstern, Schatten spielen, Dort Worte, die Poeten fühlen.
      3.  child: Im Sonnenschein, so warm und hell, die Farben tanzen, bunt und schnell. Die Blumen flüstern, Vögel singen, Da kann ein Kind die Freude bringen.;
      4. Englisch
            
OUTPUT: Only return a valid in JSON format as described below\n
RESPONSE_FORMAT: 
            {
                \"input\" : \"". $userInput["prompt"] ."\",
                \"language\" : \"result of step 4.\",
                \"translation\" : \"result of step 3.\"
            }
Ensure the response can be decoded by PHP json_decode

Probably the biggest thing about your step-by-step approach to instructions is that the language model can’t really improve quality in unseen steps. It can only shape the output it makes by the whole of the instructions. It has no internal memory to do data processing. It also definitely can’t work backwards like your final task.

What you’d need to do is allow it to generate and see the output of each step. That means the user also sees each step, unless you specifically capture only the final output format.

A one-prompt chain-of-thought that could work:

From the input text, output each of these data products:

  1. (input) Generate: Improve quality
  2. (language) Identify language
  3. (translation) Translate to {language}
  4. (audience) Variation: rewrite step 3 translation output to target this audience: {reader}
  5. (backend output) Enclose within triple-quotes: Python dictionary output using the data products: [input, language, audience]. Escape quote characters of dictionary format.

Certainly you could rewrite and refine so that 5 is eliminated, and that prior steps are the backend outputs in the container. My example makes it clear.

2 Likes