xzuyn commited on
Commit
b6e391d
·
1 Parent(s): ba682ec

Upload 2 files

Browse files
.gitattributes CHANGED
@@ -53,3 +53,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
56
+ manythings-translations-alpaca.json filter=lfs diff=lfs merge=lfs -text
make_manythings-translations-alpaca.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import random
3
+
4
+ # Read the JSONL file and parse each line into a dictionary
5
+ with open('combined-randomized.jsonl', 'r') as file:
6
+ data = [json.loads(line) for line in file][:] # Limit to the first 50 lines
7
+
8
+ # List of phrases to randomly choose from
9
+ instruction_phrases = [
10
+ "i need a translation",
11
+ "convert the following text",
12
+ "convert the following message",
13
+ "convert the following sentence",
14
+ "communicate this text",
15
+ "communicate this message",
16
+ "communicate this sentence",
17
+ "can you communicate this text",
18
+ "can you communicate this message",
19
+ "can you communicate this sentence",
20
+ "please communicate this text",
21
+ "please communicate this message",
22
+ "please communicate this sentence",
23
+ "please can you communicate this text",
24
+ "please can you communicate this message",
25
+ "please can you communicate this sentence",
26
+ "can you please communicate this text",
27
+ "can you please communicate this message",
28
+ "can you please communicate this sentence",
29
+ "translate this text",
30
+ "translate this message",
31
+ "translate this sentence",
32
+ "can you translate this text",
33
+ "can you translate this message",
34
+ "can you translate this sentence",
35
+ "please translate this text",
36
+ "please translate this message",
37
+ "please translate this sentence",
38
+ "please can you translate this text",
39
+ "please can you translate this message",
40
+ "please can you translate this sentence",
41
+ "can you please translate this text",
42
+ "can you please translate this message",
43
+ "can you please translate this sentence",
44
+ "switch the text",
45
+ "switch the message",
46
+ "switch the sentence",
47
+ "can you switch the text",
48
+ "can you switch the message",
49
+ "can you switch the sentence",
50
+ "please switch the text",
51
+ "please switch the message",
52
+ "please switch the sentence",
53
+ "please can you switch the text",
54
+ "please can you switch the message",
55
+ "please can you switch the sentence",
56
+ "can you please switch the text",
57
+ "can you please switch the message",
58
+ "can you please switch the sentence",
59
+ "translate this input text",
60
+ "translate this input message",
61
+ "translate this input sentence",
62
+ "can you translate this input text",
63
+ "can you translate this input message",
64
+ "can you translate this input sentence",
65
+ "please translate this input text",
66
+ "please translate this input message",
67
+ "please translate this input sentence",
68
+ "please can you translate this input text",
69
+ "please can you translate this input message",
70
+ "please can you translate this input sentence",
71
+ "can you please translate this input text",
72
+ "can you please translate this input message",
73
+ "can you please translate this input sentence",
74
+ "convert",
75
+ "please convert",
76
+ "please can you convert",
77
+ "can you please convert",
78
+ "translate",
79
+ "please translate",
80
+ "please can you translate",
81
+ "can you please translate",
82
+ ]
83
+
84
+ # Function to create the instruction based on language pairs
85
+ def create_instruction(from_lang, to_lang):
86
+ phrase = random.choice(instruction_phrases)
87
+ # Randomly decide to capitalize the phrase
88
+ if random.random() < 0.5:
89
+ phrase = phrase.capitalize()
90
+ phrase = f"{phrase} from {from_lang} to {to_lang}"
91
+ # Randomly decide to add a question mark
92
+ if random.random() < 0.5:
93
+ phrase += "?"
94
+ return phrase
95
+
96
+ # Initialize the final list to hold the formatted JSON data
97
+ formatted_data = []
98
+
99
+ # Iterate through each item in the original data and create two formatted entries for each
100
+ for item in data:
101
+ english_text = item.get('english')
102
+ if english_text:
103
+ for target_lang, translation in item.items():
104
+ if target_lang != 'english':
105
+ # Add instruction and input/output pairs to the formatted_data list for English to target language
106
+ formatted_data.append({
107
+ "instruction": create_instruction("English", target_lang.capitalize()),
108
+ "input": english_text,
109
+ "output": translation
110
+ })
111
+
112
+ # Add instruction and input/output pairs to the formatted_data list for target language to English
113
+ formatted_data.append({
114
+ "instruction": create_instruction(target_lang.capitalize(), "English"),
115
+ "input": translation,
116
+ "output": english_text
117
+ })
118
+
119
+ # Randomize the order of the formatted data
120
+ random.shuffle(formatted_data)
121
+
122
+ # Convert the formatted_data list to JSON format
123
+ formatted_json = json.dumps(formatted_data, indent=2)
124
+
125
+ # Save the formatted JSON data to a new file
126
+ with open('manythings-translations-alpaca.json', 'w') as output_file:
127
+ output_file.write(formatted_json)
128
+
manythings-translations-alpaca.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4e24d2de9fac8fdd054365365d2c76b4de837cb1e18bc0bfc7b0fec3c3f0fc0e
3
+ size 1395150889