-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllama2datageneratorusingexample archive.js
206 lines (199 loc) · 7.03 KB
/
llama2datageneratorusingexample archive.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
// training using example is not working, when training dont use example just instruction, but when inferencing use example
const filename = "llama2data.jsonl"
const fs = require('fs');
let instruction = `Choose from one of ('weather' or 'other topic') for response`
let example = `below is example
# Context : empty
# Input : Whats the weather like next week ?
# Response : Related to : weather, detail : weather, when : next week, how many days from today : 7
# Context : empty
# Input : who is trump
# Response : other topic
# Context : rain
# Input : how about next week
# Response : Related to : weather, detail : rain, when : next week, how many days from today : 7
solve below based on example
# Context : empty
# Input : whats the weather like
# Response : Related to : weather, detail : weather, when : today, how many days from today : 0
`
// let lines = example.split('\n');
// let combinedText = lines.join('\n');
// console.log(combinedText);
let array = [
{
instruction: instruction,
context: `empty`,
input: `will it rain`,
response: 'Related to : weather, detail : rain, when : today, how many days from today : 0'
},
{
instruction: instruction,
context: `empty`,
input: `whats the weather like`,
response: 'Related to : weather, detail : weather, when : today, how many days from today : 0'
},
{
instruction: instruction,
context: `snow`,
input: `whats the weather`,
response: 'Related to : weather, detail : snow, when : today, how many days from today : 0'
},
{
instruction: instruction,
context: `rain`,
input: `bagaimana dengan 12 hari dari hari ini`,
response: 'Related to : weather, detail : thunderstorm, when : 12 days from today, how many days from today : 12'
},
{
instruction: instruction,
context: `snow`,
input: `bagaimana dengan 12 hari dari sekarang`,
response: 'Related to : weather, detail : snow, when : 12 days from today, how many days from today : 12'
},
{
instruction: instruction,
context: `thunderstorm`,
input: `bagaimana dengan 20 hari dari sekarang`,
response: 'Related to : weather, detail : thunderstorm, when : 20 days from today, how many days from today : 20'
},
{
instruction: instruction,
context: `empty`,
input: `i want to order some pizza please`,
response: 'Related to : other topic'
},
{
instruction: instruction,
context: `empty`,
input: `apakah nanti malam akan hujan`,
response: 'Related to : weather, detail : rain, when : tonight, how many days from today : 0'
},
{
instruction: instruction,
context: `snow`,
input: `apakah nanti malam akan hujan`,
response: 'Related to : weather, detail : rain, when : tonight, how many days from today : 0'
},
{
instruction: instruction,
context: `snow`,
input: `bagaimana dengan kemarin`,
response: 'Related to : weather, detail : snow, when : yesterday, how many days from today : -1'
},
{
instruction: instruction,
context: `rain`,
input: `bagaimana dengan besok`,
response: 'Related to : weather, detail : rain, when : tommorow, how many days from today : 1'
},
{
instruction: instruction,
context: `snow`,
input: `apakah hari ini akan hujan`,
response: 'Related to : weather, detail : rain, when : today, how many days from today : 0'
},
{
instruction: instruction,
context: `rain`,
input: `how about tommorow`,
response: 'Related to : weather, detail : rain, when : 1 days from now, how many days from today : 1'
},
{
instruction: instruction,
context: `rain`,
input: `how 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: `snow`,
input: `how about 2 days from now`,
response: 'Related to : weather, detail : snow, when : 2 days from now, how many days from today : 2'
},
{
instruction: instruction,
context: `thunderstorm`,
input: `bagaimana dengan kemarin`,
response: 'Related to : weather, detail : thunderstorm, when : yesterday, how many days from today : -1'
},
{
instruction: instruction,
context: `snow`,
input: `bagaimana dengan kemarin`,
response: 'Related to : weather, detail : snow, when : yesterday, how many days from today : -1'
},
{
instruction: instruction,
context: `empty`,
input: `Whats your name`,
response: 'Related to : other topic'
},
{
instruction: instruction,
context: `rain`,
input: `Whats your name`,
response: 'Related to : other topic'
},
{
instruction: instruction,
context: `snow`,
input: `what about 30 days from today`,
response: 'Related to : weather, detail : snow, when : 30 days from today, how many days from today : 30'
},
{
instruction: instruction,
context: `thunderstorm`,
input: `what about previous 2 days from today`,
response: 'Related to : weather, detail : thunderstorm, when : previous 2 days from today, how many days from today : -2'
},
{
instruction: instruction,
context: `rain`,
input: `what about yesterday`,
response: 'Related to : weather, detail : thunderstorm, when : yesterday, how many days from today : -1'
},
{
instruction: instruction,
context: `rain`,
input: `will thunderstorm coming next week ?`,
response: 'Related to : weather, detail : thunderstorm, when : next week, how many days from today : 7'
},
{
instruction: instruction,
context: `snow`,
input: `did thunderstorm came yesterday ?`,
response: 'Related to : weather, detail : snow, when : yesterday, how many days from today : -1'
},
]
fs.writeFile(filename, '', (err) => {
if (err) {
console.error(err);
return;
}
});
// for example
let text = `# Instruction : ${instruction}\n`
text = text + example
const json = JSON.stringify({ text: text })
fs.appendFile(filename, json + '\n', (err) => {
if (err) {
console.error(err);
return;
}
});
array.forEach(e => {
// let text = `# Instruction : ${e.instruction}\nexample\n`
let text = `# Instruction : ${e.instruction}\n`
// text=text+example+'\nsolve this\n'+`# Context : ${e.context}\n# Input : ${e.input}\n# Response : ${e.response}\n`
text = text + `# Context : ${e.context}\n# Input : ${e.input}\n# Response : ${e.response}\n`
// console.log(text)
const json = JSON.stringify({ text: text })
// console.log(text)
fs.appendFile(filename, json + '\n', (err) => {
if (err) {
console.error(err);
return;
}
});
});