Ik heb een Spaanse leraar gemaakt met GPT4 die met mij Spaans oefent, concepten uitlegt en vertelt wat ik kan verbeteren.

En dat werkt verbazingwekkend goed!


Een goede basis krijg je al met een handige system prompt:

📺You are my Spanish tutor.

You provide me with sentences in English on A2 level, which I have to translate into Spanish.

After each of my responses, you let me know whether I have correctly translated your sentence and point out any mistakes I've made.

In addition, you explain the concepts that I misunderstood.

🤖Okay, let's start. Here's your first sentence:

"I like to play football with my friends during the weekend.”

👱🏻‍♂️Quiero jugar al futbal con mis amigos durante el fin de semana

🤖Your sentence is almost correct, but you should use "Me gusta" instead of "Quiero" since the English sentence says "I like" and not "I want".

The correct translation should be:
"Me gusta jugar al fútbol con mis amigos durante el fin de semana."
Keep it up!

Dit werkt direct vanuit de GPT sandbox al verbazingwekkend goed. Toch liep ik in de praktijk tegen wat issues aan:

  1. Het model is niet al te origineel in de zinnetjes die het genereert. Veelal over met vrienden of familie naar strand of park. En die woorden ken ik op een gegeven moment wel.
  2. Het zou mooi zijn als de tutor terug komt op concepten die ik eerder fout had.

Met de OpenAI API en wat slimme prompt engineering zijn deze beiden op te lossen.

1. Meer diversiteit in woorden

Ik heb online een lijst gevonden met de 1000 meest voorkomende woorden. Als ik vervolgens niet rechtstreeks met het model praat maar de API gebruik, dan kan mij script de prompt steeds een beetje aanpassen. Dus in plaats van

👱🏻‍♂️ give me the next sentence

wordt het:

👱🏻‍♂️give me the next sentence and make sure you use the word “hospital”

2. Terugkomen op concepten die ik verkeerd deed

Het tweede probleem is wat ingewikkelder. Hiertoe moest ik het model vragen om het antwoord in een gestructureerd formaat (JSON) terug te geven zodat mijn script kon herkennen of ik het antwoord goed of fout had.

📺You are a Spanish language tutor.
You are tutoring me in Spanish on A2 level.
You provide me with sentences in English which I will have to translate into Spanish.
Always provide your answer in JSON format.

You can provide three types of response.

1. When I type "next" you provide a new sentence for me to translate and the type is "sentence" like this:
{"type": "sentence",
"response":
"She is reading a book at the library"}

2. When I give a translation in Spanish you analyse my answer and respond with how I did and
you explain all that I did wrong and how to prevent that in the future. In this case the type is "analysis" and the verdict is "right" or "wrong" depending on whether I translated the sentence well or not.
Your answer will be like this:
{"type": "analysis",
"verdict": "wrong",
"response": "Just a small mistake in the verb: the correct translation is 'Ella está leyendo un libro en la biblioteca'. Use 'leyendo' instead of 'leyando' for 'reading'.",
"right_answer": "Ella está leyendo un libro en la biblioteca"}

De prompt gaat nog wat langer door want het model heeft wat voorbeelden nodig van goede en foute antwoorden en hoe dan het antwoord in JSON formaat te structureren.

Het resultaat is dat mijn script kan opvangen wat er goed gaan en wat niet en daarmee kan ik de volgende prompt dan weer automatisch aanpassen:

👱🏻‍♂️You previously asked
"She is reading a book at the library"
and I answered
"Ella está leyando un libro en la biblioteca"

Your analysis was:
"Just a small mistake in the verb: the correct translation is 'Ella está leyendo un libro en la biblioteca'. Use 'leyendo' instead of 'leyando' for 'reading'."

Now generate a new sentence that includes one or more of the concepts I got wrong.

And make sure you use the word “always”.

🤖Ok, here’s your next sentence:
”My cousin is always reading the newspaper in the morning”

Fixed!

Hiermee hebben we een afwisselende tutor die terug komt op concepten die lastig zijn.

Als het het leuk vindt: mijn (Python) code staat op GitHub: https://github.com/hpharmsen/tutor.


Vorige post: DragGAN