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
ํต์ฌ ์ฐ๊ตฌ ์ฃผ์ ๋ ๋ค์๊ณผ ๊ฐ๋ค.
- ์๋ก ๋ค๋ฅธ ํ๊ธฐ ์๋๋ฅผ ์ผ์ ํ temporal representation์ผ๋ก ์ ๊ทํํ๋ ๋ฐฉ๋ฒ
- ์จ๋ผ์ธ stroke์ raster ์ด๋ฏธ์ง๋ฅผ ํ๋์ trajectory encoder๋ก ์ฒ๋ฆฌํ๋ ๋ฐฉ๋ฒ
- ์๊ฐ์ ์ผ๋ก ์ ์ฌํ ๊ธฐํธ์ ํํ์ ์๋ฏธ๋ฅผ ๋ถ๋ฆฌํ๋ ๋ฐฉ๋ฒ
- ๊ธฐํธ ๋ถ๋ฅ์ ์์ ๋ฌธ๋งฅ์ ๊ฒฐํฉํ๋ ๋ฐฉ๋ฒ
์ฐ๊ตฌ ์์ด๋์ด
1. Trajectory-first representation
์ผ๋ฐ์ ์ธ ์ด๋ฏธ์ง ๋ถ๋ฅ ๋ฐฉ์์ ํ๊ธฐ๋ฅผ ๊ณ ์ ๋ bitmap์ผ๋ก ๋ณํํ๋ฉด์ stroke ์์์ ์๊ฐ ์ ๋ณด๋ฅผ ์ ๊ฑฐํ๋ค.
AIFlow Math Ink๋ ํ๊ธฐ๋ฅผ ๋ค์๊ณผ ๊ฐ์ ์๊ณ์ด๋ก ํํํ๋ค.
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์์ ๋น๊ตํ ์ ์๋ค.
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๋ ๋ ์ขํ๊ณ๋ฅผ ๋์์ ์ฌ์ฉํ๋ค.
shape_x, shape_y
๊ธฐํธ ์์ฒด์ bounding box๋ฅผ ๊ธฐ์ค์ผ๋ก ์ ๊ทํํ ์ขํ๋ค. ๊ธ์์ ํฌ๊ธฐ์ ์์น ์ํฅ์ ์ค์ด๊ณ ์์ํ ํํ๋ฅผ ํํํ๋ค.
canvas_x, canvas_y
์ ์ฒด canvas ๋๋ ์์ ์์ญ์ ๊ธฐ์ค์ผ๋ก ํ ์ขํ๋ค. ๊ธฐํธ์ ์๋ ํฌ๊ธฐ์ ์์ง ์์น๋ฅผ ๋ณด์กดํ๋ค.
์๋ฅผ ๋ค์ด ์๋ฌธ์ x, ๋๋ฌธ์ X, ๊ณฑ์
๊ธฐํธ ร๋ ๋ชจ์์ด ๋น์ทํ์ง๋ง ์์ ์์์์ ํฌ๊ธฐ์ ์์น ๋ถํฌ๊ฐ ๋ค๋ฅผ ์ ์๋ค. ๋ ์ขํ๊ณ๋ฅผ ํจ๊ป ์ฌ์ฉํ๋ฉด ํํ์ ๋ฌธ๋งฅ์ ๋ถ๋ฆฌํด ํ์ตํ ์ ์๋ค.
4. Online๊ณผ raster์ ๊ณตํต trajectory space
์จ๋ผ์ธ ์ ๋ ฅ์๋ stroke sequence๊ฐ ์ง์ ์กด์ฌํ์ง๋ง, raster ์ด๋ฏธ์ง์๋ stroke ์์๊ฐ ์๋ค.
Raster ๊ฒฝ๋ก๋ ์ด๋ฏธ์ง๋ฅผ ๊ณง๋ฐ๋ก symbol label๋ก ๋ถ๋ฅํ๋ ๋์ , ์ด๋ฏธ์ง์์ ์ฌ๋ฌ ๊ฐ์ virtual trajectory๋ฅผ ์์ฑํ๋ค.
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์ ๊ณ์ธต์ ์์ธก
์ํ ๊ธฐํธ์๋ ํํ๊ฐ ๊ฑฐ์ ๋์ผํ์ง๋ง ์๋ฏธ๊ฐ ๋ค๋ฅธ ๊ฒฝ์ฐ๊ฐ ๋ง๋ค.
์:
O / 0 / o
x / X / ร
| / 1 / l
๋ชจ๋ธ์ ์ด๋ฅผ ํ๋์ ๋ถ๋ฅ ๋ฌธ์ ๋ก๋ง ๋ค๋ฃจ์ง ์๊ณ ๋ ๊ฐ์ prediction head๋ก ๋๋๋ค.
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๋ ๋ค์ ๋ ํํ์ ๊ฒฐํฉํ๋ค.
128ร19 stroke representation
+
49-dimensional formula context
Context feature์๋ ๋ค์๊ณผ ๊ฐ์ ์ ๋ณด๊ฐ ํฌํจ๋๋ค.
- ์์ ์ ์ฒด ํฌ๊ธฐ ๋๋น ๊ธฐํธ ํฌ๊ธฐ
- baseline๊ณผ์ ์๋ ์์น
- ์ฃผ๋ณ ๊ธฐํธ์ ์์น์ ๊ฐ๊ฒฉ
- symbol group geometry
- ์ด์ token ํจํด
ํ์ฌ behavior head์ ๋ํ ์ญํ ๋ถ๋ฅ๋ ๋ค์๊ณผ ๊ฐ๋ค.
identifier_lower
identifier_upper
multiply_operator
์๋ฅผ ๋ค์ด x, X, ร์ trajectory๊ฐ ๋น์ทํ ๋, ๊ธฐํธ์ ์๋ ํฌ๊ธฐ์ ์ฃผ๋ณ token์ ์ด์ฉํด ์ญํ ์ ์ ํํ๋ค.
7. Boundary behavior modeling
์์ ์ธ์์์๋ ์ฌ๋ฌ stroke๋ฅผ ํ๋์ ๊ธฐํธ๋ก ๋ฌถ๋ grouping ๊ณผ์ ์ด ํ์ํ๋ค.
Boundary behavior head๋ segmentation candidate๊ฐ ์ค์ ๊ธฐํธ ๊ฒฝ๊ณ๋ฅผ ๊ฐ๋ก์ง๋ฅด๋์ง๋ฅผ geometry feature๋ก ์์ธกํ๋ค.
Segmentation lattice geometry
โ 17-dimensional boundary features
โ boundary behavior score
์ด score๋ ๊ฐ๊น์ด ์๋ ๋ ๊ธฐํธ๊ฐ ํ๋์ symbol group์ผ๋ก ํฉ์ณ์ง๋ overmerge๋ฅผ ์ต์ ํ๋ ๋ฐ ์ฌ์ฉ๋๋ค.
์ ๋ ฅ ํํ
๋ชจ๋ธ ์ ๋ ฅ์ ์ต๋ 128๊ฐ์ event์ 19๊ฐ์ feature๋ก ๊ตฌ์ฑ๋๋ค.
input shape: 128 ร 19
sample rate: 6 Hz
normalized ink space: 128 ร 128
19 input channels
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 ์ ๋ณด๋ฅผ ํจ๊ป ์ฌ์ฉํ๋ค.
๋ชจ๋ธ ๊ตฌ์กฐ
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์ ํจ๊ป ํฉ์ฑ๋๋ค.
base trajectory state
โ online shared state
โ modality-specific adaptation
โ classifier heads
Checkpoints
๊ฐ seed๋ ๋ค์ ์ธ ํ์ผ๋ก ๊ตฌ์ฑ๋๋ค.
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 ํน์ฑ์ ๋ถ์ํ๋ ๋ฐ ์ฌ์ฉ๋๋ค.
์ฌ์ฉ ์์
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 ํ๋ณด์ ๊ฐ ํ๋ณด์ ํ๋ฅ ์ด ํฌํจ๋๋ค.
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 ๋ด๋ถ ํผ๋์ด์๋ค.
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์ ๋ค์๊ณผ ๊ฐ์ด ๋ณํํ๋ค.
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๋ฅผ ์ถ๊ฐํ๋ค.
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๋ฅผ ์ ํํ๋ค.
exact score
+
0.15 ร family-consistency score
Paired test exact top-1:
83.71% โ 83.82%
Family prediction์ exact classifier์ ํ๋ณด ์์๋ฅผ ์์ ๋ฒ์์์ ๋ณด์ ํ๋ ์ญํ ์ ํ๋ค.
์ฐ๊ตฌ ํด์
AIFlow Math Ink 0.6์ ์คํ์ ์ํ ํ๊ธฐ ์ธ์์ ๋ค์ ์ธ ๋จ๊ณ๋ก ๋ถ๋ฆฌํ ์ ์์์ ๋ณด์ฌ์ค๋ค.
1. Stroke trajectory์์ ์๊ฐ์ ํํ๋ฅผ ์ถ์ถ
2. Visual family ์์์ ๊ฐ๋ฅํ symbol ํ๋ณด๋ฅผ ๊ตฌ์ฑ
3. ์์ ๋ฌธ๋งฅ๊ณผ geometry๋ก exact meaning์ ์ ํ
์ด ๊ตฌ์กฐ๋ ๊ณ ๋ฆฝ ๊ธฐํธ ์ธ์๊ณผ ์ ์ฒด ์์ ํด์์ ํ๋์ ๊ฑฐ๋ํ classifier๋ก ์ฒ๋ฆฌํ๋ ๋์ , ๊ฐ ๋จ๊ณ๊ฐ ์๋ก ๋ค๋ฅธ ์ ๋ณด๋ฅผ ๋ด๋นํ๋๋ก ํ๋ค.
- Trajectory encoder: ํ๊ธฐ ๋์๊ณผ ํํ
- Family head: ์๊ฐ์ ์ ์ฌ์ฑ
- Behavior head: ๊ธฐํธ์ ๋ฌธ๋ฒ์ ์ญํ
- Boundary head: stroke grouping
- Formula adapter: ์์ ์์์์ ์๋ ํฌ๊ธฐ์ ์์น