Skip to content

Commit 4cdf0df

Browse files
prompt tuning
1 parent 23e75df commit 4cdf0df

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

core/CAIAssistant.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, promptsFolder=None):
2828
HumanMessagePromptTemplate(
2929
prompt=PromptTemplate.from_file(
3030
os.path.join(promptsFolder, 'translate_deep.txt'),
31-
input_variables=['UserInput', 'FastTranslation', 'Language', 'Flags']
31+
input_variables=['UserInput', 'FastTranslation', 'Language', 'Flags', 'InputLanguage']
3232
)
3333
),
3434
]),
@@ -70,6 +70,7 @@ def translate(self, text, fastTranslation, language):
7070
'UserInput': text,
7171
'FastTranslation': translation['Translation'], # use shallow translation as reference
7272
'Language': language,
73+
'InputLanguage': translation.get('Input language', 'unknown'),
7374
'Flags': ', '.join([k for k, v in flags.items() if v])
7475
})
7576
# extract final translation

prompts/translate_deep.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$UserInput$: "{UserInput}"
22
$Reference$: "{FastTranslation}"
33
$Extra flags$: {Flags}
4-
$Task$: translate $UserInput$ to {Language}. $Reference$ may not be accurate. Refine step by step translation of $UserInput$ to {Language} while keeping the meaning as close as possible to $UserInput$. Consider $Extra flags$.
4+
$Task$: translate $UserInput$ to {Language}. $Reference$ may not be accurate. Refine step by step translation of $UserInput$ to {Language} while keeping the meaning as close as possible to $UserInput$. Consider $Extra flags$. Input text is in {InputLanguage}, consider their mentality and cultural differences. Suggest clarifications, that would be useful for translation.
55
Response in exactly following format:
66
```
77
@$UserInput$ in English: {{here is $UserInput$ in English}}
@@ -13,7 +13,7 @@ Response in exactly following format:
1313
1. {{quote the parts needing clarity, jargon, etc.}}
1414
@List of ambiguous pronoun usage (at least 3):
1515
1. {{quote the parts with pronoun ambiguities}}
16-
@List of suggested translations to {Language} with corresponding fixes (per issue):
17-
1. {{fixes. Resolve all issues. Resolve all ambiguities by most likely meaning.}}
16+
@List of ALL resolved issues described above:
17+
1. {{Resolve issues and ambiguities by most likely meaning. Provide translation to {Language}}}
1818
@Translation: {{here is $UserInput$ in {Language} with all fixes}}
1919
```

prompts/translate_shallow.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ $FastTranslation$: "{FastTranslation}"
33
$Task$: "translate $UserInput$ to {Language}. $FastTranslation$ is a fast translation. It may not be accurate. Take into account that user may use jokes, jargon, etc. in $UserInput$."
44
Response in exactly following format:
55
```
6+
@Input language: {{main language of $UserInput$, single language}}
67
@Translation:
78
{{Translation of $UserInput$ to {Language}}}
89
@Contains jokes: {{Yes/No}}

0 commit comments

Comments
 (0)