Spaces:
Runtime error
Runtime error
Anonymous
commited on
Commit
·
f31b1b7
1
Parent(s):
32eac11
fix instruction
Browse files- tasks/summarization.py +3 -3
tasks/summarization.py
CHANGED
|
@@ -97,7 +97,7 @@ def _translate_example(example: Dict[str, str], src_language: str, target_langua
|
|
| 97 |
print(e)
|
| 98 |
|
| 99 |
|
| 100 |
-
def create_instruction(lang: str, expected_output: str):
|
| 101 |
basic_instruction = (
|
| 102 |
f"Write a summary of the given <Text> \n The output should be in {expected_output} "
|
| 103 |
f"\n The output must be up to 2 sentences maximum!!!"
|
|
@@ -105,7 +105,7 @@ def create_instruction(lang: str, expected_output: str):
|
|
| 105 |
print(lang)
|
| 106 |
return (
|
| 107 |
basic_instruction
|
| 108 |
-
if
|
| 109 |
else _translate_instruction(basic_instruction, target_language=lang)
|
| 110 |
)
|
| 111 |
|
|
@@ -127,7 +127,7 @@ def construct_prompt(
|
|
| 127 |
):
|
| 128 |
if not instruction:
|
| 129 |
print(lang)
|
| 130 |
-
instruction = create_instruction(lang, config['prefix'])
|
| 131 |
|
| 132 |
example_prompt = PromptTemplate(
|
| 133 |
input_variables=["summary", "text"], template="Text: {text}\nSummary: {summary}"
|
|
|
|
| 97 |
print(e)
|
| 98 |
|
| 99 |
|
| 100 |
+
def create_instruction(lang: str, instruction_language: str, expected_output: str):
|
| 101 |
basic_instruction = (
|
| 102 |
f"Write a summary of the given <Text> \n The output should be in {expected_output} "
|
| 103 |
f"\n The output must be up to 2 sentences maximum!!!"
|
|
|
|
| 105 |
print(lang)
|
| 106 |
return (
|
| 107 |
basic_instruction
|
| 108 |
+
if instruction_language == "english"
|
| 109 |
else _translate_instruction(basic_instruction, target_language=lang)
|
| 110 |
)
|
| 111 |
|
|
|
|
| 127 |
):
|
| 128 |
if not instruction:
|
| 129 |
print(lang)
|
| 130 |
+
instruction = create_instruction(lang, config['prefix'], config['output'])
|
| 131 |
|
| 132 |
example_prompt = PromptTemplate(
|
| 133 |
input_variables=["summary", "text"], template="Text: {text}\nSummary: {summary}"
|