Yaron Koresh commited on
Commit
27d4615
·
verified ·
1 Parent(s): 860412d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -560,6 +560,7 @@ def get_tensor_length(tensor):
560
  return ret
561
 
562
  def _summarize(text, max_words=20):
 
563
  prefix = "summarize: "
564
  toks = tokenizer.encode( prefix + text, return_tensors="pt", truncation=False)
565
  gen = model.generate(
@@ -569,10 +570,12 @@ def _summarize(text, max_words=20):
569
  early_stopping=True,
570
  max_length=max_words
571
  )
572
- return tokenizer.decode(gen[0], skip_special_tokens=True)
 
 
573
 
574
  def _summ_step(length):
575
- return max(length // 3 , min(10,length-4))
576
 
577
  def summarize(text, max_words=20):
578
  log(f'CALL summarize')
 
560
  return ret
561
 
562
  def _summarize(text, max_words=20):
563
+ log(f'CALL _summarize')
564
  prefix = "summarize: "
565
  toks = tokenizer.encode( prefix + text, return_tensors="pt", truncation=False)
566
  gen = model.generate(
 
570
  early_stopping=True,
571
  max_length=max_words
572
  )
573
+ ret = tokenizer.decode(gen[0], skip_special_tokens=True)
574
+ log(f'RET _summarize with ret as {ret}')
575
+ return ret
576
 
577
  def _summ_step(length):
578
+ return length // 1.5
579
 
580
  def summarize(text, max_words=20):
581
  log(f'CALL summarize')