Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce VINC reporter file size by >1000x #219

Merged
merged 6 commits into from
May 3, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/main' into light-reporter-saving
  • Loading branch information
norabelrose committed May 2, 2023
commit 7c29973f05ed79a2d0d79e31d23acb2e18a6bc2a
11 changes: 11 additions & 0 deletions elk/training/ccs_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,17 @@ def reset_parameters(self):

def forward(self, x: Tensor) -> Tensor:
"""Return the raw score output of the probe on `x`."""
assert x.shape[-2] == 2, "Probe input must be a contrast pair"

# Apply normalization
x0, x1 = x.unbind(-2)
x0, x1 = self.neg_norm(x0), self.pos_norm(x1)
x = torch.stack([x0, x1], dim=-2)

return self.raw_forward(x)

def raw_forward(self, x: Tensor) -> Tensor:
"""Apply the probe to the provided input, without normalization."""
return self.probe(x).mul(self.scale).add(self.bias).squeeze(-1)

def loss(
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.