amiguel commited on
Commit
9c4ef39
·
verified ·
1 Parent(s): 3c9f4cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -101,14 +101,14 @@ def generate_translation(input_text, model, tokenizer):
101
  # Set up the streamer for real-time output
102
  streamer = TextStreamer(tokenizer, skip_special_tokens=True)
103
 
104
- # Generate translation with streaming
105
  model.eval()
106
  with torch.no_grad():
107
  outputs = model.generate(
108
  input_ids=inputs["input_ids"],
109
  attention_mask=inputs["attention_mask"],
110
  max_length=512,
111
- num_beams=5,
112
  length_penalty=1.0,
113
  early_stopping=True,
114
  streamer=streamer,
 
101
  # Set up the streamer for real-time output
102
  streamer = TextStreamer(tokenizer, skip_special_tokens=True)
103
 
104
+ # Generate translation with streaming (disable beam search)
105
  model.eval()
106
  with torch.no_grad():
107
  outputs = model.generate(
108
  input_ids=inputs["input_ids"],
109
  attention_mask=inputs["attention_mask"],
110
  max_length=512,
111
+ num_beams=1, # Set to 1 to disable beam search for streaming
112
  length_penalty=1.0,
113
  early_stopping=True,
114
  streamer=streamer,