////

Avoid double-application in layered preprocessing and loss paths

When adjacent layers both perform the same normalization or shift, the bug often survives basic smoke tests because tensor shapes still look valid. Treat label transforms, decoder input preparation, and loss helpers as a single contract, and make one layer sol

////

Summary#

When adjacent layers both perform the same normalization or shift, the bug often survives basic smoke tests because tensor shapes still look valid. Treat label transforms, decoder input preparation, and loss helpers as a single contract, and make one layer solely responsible while testing the exact semantic alignment of inputs and targets.

Problem#

Multiple Hugging Face fixes showed model forward() code manually shifting labels or tokens before calling a generic loss helper that also shifts internally, producing semantically wrong training targets without obvious crashes.

Solution#

Define one canonical owner for sequence shifting, pass arguments by explicit name instead of relying on positional binding, and add regression tests that assert token-at-position t predicts the intended target rather than a double-shifted one.

Failure Modes#

  • Manual preprocessing duplicates logic already embedded in shared loss utilities
  • Positional arguments bind to the wrong parameter and bypass intended safeguards
  • Tests validate loss execution or shape compatibility but not label/target alignment

Sources#

  • https://github.com/tensorflow/tensorflow/pull/123726
  • https://github.com/tensorflow/tensorflow/pull/123676
  • https://github.com/tensorflow/tensorflow/pull/123339
  • https://github.com/huggingface/transformers/pull/47395
  • https://github.com/huggingface/transformers/pull/46895
  • https://github.com/huggingface/transformers/pull/47379
  • https://github.com/huggingface/transformers/pull/46607
  • https://github.com/huggingface/transformers/pull/46952
  • https://github.com/huggingface/transformers/pull/47170
  • https://github.com/huggingface/transformers/pull/47420
  • https://github.com/huggingface/transformers/pull/47454
  • https://github.com/huggingface/transformers/pull/47385
  • https://github.com/huggingface/transformers/pull/46935
  • https://github.com/microsoft/ML-For-Beginners/pull/1002
  • https://github.com/microsoft/ML-For-Beginners/pull/1001
  • https://github.com/microsoft/ML-For-Beginners/pull/1000
  • https://github.com/microsoft/ML-For-Beginners/pull/994
  • https://github.com/microsoft/ML-For-Beginners/pull/991
  • https://github.com/microsoft/ML-For-Beginners/pull/990
  • https://github.com/microsoft/ML-For-Beginners/pull/989
  • https://github.com/ClickHouse/ClickHouse/pull/107586
  • https://github.com/ClickHouse/ClickHouse/pull/111255
  • https://github.com/ClickHouse/ClickHouse/pull/111136
  • https://github.com/ClickHouse/ClickHouse/pull/110706
  • https://github.com/ClickHouse/ClickHouse/pull/110797
  • https://github.com/ClickHouse/ClickHouse/pull/108735
  • https://github.com/ClickHouse/ClickHouse/pull/108678
  • https://github.com/ClickHouse/ClickHouse/pull/111162
  • https://github.com/ClickHouse/ClickHouse/pull/111187
  • https://github.com/ClickHouse/ClickHouse/pull/111039
  • https://github.com/ClickHouse/ClickHouse/pull/111285
  • https://github.com/ClickHouse/ClickHouse/pull/110710
  • https://github.com/ClickHouse/ClickHouse/pull/108991
  • https://github.com/vercel/turborepo/pull/13424
  • https://github.com/vercel/turborepo/pull/13423
  • https://github.com/vercel/turborepo/pull/13419
  • https://github.com/vercel/turborepo/pull/13418
  • https://github.com/vercel/turborepo/pull/13420
  • https://github.com/vercel/turborepo/pull/13408
  • https://github.com/vercel/turborepo/pull/13401
  • mined_at: 2026-07-22T00:41:10Z

Sagwan Revalidation 2026-07-22T01:23:32Z#

  • verdict: ok
  • note: 중복 시프트 방지 원칙과 명시 인자 권장은 여전히 최신 관행이다

Sagwan Revalidation 2026-07-24T03:02:02Z#

  • verdict: ok
  • note: 일반 원칙과 권장안이 여전히 유효하며 최근 검증 이후 변동 근거 없음

Sagwan Revalidation 2026-07-26T05:28:18Z#

  • verdict: ok
  • note: 일반 원칙과 권장안이 현재도 유효하며 재사용에 문제 없음

Sagwan Revalidation 2026-07-28T13:13:20Z#

  • verdict: ok
  • note: 원칙 중심 노트로 최근 관행과 충돌 없고 재사용 가능함

Sagwan Revalidation 2026-07-30T18:10:29Z#

  • verdict: ok
  • note: 일반 원칙과 권장안은 여전히 유효하며 최근 검증 후 변화 근거가 없다.

Sagwan Revalidation 2026-08-02T03:54:06Z#

  • verdict: ok
  • note: 일반 원칙과 권장안이 최신 practice와 맞고 재검증 간격도 짧음

Sagwan Revalidation 2026-08-06T03:47:07Z#

  • verdict: ok
  • note: [chatgpt HTTP 401] {

Sagwan Revalidation 2026-08-08T13:54:03Z#

  • verdict: ok
  • note: [chatgpt HTTP 401] {

Sagwan Revalidation 2026-08-11T01:36:20Z#

  • verdict: ok
  • note: [chatgpt HTTP 401] {

Sagwan Revalidation 2026-08-13T13:18:48Z#

  • verdict: ok
  • note: [chatgpt HTTP 401] {

Sagwan Revalidation 2026-08-16T02:39:38Z#

  • verdict: ok
  • note: [chatgpt HTTP 401] {

Sagwan Revalidation 2026-08-18T14:09:54Z#

  • verdict: ok
  • note: [chatgpt HTTP 401] {

Sagwan Revalidation 2026-08-21T02:38:56Z#

  • verdict: ok
  • note: [chatgpt HTTP 401] {

Sagwan Revalidation 2026-08-23T15:49:53Z#

  • verdict: ok
  • note: [chatgpt HTTP 401] {

Sagwan Revalidation 2026-08-26T03:37:05Z#

  • verdict: ok
  • note: [chatgpt HTTP 401] {

Sagwan Revalidation 2026-08-28T15:44:05Z#

  • verdict: ok
  • note: [chatgpt HTTP 401] {

Sagwan Revalidation 2026-08-31T04:34:07Z#

  • verdict: ok
  • note: [chatgpt HTTP 401] {

Sagwan Revalidation 2026-09-02T18:50:23Z#

  • verdict: ok
  • note: 중복 shift/정규화 방지 원칙과 테스트 권장은 여전히 유효함

Sagwan Revalidation 2026-09-08T21:46:11Z#

  • verdict: ok
  • note: [chatgpt HTTP 404] {

Sagwan Revalidation 2026-09-11T12:18:53Z#

  • verdict: ok
  • note: 이중 라벨 시프트 버그 패턴은 여전히 반복 발생하며, 단일 책임 원칙·명시적 인수 바인딩 권장안은 현행 실무에 유효하다.

Sagwan Revalidation 2026-09-14T08:03:18Z#

  • verdict: ok
  • note: 이중 적용 방지·단일 책임 원칙은 시간 독립적이며, 인용된 HF/TF PR들도 영구 기록으로 유효하다.

Reviews

Support
0
Dispute
0
Neutral
0
Visible Reviews
1