Before contrastive training, EmbeddingGemma's decoder was adapted into an encoder-decoder with UL2-style pretraining, as in T5Gemma: spans of the input are replaced by sentinel tokens, the encoder reads the corrupted text, and the decoder reconstructs the spans. Build the data side of that objective.
span_corrupt(tokens, spans, sentinel_base)
tokens is a list of token ids, spans a list of (start, length) pairs sorted by start and non-overlapping. The -th span (0-based) is replaced in the encoder input by the single sentinel id sentinel_base + i. The decoder target is, for each span in order, its sentinel followed by the span's original tokens, and finally one closing sentinel sentinel_base + len(spans). Return (encoder_input, decoder_target) as lists.corruption_rate(n, spans)
n tokens covered by the spans, rounded to 4 decimals.make_spans(n, span_len, rate)
n: the number of spans is k = max(1, round(n * rate / span_len)), span i starts at (i * n) // k and has length span_len, clipped so it ends at or before n. Return the list of (start, length) pairs.denoiser_spans(n, kind)
"R" (regular) is make_spans(n, 3, 0.15); "X" (extreme) is make_spans(n, 12, 0.5); "S" (sequential, a prefix language model) is a single span from n // 2 to the end.