Update app.py
Browse files
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(
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|