Skip to content

Commit

Permalink
set random seeds in the alpaca run script (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkupnicki authored Oct 17, 2024
1 parent eac6bda commit 1237c0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions natural_language_processing/text_generation/alpaca/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def run_single_pass(pytorch_runner, _dataset):
response = decode(outputs[:, inputs.input_ids.shape[1]:])
_dataset.submit_prediction(response)

import numpy as np
import torch
np.random.seed(44)
torch.manual_seed(44)
model = AutoModelForCausalLM.from_pretrained(model_path)
if use_torch_fp16:
model = model.half()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pytorch_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_alpaca(self):
def wrapper(**kwargs):
kwargs["q"].put(run_pytorch_fp32(**kwargs)[0])

exact_match_ref, f1_ref = 0.180, 0.548
exact_match_ref, f1_ref = 0.220, 0.547
acc = run_process(wrapper, {"model_path": self.model_path, "batch_size": 1, "num_runs": 50,
"timeout": None, "dataset_path": self.dataset_path})
self.assertTrue(acc["exact_match"] / exact_match_ref > 0.95)
Expand Down

0 comments on commit 1237c0e

Please sign in to comment.