da03 commited on
Commit
4fe17ee
·
1 Parent(s): 0d4c25e
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -22,7 +22,6 @@ def predict_product(num1, num2):
22
  input_text = f'{preprocess(num1)} * {preprocess(num2)} ='
23
  inputs = tokenizer(input_text, return_tensors='pt').to('cuda' if torch.cuda.is_available() else 'cpu')
24
  model.to('cuda' if torch.cuda.is_available() else 'cpu')
25
- eos_token_id = tokenizer.eos_token_id
26
 
27
  input_ids = inputs['input_ids']
28
  input_len = input_ids.shape[-1]
@@ -55,7 +54,7 @@ def predict_product(num1, num2):
55
  next_token_id = generated_ids[0, -1]
56
  print (next_token_id)
57
 
58
- if next_token_id.item() == eos_token_id:
59
  print ('berak')
60
  break
61
  past_key_values = outputs.past_key_values
@@ -86,7 +85,7 @@ def predict_product(num1, num2):
86
  if not is_correct_digit:
87
  is_correct_sofar = False
88
  if is_correct_digit:
89
- diff.append((correct_product[i], "-"))
90
  else:
91
  diff.append((predicted_digit, "+"))
92
  diff = diff[::-1]
 
22
  input_text = f'{preprocess(num1)} * {preprocess(num2)} ='
23
  inputs = tokenizer(input_text, return_tensors='pt').to('cuda' if torch.cuda.is_available() else 'cpu')
24
  model.to('cuda' if torch.cuda.is_available() else 'cpu')
 
25
 
26
  input_ids = inputs['input_ids']
27
  input_len = input_ids.shape[-1]
 
54
  next_token_id = generated_ids[0, -1]
55
  print (next_token_id)
56
 
57
+ if next_token_id.item() == tokenizer.eos_token_id:
58
  print ('berak')
59
  break
60
  past_key_values = outputs.past_key_values
 
85
  if not is_correct_digit:
86
  is_correct_sofar = False
87
  if is_correct_digit:
88
+ diff.append((predicted_digit, "-"))
89
  else:
90
  diff.append((predicted_digit, "+"))
91
  diff = diff[::-1]