File size: 14,567 Bytes
2948983
 
 
 
f6e614c
2948983
f6e614c
2948983
 
f6e614c
 
 
 
 
2948983
 
f6e614c
 
e2729fe
f6e614c
e2729fe
 
 
 
 
 
 
 
 
 
 
f6e614c
 
2948983
e2729fe
f770448
e2729fe
f770448
e2729fe
 
 
f770448
e2729fe
 
 
f770448
e2729fe
f770448
e2729fe
 
 
 
 
 
 
f770448
e2729fe
2948983
e2729fe
2948983
e2729fe
2948983
e2729fe
2948983
e2729fe
 
 
 
 
 
2948983
f6e614c
e2729fe
 
 
 
f6e614c
 
e2729fe
f6e614c
e2729fe
 
 
 
 
f6e614c
 
e2729fe
 
f6e614c
e2729fe
f6e614c
e2729fe
 
f6e614c
2948983
e2729fe
 
 
 
 
2948983
e2729fe
2948983
e2729fe
f6e614c
 
e2729fe
 
 
 
 
f6e614c
2948983
e2729fe
2948983
e2729fe
 
 
 
f6e614c
e2729fe
f6e614c
e2729fe
2948983
e2729fe
f6e614c
e2729fe
f6e614c
e2729fe
f6e614c
e2729fe
 
 
 
f6e614c
 
e2729fe
33080a1
e2729fe
 
 
 
 
33080a1
e2729fe
33080a1
e2729fe
 
 
 
 
 
 
 
 
 
 
 
33080a1
 
e2729fe
f6e614c
e2729fe
 
 
 
 
f6e614c
e2729fe
2948983
e2729fe
 
 
 
 
f6e614c
e2729fe
f6e614c
e2729fe
f6e614c
e2729fe
f6e614c
e2729fe
f6e614c
e2729fe
 
 
 
 
f6e614c
e2729fe
4a3cd2f
e2729fe
4a3cd2f
e2729fe
4a3cd2f
e2729fe
 
 
 
 
4a3cd2f
e2729fe
4a3cd2f
e2729fe
0194e59
e2729fe
 
 
 
 
 
 
 
 
 
0194e59
e2729fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0194e59
e2729fe
f6e614c
e2729fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f6e614c
e2729fe
bf8ae1c
e2729fe
 
 
 
 
 
 
 
 
bf8ae1c
e2729fe
50549ab
e2729fe
 
 
 
50549ab
e2729fe
50549ab
e2729fe
5aff889
e2729fe
 
 
 
 
 
5aff889
e2729fe
5aff889
e2729fe
5aff889
e2729fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6ab8274
e2729fe
 
 
 
 
6ab8274
e2729fe
0dcf39e
e2729fe
0dcf39e
e2729fe
 
 
0dcf39e
e2729fe
0dcf39e
e2729fe
 
 
 
0dcf39e
e2729fe
 
 
 
 
 
 
f6e614c
e2729fe
f6e614c
e2729fe
 
 
2948983
 
e2729fe
f6e614c
e2729fe
5094348
e2729fe
5094348
e2729fe
 
 
 
5094348
e2729fe
5094348
e2729fe
 
 
 
 
 
 
 
 
 
5094348
e2729fe
 
 
 
 
5094348
 
e2729fe
5094348
e2729fe
c4c9192
e2729fe
 
 
 
 
 
 
 
 
 
 
 
c4c9192
 
e2729fe
c4c9192
 
e2729fe
c4c9192
e2729fe
c4c9192
e2729fe
bb698e6
e2729fe
bb698e6
e2729fe
 
 
 
 
bb698e6
e2729fe
2dde02d
e2729fe
 
 
 
 
 
2dde02d
e2729fe
2dde02d
e2729fe
58b3b50
e2729fe
 
 
 
 
58b3b50
e2729fe
a16cd95
e2729fe
c228b1d
e2729fe
5ee3a5e
e2729fe
 
 
 
 
58b3b50
e2729fe
f6e614c
e2729fe
 
 
f6e614c
e2729fe
f6e614c
e2729fe
f6e614c
e2729fe
f6e614c
e2729fe
 
 
 
 
f6e614c
e2729fe
f6e614c
e2729fe
 
 
 
 
2948983
f6e614c
2948983
e2729fe
 
 
 
 
 
 
 
 
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
---
language:
  - ko
  - en
library_name: pytorch
license: other
pipeline_tag: feature-extraction
tags:
  - online-handwriting
  - mathematical-expression-recognition
  - trajectory
  - temporal-convolution
  - on-device
  - pytorch
---

# AIFlow Math Ink 0.6

