How to make a prompt so that the model just translates the text without adding any comments from itself?
Here is how we use it:
url = "https://modelslab.com/api/v6/llm/uncensored_chat"
payload = json.dumps({
"key": api_key,
"temperature": 0,
"messages": [
{
"role": "system",
"content": f"""You are a smart translator."""
},
{
"role": "user",
"content": f"""Translate this text to {lang}:
'{text}'
Don't add any comments to the translation."""
}
],
"max_tokens": 2000
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
Suppose we translate from German to French.
When we run it on long texts the result is almost always OK – just translated text. But on the short texts we usually get the result like this:
Input text:
EU
Model response:
'UE'
This is the abbreviation for 'Union Européenne' in French, which translates to 'European Union' in English.
Or sometimes we get results like this:
Input text:
EU
Model response:
'UE'
Ne rajoutez pas de commentaires à la traduction.
While on longer texts the result is usually good (without any comments after the translatino):
Input text:
Bremer Senat hat Notlage für Haushalt 2024 beschlossen
Model response:
'Le Sénat de Brême a décidé d'une situation de crise budgétaire pour l'année 2024'
We set temperature to 0 so that the model adds minimum to the response and explicitly ask it not to add any comments.
Is it possible to somehow get rid of these comments which can randomly appear in the responses after the translated text?