Skip to content

Instantly share code, notes, and snippets.

View baberabb's full-sized avatar

Baber Abbasi baberabb

View GitHub Profile
@crowsonkb
crowsonkb / spo_loss.py
Last active June 10, 2024 15:38
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: