Skip to content
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

modified machine translation assets #179

Merged
merged 4 commits into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions assets/benchmark_v1/MT/AraBench_Ara2Eng_ChatGPT4_ZeroShot.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ def config():
"madar.test.nil.0.sd",
"madar.test.nil.1.eg",
"madar.test.nil.2.eg",
"summa-2M.test.mgr.0.ma",
"summa-AJ.test.msa.0.ms",
"summa-BBC.test.msa.0.ms",
"summa-LBC.test.lev.0.lb",
"summa-Oman.test.glf.0.om",
]
configs = []
for testset in sets:
Expand Down Expand Up @@ -84,14 +79,17 @@ def prompt(input_sample):
return [
{
"role": "system",
"content": "You are an AI assistant that helps people find information.",
"content": "You are an expert translator specialized in translating texts from Arabic to English. You are concise as you only output the translation of the text without any illustrations or extra details",
},
{
"role": "user",
"content": f"Translate the following to English, output only the translation:\n {input_sample}",
"content": f"Translate the following text to English.\nText: {input_sample}\nTranslation: ",
},
]


def post_process(response):
return response["choices"][0]["message"]["content"]
response = response["choices"][0]["message"]["content"]
response = response.replace('"', "")
response = response.strip()
return response
15 changes: 7 additions & 8 deletions assets/benchmark_v1/MT/AraBench_Ara2Eng_ChatGPT_ZeroShot.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@ def config():
"madar.test.nil.0.sd",
"madar.test.nil.1.eg",
"madar.test.nil.2.eg",
"summa-2M.test.mgr.0.ma",
"summa-AJ.test.msa.0.ms",
"summa-BBC.test.msa.0.ms",
"summa-LBC.test.lev.0.lb",
"summa-Oman.test.glf.0.om",
]

configs = []
for testset in sets:
configs.append(
Expand Down Expand Up @@ -82,15 +78,18 @@ def config():

def prompt(input_sample):
return {
"system_message": "You are an AI assistant that helps people find information.",
"system_message": "You are an expert translator specialized in translating texts from Arabic to English. You are concise as you only output the translation of the text without any illustrations or extra details",
"messages": [
{
"sender": "user",
"text": f"Translate the following to English, output only the translation:\n {input_sample}",
"text": f"Translate the following text to English.\nText: {input_sample}\nTranslation: ",
}
],
}


def post_process(response):
return response["choices"][0]["text"]
response = response["choices"][0]["text"]
response = response.replace('"', "")
response = response.strip()
return response
Loading