Skip to content

Commit 39a3002

Browse files
committed
Add puzzle 15 vocab.
1 parent 063a9b3 commit 39a3002

File tree

10 files changed

+171
-36
lines changed

10 files changed

+171
-36
lines changed
File renamed without changes.
File renamed without changes.

assets/vocab/puzzle15_vocab.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"1": "0 ",
3+
"2": "1 ",
4+
"3": "2 ",
5+
"4": "3 ",
6+
"5": "4 ",
7+
"6": "5 ",
8+
"7": "6 ",
9+
"8": "7 ",
10+
"9": "8 ",
11+
"10": "9 ",
12+
"11": "10 ",
13+
"12": "11 ",
14+
"13": "12 ",
15+
"14": "13 ",
16+
"15": "14 ",
17+
"16": "15 ",
18+
"17": "(0, 0) ",
19+
"18": "(0, 1) ",
20+
"19": "(0, 2) ",
21+
"20": "(0, 3) ",
22+
"21": "(1, 0) ",
23+
"22": "(1, 1) ",
24+
"23": "(1, 2) ",
25+
"24": "(1, 3) ",
26+
"25": "(2, 0) ",
27+
"26": "(2, 1) ",
28+
"27": "(2, 2) ",
29+
"28": "(2, 3) ",
30+
"29": "(3, 0) ",
31+
"30": "(3, 1) ",
32+
"31": "(3, 2) ",
33+
"32": "(3, 3) ",
34+
"33": "### Step 1: Move 1 to (0, 0)\n",
35+
"34": "### Step 2: Move 2 to (0, 1)\n",
36+
"35": "### Step 3: Move 4 to (0, 2)\n",
37+
"36": "### Step 4: Move 3 to (1, 2)\n",
38+
"37": "### Step 5: Place 3 and 4 in correct position\n",
39+
"38": "### Step 6: Move 5 to (1, 0)\n",
40+
"39": "### Step 7: Move 6 to (1, 1)\n",
41+
"40": "### Step 8: Move 8 to (1, 2)\n",
42+
"41": "### Step 9: Move 7 to (2, 2)\n",
43+
"42": "### Step 10: Place 7 and 8 in correct position\n",
44+
"43": "### Step 11: Move 13 to (2, 0)\n",
45+
"44": "### Step 12: Move 9 to (2, 1)\n",
46+
"45": "### Step 13: Place 9 and 13 in correct position\n",
47+
"46": "### Step 14: Move 14 to (2, 1)\n",
48+
"47": "### Step 15: Move 10 to (2, 2)\n",
49+
"48": "### Step 16: Place 10 and 14 in correct position\n",
50+
"49": "### Step 17: finetune 11, 12, 15\n",
51+
"50": "UP ",
52+
"51": "DOWN ",
53+
"52": "LEFT ",
54+
"53": "RIGHT ",
55+
"54": "<board>\n",
56+
"55": "</board>\n",
57+
"56": "<input>\n",
58+
"57": "</input>\n",
59+
"58": "<output>\n",
60+
"59": "</output>\n",
61+
"60": "<reasoning>\n",
62+
"61": "</reasoning>\n",
63+
"62": "=> Check position: ",
64+
"63": "=> Move blank to ",
65+
"64": "> Move ",
66+
"65": "\n\n",
67+
"66": "[Number is not in place]\n",
68+
"67": "[Number is in place, skip]\n",
69+
"68": "=> Planned path: ",
70+
"69": "# Adjust number position\n",
71+
"70": "Path taken so far: ",
72+
"71": "=> Check for special case\n",
73+
"72": "[Special case (A)]\n",
74+
"73": "[Special case (B)]\n",
75+
"74": "=> Use formula A: ",
76+
"75": "=> Use formula B: ",
77+
"76": "=> Place 3 and 4 in correct position\n",
78+
"77": "=> Place 7 and 8 in correct position\n",
79+
"78": "=> Place 9 and 13 in correct position\n",
80+
"79": "=> Place 10 and 14 in correct position\n",
81+
"80": "[Finetune complete]\n",
82+
"81": "[Not special case]\n",
83+
"82": "\n"
84+
}

assets/vocab/puzzle15_vocab.txt

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
1 '0 ' 3
2+
2 '1 ' 3
3+
3 '2 ' 3
4+
4 '3 ' 3
5+
5 '4 ' 3
6+
6 '5 ' 3
7+
7 '6 ' 3
8+
8 '7 ' 3
9+
9 '8 ' 3
10+
10 '9 ' 3
11+
11 '10 ' 3
12+
12 '11 ' 3
13+
13 '12 ' 3
14+
14 '13 ' 3
15+
15 '14 ' 3
16+
16 '15 ' 3
17+
17 '(0, 0) ' 7
18+
18 '(0, 1) ' 7
19+
19 '(0, 2) ' 7
20+
20 '(0, 3) ' 7
21+
21 '(1, 0) ' 7
22+
22 '(1, 1) ' 7
23+
23 '(1, 2) ' 7
24+
24 '(1, 3) ' 7
25+
25 '(2, 0) ' 7
26+
26 '(2, 1) ' 7
27+
27 '(2, 2) ' 7
28+
28 '(2, 3) ' 7
29+
29 '(3, 0) ' 7
30+
30 '(3, 1) ' 7
31+
31 '(3, 2) ' 7
32+
32 '(3, 3) ' 7
33+
33 '### Step 1: Move 1 to (0, 0)\n' 29
34+
34 '### Step 2: Move 2 to (0, 1)\n' 29
35+
35 '### Step 3: Move 4 to (0, 2)\n' 29
36+
36 '### Step 4: Move 3 to (1, 2)\n' 29
37+
37 '### Step 5: Place 3 and 4 in correct position\n' 46
38+
38 '### Step 6: Move 5 to (1, 0)\n' 29
39+
39 '### Step 7: Move 6 to (1, 1)\n' 29
40+
40 '### Step 8: Move 8 to (1, 2)\n' 29
41+
41 '### Step 9: Move 7 to (2, 2)\n' 29
42+
42 '### Step 10: Place 7 and 8 in correct position\n' 47
43+
43 '### Step 11: Move 13 to (2, 0)\n' 31
44+
44 '### Step 12: Move 9 to (2, 1)\n' 30
45+
45 '### Step 13: Place 9 and 13 in correct position\n' 48
46+
46 '### Step 14: Move 14 to (2, 1)\n' 31
47+
47 '### Step 15: Move 10 to (2, 2)\n' 31
48+
48 '### Step 16: Place 10 and 14 in correct position\n' 49
49+
49 '### Step 17: finetune 11, 12, 15\n' 33
50+
50 'UP ' 3
51+
51 'DOWN ' 5
52+
52 'LEFT ' 5
53+
53 'RIGHT ' 6
54+
54 '<board>\n' 8
55+
55 '</board>\n' 9
56+
56 '<input>\n' 8
57+
57 '</input>\n' 9
58+
58 '<output>\n' 9
59+
59 '</output>\n' 10
60+
60 '<reasoning>\n' 12
61+
61 '</reasoning>\n' 13
62+
62 '=> Check position: ' 19
63+
63 '=> Move blank to ' 17
64+
64 '> Move ' 7
65+
65 '\n\n' 2
66+
66 '[Number is not in place]\n' 25
67+
67 '[Number is in place, skip]\n' 27
68+
68 '=> Planned path: ' 17
69+
69 '# Adjust number position\n' 25
70+
70 'Path taken so far: ' 19
71+
71 '=> Check for special case\n' 26
72+
72 '[Special case (A)]\n' 19
73+
73 '[Special case (B)]\n' 19
74+
74 '=> Use formula A: ' 18
75+
75 '=> Use formula B: ' 18
76+
76 '=> Place 3 and 4 in correct position\n' 37
77+
77 '=> Place 7 and 8 in correct position\n' 37
78+
78 '=> Place 9 and 13 in correct position\n' 38
79+
79 '=> Place 10 and 14 in correct position\n' 39
80+
80 '[Finetune complete]\n' 20
81+
81 '[Not special case]\n' 19
82+
82 '\n' 1
File renamed without changes.
File renamed without changes.

examples/batch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async fn create_context(info: &ModelInfo, _auto: bool) -> Result<Context> {
7979
}
8080

8181
async fn load_tokenizer() -> Result<Tokenizer> {
82-
let file = File::open("assets/rwkv_vocab_v20230424.json").await?;
82+
let file = File::open("assets/vocab/rwkv_vocab_v20230424.json").await?;
8383
let mut reader = BufReader::new(file);
8484
let mut contents = String::new();
8585
reader.read_to_string(&mut contents).await?;

examples/chat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async fn create_context(info: &ModelInfo, _auto: bool) -> Result<Context> {
6060
}
6161

6262
async fn load_tokenizer() -> Result<Tokenizer> {
63-
let file = File::open("assets/rwkv_vocab_v20230424.json").await?;
63+
let file = File::open("assets/vocab/rwkv_vocab_v20230424.json").await?;
6464
let mut reader = BufReader::new(file);
6565
let mut contents = String::new();
6666
reader.read_to_string(&mut contents).await?;

examples/gen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async fn create_context(info: &ModelInfo, _auto: bool) -> Result<Context> {
7171
}
7272

7373
async fn load_tokenizer() -> Result<Tokenizer> {
74-
let file = File::open("assets/rwkv_vocab_v20230424.json").await?;
74+
let file = File::open("assets/vocab/rwkv_vocab_v20230424.json").await?;
7575
let mut reader = BufReader::new(file);
7676
let mut contents = String::new();
7777
reader.read_to_string(&mut contents).await?;

examples/serialization.rs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ use itertools::Itertools;
88
use memmap2::Mmap;
99
use safetensors::SafeTensors;
1010
use serde::{de::DeserializeSeed, Serialize};
11-
use std::{
12-
io::Write,
13-
path::PathBuf,
14-
time::{Duration, Instant},
15-
};
11+
use std::{io::Write, path::PathBuf};
1612
use tokio::{
1713
fs::File,
1814
io::{AsyncReadExt, BufReader},
@@ -76,7 +72,7 @@ async fn create_context(info: &ModelInfo, _auto: bool) -> Result<Context> {
7672
}
7773

7874
async fn load_tokenizer() -> Result<Tokenizer> {
79-
let file = File::open("assets/rwkv_vocab_v20230424.json").await?;
75+
let file = File::open("assets/vocab/rwkv_vocab_v20230424.json").await?;
8076
let mut reader = BufReader::new(file);
8177
let mut contents = String::new();
8278
reader.read_to_string(&mut contents).await?;
@@ -208,17 +204,12 @@ async fn main() -> Result<()> {
208204

209205
const PROMPT: &str = include_str!("prompt.md");
210206
let tokens = tokenizer.encode(PROMPT.as_bytes())?;
211-
let prompt_len = tokens.len();
212207
let prompt = InferInputBatch {
213208
tokens,
214209
option: InferOption::Last,
215210
};
216211
let mut prompt = InferInput::new(vec![prompt], cli.token_chunk_size);
217212

218-
let mut read = false;
219-
let mut instant = Instant::now();
220-
let mut prefill = Duration::ZERO;
221-
222213
let num_token = 500;
223214
for _ in 0..num_token {
224215
let input = prompt.clone();
@@ -227,13 +218,6 @@ async fn main() -> Result<()> {
227218

228219
let output = output[0].0.clone();
229220
if output.size() > 0 {
230-
if !read {
231-
print!("\n{}", PROMPT);
232-
prefill = instant.elapsed();
233-
instant = Instant::now();
234-
read = true;
235-
}
236-
237221
let output = softmax_one(&context, output).await?;
238222
let output = output.to_vec();
239223
let token = sample(&output, 0.0);
@@ -248,21 +232,6 @@ async fn main() -> Result<()> {
248232
std::io::stdout().flush().unwrap();
249233
}
250234
}
251-
print!("\n\n");
252-
253-
let duration = instant.elapsed();
254-
log::info!(
255-
"Prefill:\t{} tokens,\t{} mills,\t{} tps",
256-
prompt_len,
257-
prefill.as_millis(),
258-
prompt_len as f64 / prefill.as_secs_f64()
259-
);
260-
log::info!(
261-
"Generation:\t{} tokens,\t{} mills,\t{} tps",
262-
num_token,
263-
duration.as_millis(),
264-
num_token as f64 / duration.as_secs_f64()
265-
);
266235

267236
Ok(())
268237
}

0 commit comments

Comments
 (0)