AIFlow Math Ink 0.6์€ ์ˆ˜ํ•™ ํ•„๊ธฐ๋ฅผ **์ด๋ฏธ์ง€๋ณด๋‹ค stroke trajectory๋กœ ๋จผ์ € ํ•ด์„ํ•˜๋Š”** PyTorch ์—ฐ๊ตฌ ๋ชจ๋ธ์ด๋‹ค.

์˜จ๋ผ์ธ ํŽœ ์ž…๋ ฅ์„ ์‹œ๊ฐ„ ์ˆœ์„œ๊ฐ€ ์žˆ๋Š” point sequence๋กœ ํ‘œํ˜„ํ•˜๊ณ , ๊ฐ ๊ณ ๋ฆฝ ๊ธฐํ˜ธ์— ๋Œ€ํ•ด ๋‹ค์Œ ๋‘ ์ข…๋ฅ˜์˜ ํ™•๋ฅ ์„ ์˜ˆ์ธกํ•œ๋‹ค.

- 378๊ฐœ exact symbol label
- 324๊ฐœ visual family

ํ•ต์‹ฌ ์—ฐ๊ตฌ ์ฃผ์ œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

1. ์„œ๋กœ ๋‹ค๋ฅธ ํ•„๊ธฐ ์†๋„๋ฅผ ์ผ์ •ํ•œ temporal representation์œผ๋กœ ์ •๊ทœํ™”ํ•˜๋Š” ๋ฐฉ๋ฒ•
2. ์˜จ๋ผ์ธ stroke์™€ raster ์ด๋ฏธ์ง€๋ฅผ ํ•˜๋‚˜์˜ trajectory encoder๋กœ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•
3. ์‹œ๊ฐ์ ์œผ๋กœ ์œ ์‚ฌํ•œ ๊ธฐํ˜ธ์˜ ํ˜•ํƒœ์™€ ์˜๋ฏธ๋ฅผ ๋ถ„๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•
4. ๊ธฐํ˜ธ ๋ถ„๋ฅ˜์™€ ์ˆ˜์‹ ๋ฌธ๋งฅ์„ ๊ฒฐํ•ฉํ•˜๋Š” ๋ฐฉ๋ฒ•

![AIFlow Math Ink 0.6 architecture](assets/architecture.svg)

## ์—ฐ๊ตฌ ์•„์ด๋””์–ด

### 1. Trajectory-first representation

์ผ๋ฐ˜์ ์ธ ์ด๋ฏธ์ง€ ๋ถ„๋ฅ˜ ๋ฐฉ์‹์€ ํ•„๊ธฐ๋ฅผ ๊ณ ์ •๋œ bitmap์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋ฉด์„œ stroke ์ˆœ์„œ์™€ ์‹œ๊ฐ„ ์ •๋ณด๋ฅผ ์ œ๊ฑฐํ•œ๋‹ค.

AIFlow Math Ink๋Š” ํ•„๊ธฐ๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์‹œ๊ณ„์—ด๋กœ ํ‘œํ˜„ํ•œ๋‹ค.

```text
pointโ‚ โ†’ pointโ‚‚ โ†’ pointโ‚ƒ โ†’ ... โ†’ pen-up
```

๊ฐ point์—๋Š” ์œ„์น˜๋ฟ ์•„๋‹ˆ๋ผ ๋‹ค์Œ ์ •๋ณด๊ฐ€ ํฌํ•จ๋œ๋‹ค.

- ์ด๋™ ๋ฐฉํ–ฅ
- ๊ณก๋ฅ 
- ํ•„๊ธฐ ์†๋„
- stroke ๋‚ด๋ถ€ ์ง„ํ–‰๋ฅ 
- pen-up ์ƒํƒœ
- ์ „์ฒด ๊ธฐํ˜ธ ์•ˆ์—์„œ์˜ ์ƒ๋Œ€ ์œ„์น˜
- timestamp ๊ด€์ธก ์—ฌ๋ถ€

์ด ํ‘œํ˜„์€ ๊ฐ™์€ ๋ชจ์–‘์ด๋ผ๋„ stroke ์ˆœ์„œ์™€ ์›€์ง์ž„์ด ๋‹ค๋ฅธ ํ•„๊ธฐ๋ฅผ ๊ตฌ๋ถ„ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•œ๋‹ค.

### 2. Canonical temporal sampling

์‚ฌ๋žŒ๋งˆ๋‹ค ํ•„๊ธฐ ์†๋„์™€ touch event ๋ฐœ์ƒ ๋นˆ๋„๊ฐ€ ๋‹ค๋ฅด๊ธฐ ๋•Œ๋ฌธ์— ์›๋ณธ event ๊ฐœ์ˆ˜๋Š” ์ผ์ •ํ•˜์ง€ ์•Š๋‹ค.

๋ชจ๋ธ์€ ๊ฐ stroke๋ฅผ 6Hz canonical timeline์œผ๋กœ ์žฌํ‘œ๋ณธํ™”ํ•œ๋‹ค. ์ด๋•Œ ๋‹ค์Œ anchor๋Š” ํ•ญ์ƒ ๋ณด์กดํ•œ๋‹ค.

- stroke ์‹œ์ž‘์ 
- stroke ๋์ 
- pen-up
- ์›๋ณธ timestamp

์ด๋ฅผ ํ†ตํ•ด ๋น ๋ฅด๊ฒŒ ์“ด ๊ธฐํ˜ธ์™€ ๋А๋ฆฌ๊ฒŒ ์“ด ๊ธฐํ˜ธ๋ฅผ ๋น„์Šทํ•œ temporal scale์—์„œ ๋น„๊ตํ•  ์ˆ˜ ์žˆ๋‹ค.

```text
Raw touch events
  โ†’ stroke anchor preservation
  โ†’ 6 Hz canonical sampling
  โ†’ maximum 128 events
```

์›๋ณธ touch event๋Š” ๊ทธ๋Œ€๋กœ ์œ ์ง€ํ•˜๊ณ , ์žฌํ‘œ๋ณธํ™”๋œ sequence๋Š” ๋ชจ๋ธ ์ž…๋ ฅ์šฉ view๋กœ ์‚ฌ์šฉํ•œ๋‹ค.

### 3. Shape coordinate์™€ canvas coordinate์˜ ๋ถ„๋ฆฌ

๊ธฐํ˜ธ์˜ ๋ชจ์–‘๊ณผ ์ˆ˜์‹ ์•ˆ์—์„œ์˜ ์œ„์น˜๋Š” ์„œ๋กœ ๋‹ค๋ฅธ ์ •๋ณด๋ฅผ ๊ฐ€์ง„๋‹ค.

AIFlow Math Ink๋Š” ๋‘ ์ขŒํ‘œ๊ณ„๋ฅผ ๋™์‹œ์— ์‚ฌ์šฉํ•œ๋‹ค.

```text
shape_x, shape_y
```

๊ธฐํ˜ธ ์ž์ฒด์˜ bounding box๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์ •๊ทœํ™”ํ•œ ์ขŒํ‘œ๋‹ค. ๊ธ€์ž์˜ ํฌ๊ธฐ์™€ ์œ„์น˜ ์˜ํ–ฅ์„ ์ค„์ด๊ณ  ์ˆœ์ˆ˜ํ•œ ํ˜•ํƒœ๋ฅผ ํ‘œํ˜„ํ•œ๋‹ค.

```text
canvas_x, canvas_y
```

์ „์ฒด canvas ๋˜๋Š” ์ˆ˜์‹ ์˜์—ญ์„ ๊ธฐ์ค€์œผ๋กœ ํ•œ ์ขŒํ‘œ๋‹ค. ๊ธฐํ˜ธ์˜ ์ƒ๋Œ€ ํฌ๊ธฐ์™€ ์ˆ˜์ง ์œ„์น˜๋ฅผ ๋ณด์กดํ•œ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด ์†Œ๋ฌธ์ž `x`, ๋Œ€๋ฌธ์ž `X`, ๊ณฑ์…ˆ ๊ธฐํ˜ธ `ร—`๋Š” ๋ชจ์–‘์ด ๋น„์Šทํ•˜์ง€๋งŒ ์ˆ˜์‹ ์•ˆ์—์„œ์˜ ํฌ๊ธฐ์™€ ์œ„์น˜ ๋ถ„ํฌ๊ฐ€ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ๋‹ค. ๋‘ ์ขŒํ‘œ๊ณ„๋ฅผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋ฉด ํ˜•ํƒœ์™€ ๋ฌธ๋งฅ์„ ๋ถ„๋ฆฌํ•ด ํ•™์Šตํ•  ์ˆ˜ ์žˆ๋‹ค.

### 4. Online๊ณผ raster์˜ ๊ณตํ†ต trajectory space

์˜จ๋ผ์ธ ์ž…๋ ฅ์—๋Š” stroke sequence๊ฐ€ ์ง์ ‘ ์กด์žฌํ•˜์ง€๋งŒ, raster ์ด๋ฏธ์ง€์—๋Š” stroke ์ˆœ์„œ๊ฐ€ ์—†๋‹ค.

