Accepted for Sprint 1 planning

ADR-0001: Landmark Model Architecture

작성일: 2026-05-13 · 결정 범위: 모델 선택, fine-tuning, ONNX 배포 경로

Context

제품 문서의 목표는 온디바이스 이미지 입력만으로 서울 랜드마크 Top-k 후보를 반환하고, 저신뢰 입력은 무리하게 단정하지 않는 것이다. Sprint Backlog의 핵심 모델 작업은 경량 ONNX 모델 준비, tensor 변환, image embedding 생성, smoke test다.

사용자 확인 기준 전체 데이터셋은 Google Drive에 있으며 10~13개 카테고리, 카테고리당 평균 약 400장이다. labels.json은 로컬 샘플과 유사하게 landmark_id, landmark_name, label_status, view_type, quality_status, captions를 포함한다고 가정한다.

딥인터뷰 Round 1에서 제품 범위는 종로구 특정 랜드마크 10~15개 fixed set으로 확인되었다. Sprint 1은 Flutter 완성도보다 온디바이스/local runtime 기술 시현이 중요하며, 정확도가 최우선이다. 50MB 이하 모델과 1초 이하 latency는 목표값이지만 hard stop은 아니다. Round 2에서는 2026-05-18 시연을 위해 휴대폰 탑재를 우선하되, 실패 시 노트북 ONNX runtime으로 대체하는 demo ladder를 채택했다. Round 3에서는 앱 구현과 상세정보 DB는 팀원이 담당하고, 모델 팀은 모델 개발과 serving contract에 집중하기로 했다. Round 4에서는 Sprint 1 handoff package를 JSON 기반으로 단순화하고, 사용자 표시 점수는 percentage, out-of-scope 후보는 화면에서 숨기고 debug log에만 남기기로 했다. 학습 서버는 8 × NVIDIA Tesla P100 PCIe 16GB로 확인되었으므로, 기존 GPU 미확정 리스크는 해소하고 P100의 BF16 미지원과 16GB VRAM 제약을 기준으로 학습 전략을 조정한다.

Decision

Sprint 1의 모델 구조는 retrieval-first + auxiliary classification으로 결정한다. 사용자 경험은 image-only 검색이지만, 학습과 후보 인덱스 구성에는 captions와 landmark names를 활용한다.

  1. DINOv3는 visual embedding teacher, SigLIP2는 multilingual image-text teacher로 분리해 frozen baseline을 비교한다.
  2. 오늘은 teacher를 최종 고정하지 않고, Top-k 정확도와 rejection/calibration gate를 통과한 쪽을 student distillation 기준으로 삼는다.
  3. Teacher embedding으로 class prototype, image prototype, text candidate embedding을 오프라인 생성한다.
  4. Mobile target용 student image encoder를 supervised contrastive learning + classification + distillation으로 학습한다.
  5. 앱에는 student image encoder ONNX와 JSON 형태의 prototype index를 탑재한다.
  6. 검색 결과는 cosine similarity Top-k, Top1/Top2 margin, coverage@accuracy 기준 confidence threshold로 산출한다.

Recommended Path

순위 경로 추천 이유 리스크
1안 DINOv3 visual teacher + lightweight student image encoder image-only landmark 구분과 hard negative에 강한 visual representation을 기대할 수 있다. DINOv3는 최신 계열이라 서버 패키지 버전 호환과 checkpoint availability를 먼저 확인해야 한다.
2안 SigLIP2 image-text teacher + student distillation into shared retrieval space labels.json의 captions, landmark_name_en, candidate_text를 retrieval index로 쓰기 쉽다. text preprocessing 규칙과 tokenizer 설정이 틀리면 성능이 흔들릴 수 있다.
Fallback timm EfficientNet/ConvNeXt/MobileNet 계열 + classification/prototype retrieval ONNX export와 local runtime 기술 시현을 빠르게 검증한다. teacher 기반 retrieval보다 open-set/near-duplicate 변별력이 낮을 수 있다.

Fine-tuning Design

Stage 0: Data audit

labels.json과 images 폴더를 기준으로 missing file, duplicate image, class balance, label_status, quality_status, view_type, source_group_id 분포를 저장한다. reject/not_landmark와 서울 외 장소는 검색 거절 threshold 평가에 별도 사용한다.

Stage 1: Frozen teacher baseline

DINOv3와 SigLIP2를 freeze하고 모든 train/val/test image embedding을 생성한다. DINOv3는 visual prototype retrieval, SigLIP2는 caption/name 기반 image-text retrieval을 평가한다. class prototype retrieval로 Top-1, Top-3 Accuracy, Recall@K, confusion matrix를 산출하고, negative set이 있으면 reject AUROC, coverage@accuracy, Top1/Top2 margin threshold도 함께 기록한다. 이 결과가 이후 fine-tuning의 baseline이자 teacher 선택 gate다.

Stage 2: Student training

student image encoder는 deployability를 우선한다. loss는 L = CE(class) + SupCon/Triplet + KD(teacher embedding cosine)로 시작한다. 처음부터 full fine-tune을 하기보다 frozen/partial unfreeze, LoRA, 마지막 stage unfreeze 순으로 확장한다.

Stage 3: Hard negative tuning

경복궁/창덕궁처럼 유사한 랜드마크 또는 같은 건물의 interior/sign/detail view가 혼동되는 경우를 confusion matrix에서 골라 hard negative sampler와 margin loss를 적용한다. 이 단계는 US-06의 오인식률 개선 근거가 된다. 현재 negative 데이터는 부족하므로, 한국 전통 건축물 중 외형이 유사한 범위 외/유사 랜드마크 샘플을 별도 수집 대상으로 둔다.

Stage 4: ONNX and quantization

student를 ONNX로 export하고 ONNX Runtime에서 dummy input과 실제 validation image를 통과시킨다. Sprint 1 target device와 execution provider를 정한 뒤 operator fallback, preprocessing parity, quantization 후 Top-3 Accuracy 및 rejection metric 하락폭을 비교한다. 이후 dynamic quantization 또는 static INT8 calibration을 적용해 파일 크기, latency, accuracy 변화를 기록한다.

Inference Architecture

Component Runtime 역할
Image preprocessing Flutter/Dart 또는 native helper resize, RGB 변환, normalize, tensor 변환. 학습 preprocessing과 bit-level까지 맞추는 것을 목표로 한다.
Student image encoder ONNX Runtime Mobile 입력 이미지를 normalized embedding으로 변환한다.
Prototype index JSON bundled asset landmark_id별 image/text prototype과 candidate metadata를 저장한다. Sprint 1은 JSON을 표준으로 둔다.
Search confidence Service layer Top-1 score, Top-1/Top-2 margin, coverage@accuracy 기준 threshold로 판독 가능 여부를 결정한다.
App contract Model serving wrapper matched, out_of_scope, invalid_image status와 percentage Top-3 후보를 앱에 반환한다.

Demo Ladder

  1. Preferred: 휴대폰에서 ONNX Runtime Mobile로 모델을 로드하고 사진 입력, Top-3 출력, 상세정보 표시까지 시현한다.
  2. Fallback: 노트북 local ONNX Runtime에서 같은 모델과 prototype index로 사진 입력, Top-3 출력, 상세정보 표시를 시현한다.
  3. Flutter shell은 시간이 허용될 때 붙인다. 모델 학습, ONNX export, local inference 검증을 Flutter UI보다 먼저 끝낸다.
  4. 범위 외 입력은 화면에 Top-3를 보여주지 않고, debug log에 후보와 raw score를 남긴다.

Training Strategy on 8 P100 GPUs

학습 서버는 Ubuntu 20.04 LTS, 8 × NVIDIA Tesla P100 PCIe 16GB, 128GB RAM, CUDA 12.2로 확인되었다. single-node DDP를 기본으로 사용하되, 큰 teacher full fine-tuning은 여전히 보류한다. 오늘 목표는 teacher frozen embedding과 student training 시작이다.

P100 16GB는 Sprint 1 student 학습에는 충분하지만 최신 대형 vision-language teacher를 full fine-tune하기에는 빠듯하다. teacher는 frozen embedding 생성에 우선 사용하고, 학습 대상은 deployable student로 제한한다.

Experiment Metadata

각 실험은 dataset snapshot, split manifest hash, model name, checkpoint id, license, preprocessing config hash, PyTorch/Transformers/timm/ONNX Runtime 버전, target device, execution provider, quantization mode를 함께 남긴다. 이 항목이 없으면 성능 수치를 재현 가능한 결과로 취급하지 않는다.

Consequences

References