Commit
·
45df06f
1
Parent(s):
0c783bc
Update README.md
Browse files
README.md
CHANGED
|
@@ -45,12 +45,56 @@ load_dataset("tdtunlp/opus100_envi")
|
|
| 45 |
- Format for Translation task
|
| 46 |
|
| 47 |
```python
|
| 48 |
-
def preprocess(
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
"""
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
"""
|
| 56 |
```
|
|
|
|
| 45 |
- Format for Translation task
|
| 46 |
|
| 47 |
```python
|
| 48 |
+
def preprocess(
|
| 49 |
+
sample,
|
| 50 |
+
instruction_key="### Instruction:",
|
| 51 |
+
input_key="Input:",
|
| 52 |
+
response_key="<|endofprompt|>",
|
| 53 |
+
end_key="<|endoftext|>",
|
| 54 |
+
en2vi=True,
|
| 55 |
+
):
|
| 56 |
+
if en2vi:
|
| 57 |
+
if random.random() < 0.5:
|
| 58 |
+
instruction = "Translate the following sentences from English into Vietnamese."
|
| 59 |
+
else:
|
| 60 |
+
instruction = "Dịch các câu sau từ tiếng Anh sang tiếng Việt."
|
| 61 |
+
|
| 62 |
+
input = sample['en'].strip()
|
| 63 |
+
response = sample['vi'].strip()
|
| 64 |
+
else:
|
| 65 |
+
if random.random() < 0.5:
|
| 66 |
+
instruction = "Translate the following sentences from Vietnamese into English."
|
| 67 |
+
else:
|
| 68 |
+
instruction = "Dịch các câu sau từ tiếng Việt sang tiếng Anh."
|
| 69 |
+
|
| 70 |
+
input = sample['vi'].strip()
|
| 71 |
+
response = sample['en'].strip()
|
| 72 |
+
|
| 73 |
+
return {'text': """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
| 74 |
+
{instruction_key}
|
| 75 |
+
{instruction}
|
| 76 |
+
{input_key}
|
| 77 |
+
{input}
|
| 78 |
+
{response_key}
|
| 79 |
+
{response}
|
| 80 |
+
{end_key}""".format(
|
| 81 |
+
instruction_key=instruction_key,
|
| 82 |
+
instruction=instruction,
|
| 83 |
+
input_key=input_key,
|
| 84 |
+
input=input,
|
| 85 |
+
response_key=response_key,
|
| 86 |
+
response=response,
|
| 87 |
+
end_key=end_key,
|
| 88 |
+
)}
|
| 89 |
|
| 90 |
"""
|
| 91 |
+
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
| 92 |
+
### Instruction:
|
| 93 |
+
Dịch các câu sau từ tiếng Anh sang tiếng Việt.
|
| 94 |
+
Input:
|
| 95 |
+
Toast falls jelly-side down, children hit tables and people get hurt.
|
| 96 |
+
<|endofprompt|>
|
| 97 |
+
Bánh mì nướng rơi đông lại, trẻ con va vào bàn và con người bị thương.
|
| 98 |
+
<|endoftext|>
|
| 99 |
"""
|
| 100 |
```
|