Raster ๊ฒฝ๋กœ๋Š” ์ด๋ฏธ์ง€๋ฅผ ๊ณง๋ฐ”๋กœ symbol label๋กœ ๋ถ„๋ฅ˜ํ•˜๋Š” ๋Œ€์‹ , ์ด๋ฏธ์ง€์—์„œ ์—ฌ๋Ÿฌ ๊ฐœ์˜ virtual trajectory๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

```text
Raster image
  โ†’ spatial encoder
  โ†’ virtual-trajectory decoder
  โ†’ top-4 stroke hypotheses
  โ†’ shared trajectory encoder
```

๊ฐ hypothesis๋Š” ๋‹ค์Œ ์ •๋ณด๋ฅผ ํฌํ•จํ•œ๋‹ค.

- virtual stroke coordinates
- stroke state
- progress
- hypothesis score

์ดํ›„ ์˜จ๋ผ์ธ ์ž…๋ ฅ๊ณผ ๋™์ผํ•œ residual TCN์ด virtual trajectory๋ฅผ ์ฒ˜๋ฆฌํ•œ๋‹ค.

์ด ๊ตฌ์กฐ์˜ ๋ชฉ์ ์€ ์ž…๋ ฅ modality๊ฐ€ ๋‹ฌ๋ผ๋„ ์ตœ์ข… ์ธ์‹์€ ๋™์ผํ•œ trajectory representation ์œ„์—์„œ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

### 5. Exact label๊ณผ visual family์˜ ๊ณ„์ธต์  ์˜ˆ์ธก

์ˆ˜ํ•™ ๊ธฐํ˜ธ์—๋Š” ํ˜•ํƒœ๊ฐ€ ๊ฑฐ์˜ ๋™์ผํ•˜์ง€๋งŒ ์˜๋ฏธ๊ฐ€ ๋‹ค๋ฅธ ๊ฒฝ์šฐ๊ฐ€ ๋งŽ๋‹ค.

์˜ˆ:

```text
O / 0 / o
x / X / ร—
| / 1 / l
```

๋ชจ๋ธ์€ ์ด๋ฅผ ํ•˜๋‚˜์˜ ๋ถ„๋ฅ˜ ๋ฌธ์ œ๋กœ๋งŒ ๋‹ค๋ฃจ์ง€ ์•Š๊ณ  ๋‘ ๊ฐœ์˜ prediction head๋กœ ๋‚˜๋ˆˆ๋‹ค.

```text
Shared trajectory representation
  โ”œโ”€ exact head: 378 labels
  โ””โ”€ family head: 324 visual families
```

Exact head๋Š” ์ตœ์ข… symbol token์„ ์˜ˆ์ธกํ•œ๋‹ค.

Family head๋Š” ์‹œ๊ฐ์ ์œผ๋กœ ๊ฐ€๊นŒ์šด ๊ธฐํ˜ธ ์ง‘ํ•ฉ์„ ์˜ˆ์ธกํ•œ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด trajectory encoder๊ฐ€ ํ˜•ํƒœ๋ฅผ ๋จผ์ € ์•ˆ์ •์ ์œผ๋กœ ๊ตฌ๋ถ„ํ•˜๊ณ , ์ •ํ™•ํ•œ ์˜๋ฏธ ์„ ํƒ์€ ๋ณ„๋„์˜ ๋ฌธ๋งฅ ์ •๋ณด์™€ ๊ฒฐํ•ฉํ•  ์ˆ˜ ์žˆ๋‹ค.

### 6. Formula-context behavior modeling

๊ณ ๋ฆฝ ๊ธฐํ˜ธ์˜ trajectory๋งŒ์œผ๋กœ ๊ตฌ๋ถ„ํ•˜๊ธฐ ์–ด๋ ค์šด ๊ธฐํ˜ธ์—๋Š” ์ˆ˜์‹ ๋ฌธ๋งฅ์„ ์ถ”๊ฐ€ํ•œ๋‹ค.

Behavior head๋Š” ๋‹ค์Œ ๋‘ ํ‘œํ˜„์„ ๊ฒฐํ•ฉํ•œ๋‹ค.

```text
128ร—19 stroke representation
+
49-dimensional formula context
```

Context feature์—๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ •๋ณด๊ฐ€ ํฌํ•จ๋œ๋‹ค.

- ์ˆ˜์‹ ์ „์ฒด ํฌ๊ธฐ ๋Œ€๋น„ ๊ธฐํ˜ธ ํฌ๊ธฐ
- baseline๊ณผ์˜ ์ƒ๋Œ€ ์œ„์น˜
- ์ฃผ๋ณ€ ๊ธฐํ˜ธ์˜ ์œ„์น˜์™€ ๊ฐ„๊ฒฉ
- symbol group geometry
- ์ด์›ƒ token ํŒจํ„ด

