ayushraj2349-2 commited on
Commit
b6e81a2
·
verified ·
1 Parent(s): 159c5e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -14,7 +14,13 @@ def review_code(code_snippet):
14
 
15
  # Process input
16
  inputs = tokenizer(code_snippet, return_tensors="pt").to("cpu") # Move to CPU
17
- outputs = model.generate(**inputs, max_length=80, do_sample=False, num_beams=3)
 
 
 
 
 
 
18
 
19
  # Check if the model generated output
20
  if outputs is None:
 
14
 
15
  # Process input
16
  inputs = tokenizer(code_snippet, return_tensors="pt").to("cpu") # Move to CPU
17
+ outputs = model.generate(
18
+ **inputs,
19
+ max_length=50, # ✅ Reduced token generation to prevent hallucinations
20
+ do_sample=False,
21
+ num_beams=3,
22
+ repetition_penalty=2.0 # ✅ Penalizes repetitive text generation
23
+ )
24
 
25
  # Check if the model generated output
26
  if outputs is None: