C.W.K.
Stream
Lesson 08 of 12 · published

Sequence Data 가 왜 어려운가

~16 min · sequence, rnn, context

Level 0Curious
0 XP0/73 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

Variable length, order matters, long-range dependency

Image 는 fixed-size grid. Sentence 는 word order 에 의미 의존하는 variable-length sequence ('dog bites man' ≠ 'man bites dog'). Audio 는 high sampling rate 의 long sequence. Code 는 structured sequence. 각 token 의 의미가 멀리 있는 token 에 의존 — 가끔 관련 context 가 수백 token 뒤.

핵심 challenge 3 개: variable length (fixed input shape 없음), order sensitivity (token permute 하면 의미 바뀜), long-range dependency (token N 이 token N-1000 에 의존).

팁: 이 track 의 모든 sequence architecture 가 그 셋 중 하나에 대한 답. RNN 이 variable length 를 sequentially 다뤄. Attention 이 long-range dependency 를 parallel 로 다뤄. Transformer 가 둘 다, length 에 quadratic cost 로 — newer model (Mamba, RWKV) 이 fix 시도 중.

Sequence task shape

  • Sequence classification (sentiment, intent) — 전체 sequence 에 한 label.
  • Sequence labeling (NER, POS) — token 당 한 label.
  • Sequence-to-sequence (translation, summarization) — input sequence 주어진 output sequence.
  • Causal language modeling (GPT) — 모든 이전 token 주어진 next token 예측.

이상적 sequence model 에 필요한 것

Constant-time per-token inference, true long-range memory, parallelizable training, reasonable parameter efficiency. 단일 architecture 가 4 가지 다 안 가짐. RNN 이 constant per-token cost 줬지만 long-range memory 나쁨, transformer 가 quadratic attention 비용으로 좋은 long-range memory 와 parallel training 줌.

원칙: Sequence modeling 이 tradeoff space 지 풀린 문제 아냐. 본인 task 가 어떤 axis (latency, context length, training compute) 에 bound 됐는지 아는 게 올바른 architecture pick 의 절반.

Code

Three sequence task shapes in one screen·python
from transformers import pipeline

# Sequence classification (one label per sequence)
clf = pipeline("text-classification", model="distilbert-base-uncased-finetuned-sst-2-english")
print(clf("I love this so much"))   # [{'label': 'POSITIVE', 'score': 0.999}]

# Sequence labeling (one label per token)
ner = pipeline("ner", model="dbmdz/bert-large-cased-finetuned-conll03-english")
print(ner("Pippa lives in Seoul."))

# Causal language modeling (next-token prediction)
gen = pipeline("text-generation", model="gpt2")
print(gen("Deep learning is", max_length=30))

External links

Exercise

위 4 sequence task shape 마다, Hugging Face 에서 pretrained model 하나 찾아서 본인 도메인 example 3 개에 inference. 본인 real-world 문제가 어떤 task shape 에 매핑되는지 봐.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.