ํ˜„์žฌ behavior head์˜ ๋Œ€ํ‘œ ์—ญํ•  ๋ถ„๋ฅ˜๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

```text
identifier_lower
identifier_upper
multiply_operator
```

์˜ˆ๋ฅผ ๋“ค์–ด `x`, `X`, `ร—`์˜ trajectory๊ฐ€ ๋น„์Šทํ•  ๋•Œ, ๊ธฐํ˜ธ์˜ ์ƒ๋Œ€ ํฌ๊ธฐ์™€ ์ฃผ๋ณ€ token์„ ์ด์šฉํ•ด ์—ญํ• ์„ ์„ ํƒํ•œ๋‹ค.

### 7. Boundary behavior modeling

์ˆ˜์‹ ์ธ์‹์—์„œ๋Š” ์—ฌ๋Ÿฌ stroke๋ฅผ ํ•˜๋‚˜์˜ ๊ธฐํ˜ธ๋กœ ๋ฌถ๋Š” grouping ๊ณผ์ •์ด ํ•„์š”ํ•˜๋‹ค.

Boundary behavior head๋Š” segmentation candidate๊ฐ€ ์‹ค์ œ ๊ธฐํ˜ธ ๊ฒฝ๊ณ„๋ฅผ ๊ฐ€๋กœ์ง€๋ฅด๋Š”์ง€๋ฅผ geometry feature๋กœ ์˜ˆ์ธกํ•œ๋‹ค.

```text
Segmentation lattice geometry
  โ†’ 17-dimensional boundary features
  โ†’ boundary behavior score
```

์ด score๋Š” ๊ฐ€๊นŒ์ด ์žˆ๋Š” ๋‘ ๊ธฐํ˜ธ๊ฐ€ ํ•˜๋‚˜์˜ symbol group์œผ๋กœ ํ•ฉ์ณ์ง€๋Š” overmerge๋ฅผ ์–ต์ œํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋œ๋‹ค.

## ์ž…๋ ฅ ํ‘œํ˜„

๋ชจ๋ธ ์ž…๋ ฅ์€ ์ตœ๋Œ€ 128๊ฐœ์˜ event์™€ 19๊ฐœ์˜ feature๋กœ ๊ตฌ์„ฑ๋œ๋‹ค.

```text
input shape: 128 ร— 19
sample rate: 6 Hz
normalized ink space: 128 ร— 128
```

![Stroke encoding](assets/stroke_encoding.svg)

### 19 input channels

```text
shape_x, shape_y,
canvas_x, canvas_y,
direction_x, direction_y,
curvature, pen_up, stroke_progress,
aspect_ratio,
bbox_top, bbox_bottom, bbox_height, center_y,
baseline_available,
time_delta, speed, missing_mask, source_modality
```

| Feature group | ์—ญํ•  |
|---|---|
| `shape_x`, `shape_y` | ๊ธฐํ˜ธ ๋‚ด๋ถ€์˜ ์ •๊ทœํ™”๋œ ํ˜•ํƒœ |
| `canvas_x`, `canvas_y` | ์ „์ฒด canvas ์•ˆ์—์„œ์˜ ์ƒ๋Œ€ ์œ„์น˜ |
| `direction_x`, `direction_y` | point ์ด๋™ ๋ฐฉํ–ฅ |
| `curvature` | stroke์˜ ๊ตญ์†Œ ๊ณก๋ฅ  |
| `pen_up` | stroke ๊ฒฝ๊ณ„ |
| `stroke_progress` | stroke ์‹œ์ž‘๋ถ€ํ„ฐ ๋๊นŒ์ง€์˜ ์ง„ํ–‰๋„ |
| `aspect_ratio` | ๊ธฐํ˜ธ bounding box ๋น„์œจ |
| `bbox_*`, `center_y` | ์ˆ˜์‹ ์•ˆ์—์„œ์˜ geometry |
| `baseline_available` | baseline feature์˜ ์œ ํšจ์„ฑ |
| `time_delta`, `speed` | temporal dynamics |
| `missing_mask` | ๊ด€์ธก๋˜์ง€ ์•Š์€ ์‹œ๊ฐ„ ์ •๋ณด ํ‘œ์‹œ |
| `source_modality` | online ๋˜๋Š” raster ์ž…๋ ฅ ๊ตฌ๋ถ„ |

Timestamp๊ฐ€ ์กด์žฌํ•˜๋Š” ์ž…๋ ฅ์€ ๊ด€์ธก๋œ ์‹œ๊ฐ„ ์ฐจ์ด์™€ ์†๋„๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. ์ •์  ์ด๋ฏธ์ง€์—์„œ ์ƒ์„ฑ๋œ virtual trajectory๋Š” canonical timing๊ณผ missingness ์ •๋ณด๋ฅผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•œ๋‹ค.

