Einmalumdiewelt commited on
Commit
4a5fd41
·
1 Parent(s): 49c0671

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -11,10 +11,18 @@ model.to(device)
11
 
12
 
13
  def summarize(inputs):
 
 
 
 
 
 
 
 
14
  preds = model.generate(**inputs,max_length=200,min_length=100)
15
- # we decode the predictions to store them
16
  decoded_predictions = tokenizer.batch_decode(preds, skip_special_tokens=True)
17
- # each batches predictions are appended to the list
18
  return decoded_predictions
19
 
20
  description = "Quickly summarize your German text in a few sentences. \nThe algorithm was fine-tuned on high-quality German news articles."
 
11
 
12
 
13
  def summarize(inputs):
14
+ #define model inputs
15
+ inputs = tokenizer(
16
+ inputs.tolist(),
17
+ max_length=512,
18
+ truncation=True,
19
+ padding="max_length",
20
+ return_tensors='pt').to(device)
21
+ #generate preds
22
  preds = model.generate(**inputs,max_length=200,min_length=100)
23
+ #we decode the predictions to store them
24
  decoded_predictions = tokenizer.batch_decode(preds, skip_special_tokens=True)
25
+ #return
26
  return decoded_predictions
27
 
28
  description = "Quickly summarize your German text in a few sentences. \nThe algorithm was fine-tuned on high-quality German news articles."