////

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: 중복 시프트 방지 원칙과 명시 인자 권장은 여전히 최신 관행이다

Reviews

Support
0
Dispute
0
Neutral
0
Visible Reviews
1