## ๋ชจ๋ธ ๊ตฌ์กฐ

```text
Online strokes
  โ†’ canonical sampler
  โ†’ 128ร—19 sequence
  โ†’ dual-TCN online adapter
  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                               โ”‚
Raster 128ร—128                                 โ”‚
  โ†’ spatial encoder                            โ”‚
  โ†’ causal virtual-trajectory decoder          โ”‚
  โ†’ top-4 trajectory hypotheses                โ”‚
  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
                                               โ–ผ
                                shared residual TCN
                                     โ”œโ”€ exact head
                                     โ””โ”€ visual-family head
```

์ฃผ์š” ์„ค์ •:

| ํ•ญ๋ชฉ | ๊ฐ’ |
|---|---:|
| Maximum events | 128 |
| Input features | 19 |
| Shared hidden size | 128 |
| Exact labels | 378 |
| Visual families | 324 |
| Raster hypotheses | 4 |
| Canonical sample rate | 6Hz |

### Dual-TCN online adapter

์˜จ๋ผ์ธ ์ž…๋ ฅ์€ ๋‘ ์ข…๋ฅ˜์˜ temporal pattern์„ ํ•จ๊ป˜ ์ฒ˜๋ฆฌํ•œ๋‹ค.

- ๊ธฐํ˜ธ ์ „์ฒด์˜ ๊ธด stroke ํ๋ฆ„
- point ์‚ฌ์ด์˜ ์งง์€ ๊ตญ์†Œ ๋ณ€ํ™”

Dual-TCN adapter๋Š” ์„œ๋กœ ๋‹ค๋ฅธ receptive field๋ฅผ ๊ฐ€์ง„ temporal convolution์„ ๊ฒฐํ•ฉํ•ด ์ด ๋‘ ํŒจํ„ด์„ ํ‘œํ˜„ํ•œ๋‹ค.

Adapter์˜ shared state๋Š” base trajectory encoder์™€ ํ•จ๊ป˜ ํ•ฉ์„ฑ๋œ๋‹ค.

```text
base trajectory state
  โ†’ online shared state
  โ†’ modality-specific adaptation
  โ†’ classifier heads
```

## Checkpoints

๊ฐ seed๋Š” ๋‹ค์Œ ์„ธ ํŒŒ์ผ๋กœ ๊ตฌ์„ฑ๋œ๋‹ค.

```text
models/
  seed17/
    base_378.pt
    online_adapter.pt
    behavior_role_head.pt
  seed31/
    base_378.pt
    online_adapter.pt
    behavior_role_head.pt
  seed47/
    base_378.pt
    online_adapter.pt
    behavior_role_head.pt
```

| ํŒŒ์ผ | ๋‚ด์šฉ |
|---|---|
| `base_378.pt` | ๊ณตํ†ต trajectory encoder, raster encoder, exact/family classifier |
| `online_adapter.pt` | ์‹ค์ œ online stroke์— ๋Œ€ํ•œ dual-TCN adaptation |
| `behavior_role_head.pt` | ๊ธฐํ˜ธ์˜ ์ˆ˜์‹ ๋‚ด ์—ญํ• ์„ ๋ถ„๋ฅ˜ํ•˜๋Š” context head |

์„ธ seed๋Š” ์„œ๋กœ ๋‹ค๋ฅธ ์ดˆ๊ธฐํ™”์—์„œ ํ•™์Šต๋˜์–ด ๋ชจ๋ธ ๊ฐ„ ์˜ค๋ฅ˜ ํ•ฉ์˜์™€ ensemble ํŠน์„ฑ์„ ๋ถ„์„ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋œ๋‹ค.

## ์‚ฌ์šฉ ์˜ˆ์‹œ

```python
from pathlib import Path
from math_grid_drawer.research.math_ink_06 import MathInk06Engine

root = Path("models/seed17")

engine = MathInk06Engine(
    root / "base_378.pt",
    adapter_checkpoint=root / "online_adapter.pt",
)

result = engine.recognize_online(
    strokes,
    canvas_width=128,
    canvas_height=128,
    top_k=5,
)
```

์ถœ๋ ฅ์—๋Š” exact symbol ํ›„๋ณด์™€ ๊ฐ ํ›„๋ณด์˜ ํ™•๋ฅ ์ด ํฌํ•จ๋œ๋‹ค.

```python
for candidate in result.candidates:
    print(candidate.token, candidate.probability)
```

## ์—ฐ๊ตฌ ๊ฒฐ๊ณผ

