Skip to content

Instantly share code, notes, and snippets.

@baberabb
baberabb / spo_loss.py
Created June 10, 2024 15:38 — forked from crowsonkb/spo_loss.py
Scalar Preference Optimization
"""Scalar Preference Optimization."""
import torch
from torch.nn import functional as F
def logp_completion(logits, tokens, mask):
"""Compute the log probabilities of completions given their prompts.
Args: