Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions disco/scorers/pipeline_scorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def __init__(self, label, params, temperature=1.0):
self.pipeline = pipeline(**params)
self.temperature = temperature

def log_score(self, samples, _):
"""computes the log-scores of the samples
def score(self, samples, _):
"""computes the scores of the samples
from the label returned by the pipeline

Parameters
Expand All @@ -37,9 +37,9 @@ def log_score(self, samples, _):

Returns
-------
tensor of log-probabilities"""
tensor of scores"""

return torch.log(
return (
torch.tensor(
[[r_i["score"] for r_i in r if self.label == r_i["label"]][0]
for r in self.pipeline([s.text for s in samples], return_all_scores=True)]
Expand Down
2 changes: 1 addition & 1 deletion disco/tuners/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _update_features_moments(self, context, samples, proposal_log_scores, model_
logweights = model_log_scores - proposal_log_scores
importance_ratios = torch.exp(logweights)
for (label, feature) in self.features:
proposal_moment_pointwise_estimates = feature.log_score(samples, context).exp().to(device)
proposal_moment_pointwise_estimates = feature.score(samples, context).to(device)
self.features_moments_proposal[label][context] += proposal_moment_pointwise_estimates
self.features_moments_target[label][context] += importance_ratios * proposal_moment_pointwise_estimates

Expand Down