### ๊ณ ๋ฆฝ ๊ธฐํ˜ธ trajectory classification

Seed 17์˜ writer-disjoint ํ‰๊ฐ€ ๊ฒฐ๊ณผ:

| Split | Exact top-1 | Exact top-5 | Family top-1 |
|---|---:|---:|---:|
| Writer validation, 4,261 samples | 86.13% | 99.48% | 92.94% |
| Paired test, 3,782 samples | 82.87% | 97.73% | 91.22% |

์„ธ seed์˜ ํ™•๋ฅ ์„ ํ‰๊ท ํ•œ ensemble ๊ฒฐ๊ณผ:

| Metric | Result |
|---|---:|
| Exact top-1 | 83.71% |
| Exact top-5 | 98.02% |
| Visual-family top-1 | 92.99% |
| Seed oracle top-1 | 88.05% |

Exact top-1๊ณผ family top-1์˜ ์ฐจ์ด๋Š” ์ „์ฒด์ ์ธ ํ˜•ํƒœ ์ธ์‹๋ณด๋‹ค ๋™์ผ family ๋‚ด๋ถ€์˜ ์˜๋ฏธ ์„ ํƒ์ด ๋” ์–ด๋ ค์šด ๋ฌธ์ œ์ž„์„ ๋ณด์—ฌ์ค€๋‹ค.

Exact ์˜ค๋ฅ˜์˜ 56.98%๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋™์ผ visual-family ๋‚ด๋ถ€ ํ˜ผ๋™์ด์—ˆ๋‹ค.

```text
O / 0 / o
uppercase / lowercase
vertical-line family
cross family
```

์ด ๊ฒฐ๊ณผ๋Š” trajectory encoder๊ฐ€ ํ˜•ํƒœ ํ›„๋ณด๋ฅผ ๋งŒ๋“ค๊ณ , formula context๊ฐ€ ์ตœ์ข… ์˜๋ฏธ๋ฅผ ์„ ํƒํ•˜๋Š” ๊ณ„์ธต์  ๊ตฌ์กฐ๋ฅผ ๋’ท๋ฐ›์นจํ•œ๋‹ค.

### Formula-context behavior head

์ •๋‹ต symbol grouping ์œ„์—์„œ ํ‰๊ฐ€ํ•œ 3-seed ํ‰๊ท :

| Metric | Result |
|---|---:|
| Role accuracy | 93.33% |
| Macro-F1 | 76.41% |
| Lowercase identifier recall | 95.66% |
| Uppercase identifier recall | 55.91% |
| Multiplication recall | 88.89% |
| Expected calibration error | 4.88% |

Behavior head๋ฅผ teacher prediction ๋’ค์— ์ ์šฉํ–ˆ์„ ๋•Œ ๋Œ€์ƒ ๊ธฐํ˜ธ์˜ exact top-1์€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ณ€ํ™”ํ–ˆ๋‹ค.

```text
33.65% โ†’ 47.30%
```

ํ‰๊ท  ์ƒ์Šน ํญ์€ `13.65%p`์˜€์œผ๋ฉฐ rewrite precision์€ `81.35%`์˜€๋‹ค.

์ด ์‹คํ—˜์€ trajectory๋งŒ์œผ๋กœ ์„ ํƒํ•˜๊ธฐ ์–ด๋ ค์šด exact meaning์„ ์ˆ˜์‹ ๋ฌธ๋งฅ์ด ๋ณด์™„ํ•  ์ˆ˜ ์žˆ์Œ์„ ๋ณด์—ฌ์ค€๋‹ค.

### Continuous-formula adaptation

Product trajectory encoder์™€ online adapter๋ฅผ ๊ณ ์ •ํ•˜๊ณ , ์—ฐ์† ์ˆ˜์‹์˜ symbol group์— ์ž‘์€ formula adapter๋ฅผ ์ถ”๊ฐ€ํ–ˆ๋‹ค.

```text
Frozen trajectory encoder
  + frozen online adapter
  + hidden-64 formula adapter
```

3-seed ํ‰๊ท  ๊ฒฐ๊ณผ:

| Metric | Mean |
|---|---:|
| Writer-validation exact top-1 | 85.19% |
| Writer-validation family top-1 | 93.30% |
| Official-test exact top-1 | 82.38% |
| Official-test family top-1 | 88.17% |

์ž‘์€ adapter๋งŒ์œผ๋กœ๋„ ๊ณ ๋ฆฝ ๊ธฐํ˜ธ encoder์˜ representation์„ ์—ฐ์† ์ˆ˜์‹ ํ™˜๊ฒฝ์— ๋งž๊ฒŒ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ์Œ์„ ํ™•์ธํ–ˆ๋‹ค.

