Skip to content

Commit

Permalink
restored test file
Browse files Browse the repository at this point in the history
  • Loading branch information
poedator committed Nov 30, 2023
1 parent 204b4b8 commit 020e46b
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions tests/generation/test_beam_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,39 +575,3 @@ def test_constrained_beam_scorer_update(self):
def test_constrained_beam_scorer_finalize(self):
inputs = self.constrained_beam_search_tester.prepare_inputs()
self.constrained_beam_search_tester.check_constrained_beam_scorer_finalize(*inputs)


@require_torch
@require_torch_gpu
# @slow
class Beams4dTest(unittest.TestCase):
def setUp(self):
device = 'cuda' if torch.cuda.is_available() else 'cpu'
self.model_name = "facebook/opt-125m"
model = transformers.AutoModelForCausalLM.from_pretrained(self.model_name, device_map=device)

prefix_tokens = torch.tensor([11, 22, 33], device=device)
new_tokens = torch.tensor([44, 55, 66, 77], device=device)

model_outputs_0 = model.forward(input_ids=prefix_tokens.unsqueeze(0)) # preparing KV cache value

# regular beam search iteration
kv_cache =


# Constant values
EXPECTED_RELATIVE_DIFFERENCE = (
2.109659552692574 # This was obtained on a RTX Titan so the number might slightly change
)

input_text = "Hello my name is"
EXPECTED_OUTPUTS = set()
EXPECTED_OUTPUTS.add("Hello my name is John and I am a professional photographer. I")
EXPECTED_OUTPUTS.add("Hello my name is John.\nI am a friend of your father.\n")
EXPECTED_OUTPUTS.add("Hello my name is John Doe, I am a student at the University")
MAX_NEW_TOKENS = 10

def setUp(self):
# Models and tokenizer
self.tokenizer = AutoTokenizer.from_pretrained(self.model_name)

0 comments on commit 020e46b

Please sign in to comment.