Case Study

Calculating a Relative Position Bias Bucket

A model computes a bias for relative positions using a unified bucketing function. This function maps a relative position offset, i-j, to a bucket index, b(i-j), using the piecewise formula below. The formula uses a direct mapping for small offsets and a logarithmic mapping for larger ones.

Formula:

  • If 0 <= i-j < (n_b+1)/2, then b(i-j) = i-j
  • If i-j >= (n_b+1)/2, then b(i-j) = min(n_b, (n_b+1)/2 + floor( (log(i-j) - log((n_b+1)/2)) / (log(dist_max) - log((n_b+1)/2)) * (n_b+1)/2 ))

Given the scenario below, calculate the correct bucket index.

0

1

Updated 2025-09-26

Contributors are:

Who are from:

Tags

Ch.2 Generative Models - Foundations of Large Language Models

Foundations of Large Language Models

Foundations of Large Language Models Course

Computing Sciences

Application in Bloom's Taxonomy

Cognitive Psychology

Psychology

Social Science

Empirical Science

Science