craigchen commited on
Commit
6785767
·
1 Parent(s): 25cb490

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -52,7 +52,7 @@ def generate_title():
52
  # compute span boundaries
53
  num_tokens = len(inputs["input_ids"][0])
54
  print(f"Input has {num_tokens} tokens")
55
- max_input_length = 500
56
  num_spans = math.ceil(num_tokens / max_input_length)
57
  print(f"Input has {num_spans} spans")
58
  overlap = math.ceil((num_spans * max_input_length - num_tokens) / max(num_spans - 1, 1))
@@ -83,7 +83,8 @@ def generate_title():
83
  # compute predictions
84
  outputs = model.generate(**inputs, do_sample=True, temperature=temperature)
85
  decoded_outputs = tokenizer.batch_decode(outputs, skip_special_tokens=True)
86
- predicted_titles = [decoded_output[0] for decoded_output in decoded_outputs]
 
87
 
88
  st.session_state.titles = predicted_titles
89
 
 
52
  # compute span boundaries
53
  num_tokens = len(inputs["input_ids"][0])
54
  print(f"Input has {num_tokens} tokens")
55
+ max_input_length = 25
56
  num_spans = math.ceil(num_tokens / max_input_length)
57
  print(f"Input has {num_spans} spans")
58
  overlap = math.ceil((num_spans * max_input_length - num_tokens) / max(num_spans - 1, 1))
 
83
  # compute predictions
84
  outputs = model.generate(**inputs, do_sample=True, temperature=temperature)
85
  decoded_outputs = tokenizer.batch_decode(outputs, skip_special_tokens=True)
86
+ # predicted_titles = [decoded_output[0] for decoded_output in decoded_outputs]
87
+ predicted_titles = [nltk.sent_tokenize(decoded_output.strip())[0] for decoded_output in decoded_outputs]
88
 
89
  st.session_state.titles = predicted_titles
90