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

Adding inference support for next logit probability. #78

Merged
merged 8 commits into from
Jun 17, 2024

Conversation

kaisopos
Copy link
Contributor

@kaisopos kaisopos commented Jun 13, 2024

Contributes to OPE-35

src/lema/infer_prob.py Outdated Show resolved Hide resolved
src/lema/infer_prob.py Outdated Show resolved Hide resolved
src/lema/infer_prob.py Outdated Show resolved Hide resolved
src/lema/infer_prob.py Outdated Show resolved Hide resolved
src/lema/infer_prob.py Outdated Show resolved Hide resolved
src/lema/infer_prob.py Outdated Show resolved Hide resolved
src/lema/infer_prob.py Outdated Show resolved Hide resolved
src/lema/infer_prob.py Outdated Show resolved Hide resolved
src/lema/infer_prob.py Outdated Show resolved Hide resolved
src/lema/infer_prob.py Outdated Show resolved Hide resolved
for acceptable_logit in acceptable_logits_enc:
acceptable_logit_prob = next_logit_probs[acceptable_logit]
acceptable_logit_probs.append(
acceptable_logit_prob.detach().cpu().numpy().item()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend using the inference_mode or no_grad decorator. That'll avoid the need to manually detach + inference will be faster

I also just noticed that we do not set the model.eval() in our inference scripts, we should add that as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no_grad : Done.
model.eval() in our inference scripts --> can you elaborate?

src/lema/infer_prob.py Outdated Show resolved Hide resolved
tests/test_infer_prob.py Show resolved Hide resolved
src/lema/infer_prob.py Outdated Show resolved Hide resolved
Copy link

linear bot commented Jun 14, 2024

OPE-35 Add in-training evaluation options

HuggingFace trainers already support evaluation every N training steps. The goal of this task is to enable configuring a list of datasets to evaluate intermediate checkpoints.

src/lema/infer_prob.py Outdated Show resolved Hide resolved
src/lema/infer_prob.py Outdated Show resolved Hide resolved
tests/test_infer_prob.py Outdated Show resolved Hide resolved
@kaisopos kaisopos merged commit 06790a0 into main Jun 17, 2024
1 check passed
@kaisopos kaisopos deleted the kostas_infer_probabilities branch June 17, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants