← 문제 목록/SIF Weighted Bag (Arora et al. 2017) [medium]
문제 해설

SIF Weighted Bag (Arora et al. 2017) [medium]

신경망 · medium

preview

SIF (Smooth Inverse Frequency) Bag [medium]

v1 bag-of-embeddings 은 단순 평균. Arora et al. (2017) "A Simple but Tough-to-Beat Baseline"확률 역수 가중을 제안:

sb=lwlEidxb,llwl,wl=aa+p(idxb,l)\mathbf{s}_b = \frac{\sum_l w_l \cdot E_{\text{idx}_{b,l}}}{\sum_l w_l}, \quad w_l = \frac{a}{a + p(\text{idx}_{b,l})}

여기서 p(w)p(w) 는 token 확률 (코퍼스 빈도), a103a \approx 10^{-3}.

직관

  • 고빈도 단어("the", "is") → pp 큼 → ww 작음 → 기여 적음.
  • 저빈도 단어("quantum") → pp 작음 → w1w \approx 1 → 가중치 큼.
  • TF-IDF 의 연속 버전. 의미 담은 단어가 sentence vector 를 지배.

Word2Vec/GloVe 평균 + SIF → 많은 semantic benchmark 에서 LSTM/CNN 을 이김 (간단한 baseline 이 강력한 이유).

과제

함수 sif_bag(E, idx_batch, probs, a=1e-3) 를 완성하세요.

  • E shape (V, D).
  • idx_batch shape (B, L) 정수.
  • probs shape (V,) — token별 확률.
  • a 스무딩 상수.
  • 반환: shape (B, D).

테스트 케이스

#이름검증
1shape (B, D)
2균등 probs → 평균 (v1 등가)
3고빈도 token 가중치 작음변화시 출력 변동 작음
4저빈도 token 가중치 큼
5a → ∞ 극한 → 평균
6permutation invariance순서 바꿔도 동일
7알려진 toy 값
코드 작성
Loading...
실행 결과

코드를 작성하고 Run 을 눌러보세요.