-
Notifications
You must be signed in to change notification settings - Fork 0
/
llama2datageneratorcsv.js
241 lines (232 loc) · 7.44 KB
/
llama2datageneratorcsv.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
// only english for mistral
const filename = "train.csv"
const fs = require('fs');
let instruction = `Choose from one of ('weather' or 'other topic') what input is related to, input can be in indonesian or english, response always in english. Detail is from context if not available in input`
let othertopic = `Related to : other topic`
let array = [
{
instruction: instruction,
context: ``,
input: `Whats the weather like next week ?`,
response: `Related to : weather, detail : weather, when : next week, how many days from today : 0`
},
{
instruction: instruction,
context: `rain`,
input: `Whats the weather like next week ?`,
response: `Related to : weather, detail : weather, when : next week, how many days from today : 0`
},
{
instruction: instruction,
context: `snow`,
input: `Whats the weather like today ?`,
response: `Related to : weather, detail : weather, when : today, how many days from today : 0`
},
{
instruction: instruction,
context: ``,
input: `Whats the weather like today ?`,
response: `Related to : weather, detail : weather, when : today, how many days from today : 0`
},
{
instruction: instruction,
context: ``,
input: `Will it rain today ?`,
response: `Related to : weather, detail : rain, when : today, how many days from today : 0`
},
{
instruction: instruction,
context: ``,
input: `Will it rain 2 days from now ?`,
response: `Related to : weather, detail : rain, when : 2 days from now, how many days from today : 2`
},
{
instruction: instruction,
context: ``,
input: `Is it raining yesterday ?`,
response: `Related to : weather, detail : rain, when : yesterday, how many days from today : -1`
},
{
instruction: instruction,
context: `rain`,
input: `What about today ?`,
response: `Related to : weather, detail : rain, when : today, how many days from today : 0`
},
{
instruction: instruction,
context: `rain`,
input: `What about 2 days from now ?`,
response: `Related to : weather, detail : rain, when : 2 days from now, how many days from today : 2`
},
{
instruction: instruction,
context: `rain`,
input: `What about 10 days from now ?`,
response: `Related to : weather, detail : rain, when : 10 days from now, how many days from today : 10`
},
{
instruction: instruction,
context: `rain`,
input: `How about 10 days from now ?`,
response: `Related to : weather, detail : rain, when : 10 days from now, how many days from today : 10`
},
{
instruction: instruction,
context: `snow`,
input: `What about 3 days from now ?`,
response: `Related to : weather, detail : snow, when : 3 days from now, how many days from today : 3`
},
{
instruction: instruction,
context: `snow`,
input: `What about 15 days from now ?`,
response: `Related to : weather, detail : snow, when : 15 days from now, how many days from today : 15`
},
{
instruction: instruction,
context: ``,
input: `Will it rain next week ?`,
response: `Related to : weather, detail : rain, when : next week, how many days from today : 7`
},
{
instruction: instruction,
context: `rain`,
input: `What about tommorow ?`,
response: `Related to : weather, detail : rain, when : tommorow, how many days from today : 0`
},
{
instruction: instruction,
context: `thunderstorm`,
input: `What about tommorow ?`,
response: `Related to : weather, detail : thunderstorm, when : tommorow, how many days from today : 1`
},
{
instruction: instruction,
context: `snow`,
input: `What about tommorow ?`,
response: `Related to : weather, detail : snow, when : tommorow, how many days from today : 1`
},
{
instruction: instruction,
context: `snow`,
input: `What about next week ?`,
response: `Related to : weather, detail : snow, when : next week, how many days from today : 7`
},
{
instruction: instruction,
context: ``,
input: `Will it snow today ?`,
response: `Related to : weather, detail : snow, when : today, how many days from today : 0`
},
{
instruction: instruction,
context: `rain`,
input: `Will it snow today ?`,
response: `Related to : weather, detail : snow, when : today, how many days from today : 0`
},
{
instruction: instruction,
context: ``,
input: `Will it snow tommorow ?`,
response: `Related to : weather, detail : snow, when : tommorow, how many days from today : 1`
},
{
instruction: instruction,
context: `rain`,
input: `Is thunderstorm coming ?`,
response: `Related to : weather, detail : thunderstorm, when : today, how many days from today : 0`
},
{
instruction: instruction,
context: ``,
input: `Is thunderstorm coming ?`,
response: `Related to : weather, detail : thunderstorm, when : today, how many days from today : 0`
},
{
instruction: instruction,
context: ``,
input: `What's your name ?`,
response: othertopic
},
{
instruction: instruction,
context: `rain`,
input: `What's your name ?`,
response: othertopic
},
{
instruction: instruction,
context: ``,
input: `Tell me about trump`,
response: othertopic
},
{
instruction: instruction,
context: `thunderstorm`,
input: `Explain why you so smart`,
response: othertopic
},
{
instruction: instruction,
context: ``,
input: `Explain why you so smart`,
response: othertopic
},
{
instruction: instruction,
context: ``,
input: `I want to order pizza`,
response: othertopic
},
{
instruction: instruction,
context: `weather`,
input: `I want to order pizza`,
response: othertopic
},
{
instruction: instruction,
context: `weather`,
input: `what is 20+40`,
response: othertopic
},
{
instruction: instruction,
context: ``,
input: `fuck you`,
response: othertopic
},
{
instruction: instruction,
context: ``,
input: `motherfucker`,
response: othertopic
},
]
// function jsonToCsv(data) {
// return (
// Object.keys(data[0]).join(",") +
// "\n" +
// data.map((d) => Object.values(d).join(",")).join("\n")
// );
// }
// console.log(jsonToCsv(array))
fs.writeFile(filename, '', (err) => {
if (err) {
console.error(err);
return;
}
});
line = "text\n"
array.forEach(e => {
const text = `"### Instruction : ${e.instruction}\n### Context : ${e.context}\n### Input : ${e.input}\n### Response : ${e.response}"`
// const text = ','+`### Instruction : ${e.instruction} ### Context : ${e.context} ### Input : ${e.input} ### Response : ${e.response}`
line = line + text + "\n"
});
fs.appendFile(filename, line, (err) => {
if (err) {
console.error(err);
return;
}
});
// console.log(line)