### Grouping boundary head

| Metric | Base grouping | Boundary head |
|---|---:|---:|
| Exact partition | 60.04% | 60.25% |
| Pair-F1 | 91.07% | 91.26% |
| Overmerge formula rate | 21.72% | 20.49% |

Boundary head๋Š” ๊ธฐํ˜ธ ์‚ฌ์ด์˜ geometry๋ฅผ ์ด์šฉํ•ด ์ธ์ ‘ symbol์˜ ๊ณผ๋„ํ•œ ๋ณ‘ํ•ฉ์„ ์ค„์˜€๋‹ค.

### Family fusion

Validation์—์„œ exact probability์™€ family probability๋ฅผ ๊ฒฐํ•ฉํ•˜๋Š” fusion weight๋ฅผ ์„ ํƒํ–ˆ๋‹ค.

```text
exact score
+
0.15 ร— family-consistency score
```

Paired test exact top-1:

```text
83.71% โ†’ 83.82%
```

Family prediction์€ exact classifier์˜ ํ›„๋ณด ์ˆœ์„œ๋ฅผ ์ž‘์€ ๋ฒ”์œ„์—์„œ ๋ณด์ •ํ•˜๋Š” ์—ญํ• ์„ ํ•œ๋‹ค.

## ์—ฐ๊ตฌ ํ•ด์„

AIFlow Math Ink 0.6์˜ ์‹คํ—˜์€ ์ˆ˜ํ•™ ํ•„๊ธฐ ์ธ์‹์„ ๋‹ค์Œ ์„ธ ๋‹จ๊ณ„๋กœ ๋ถ„๋ฆฌํ•  ์ˆ˜ ์žˆ์Œ์„ ๋ณด์—ฌ์ค€๋‹ค.

```text
1. Stroke trajectory์—์„œ ์‹œ๊ฐ์  ํ˜•ํƒœ๋ฅผ ์ถ”์ถœ
2. Visual family ์•ˆ์—์„œ ๊ฐ€๋Šฅํ•œ symbol ํ›„๋ณด๋ฅผ ๊ตฌ์„ฑ
3. ์ˆ˜์‹ ๋ฌธ๋งฅ๊ณผ geometry๋กœ exact meaning์„ ์„ ํƒ
```

์ด ๊ตฌ์กฐ๋Š” ๊ณ ๋ฆฝ ๊ธฐํ˜ธ ์ธ์‹๊ณผ ์ „์ฒด ์ˆ˜์‹ ํ•ด์„์„ ํ•˜๋‚˜์˜ ๊ฑฐ๋Œ€ํ•œ classifier๋กœ ์ฒ˜๋ฆฌํ•˜๋Š” ๋Œ€์‹ , ๊ฐ ๋‹จ๊ณ„๊ฐ€ ์„œ๋กœ ๋‹ค๋ฅธ ์ •๋ณด๋ฅผ ๋‹ด๋‹นํ•˜๋„๋ก ํ•œ๋‹ค.

- Trajectory encoder: ํ•„๊ธฐ ๋™์ž‘๊ณผ ํ˜•ํƒœ
- Family head: ์‹œ๊ฐ์  ์œ ์‚ฌ์„ฑ
- Behavior head: ๊ธฐํ˜ธ์˜ ๋ฌธ๋ฒ•์  ์—ญํ• 
- Boundary head: stroke grouping
- Formula adapter: ์ˆ˜์‹ ์•ˆ์—์„œ์˜ ์ƒ๋Œ€ ํฌ๊ธฐ์™€ ์œ„์น˜

## ์—ฐ๊ตฌ ์ž๋ฃŒ

- [์ „์ฒด ๊ธฐ์ˆ  ๋ณด๊ณ ์„œ](reports/RESEARCH_REPORT.md)
- [Federation audit](reports/FEDERATION_AUDIT_20260724.md)
- [3-seed behavior ๊ฒฐ๊ณผ](reports/behavior_role_3seed_summary.json)
- [Boundary ๊ฒฐ๊ณผ](reports/boundary_behavior_guard_report.json)
- [Online ์˜ค๋ฅ˜ ํ•ฉ์˜ ๋ถ„์„](reports/online_error_consensus_paired_test_3seed.json)
- [Family-fusion calibration](reports/online_family_fusion_calibration_3seed.json)
- [Formula-context ๊ณ„์•ฝ ๋ถ„์„](reports/formula_context_contract_3seed.json)
- [Formula adapter ๊ฒฐ๊ณผ](reports/formula_adapter_h64_3seed_summary.json)
- [Checkpoint manifest](MANIFEST.json)