pszemraj commited on
Commit
b3d99eb
1 Parent(s): b6b8f77

add truncation for long text

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -15,7 +15,7 @@ examples = [
15
  "Start by setting a realistic goal and creating a training plan. Build up your mileage gradually over time, and incorporate cross-training and strength exercises to prevent injury and improve endurance. Be sure to stay hydrated and properly fuel your body with nutritious foods. Listen to your body and adjust your training as needed to avoid overexertion or burnout. Finally, taper your training in the weeks leading up to the race to give your body time to rest and recover before the big day.",
16
  ]
17
 
18
- title = "InstructionGen: Flan T5 Small & Bart Base"
19
  description = "This demo compares the [flan-t5-small-instructiongen](https://huggingface.co/pszemraj/flan-t5-small-instructiongen) and [bart-base-instructiongen](https://huggingface.co/pszemraj/bart-base-instructiongen) models on 'creating' an instruction for arbitrary text."
20
  article = """---
21
 
@@ -23,12 +23,16 @@ These models generate instructions for Large Language Models (LLMs) from arbitra
23
 
24
 
25
  def inference(text):
26
- output_flan_t5 = pipe_flan_t5(
27
- text, num_beams=2, early_stopping=True, max_length=100
28
- )[0]["generated_text"]
29
- output_bart_base = pipe_bart_base(
30
- text, num_beams=2, early_stopping=True, max_length=100
31
- )[0]["generated_text"]
 
 
 
 
32
  return [output_flan_t5, output_bart_base]
33
 
34
 
 
15
  "Start by setting a realistic goal and creating a training plan. Build up your mileage gradually over time, and incorporate cross-training and strength exercises to prevent injury and improve endurance. Be sure to stay hydrated and properly fuel your body with nutritious foods. Listen to your body and adjust your training as needed to avoid overexertion or burnout. Finally, taper your training in the weeks leading up to the race to give your body time to rest and recover before the big day.",
16
  ]
17
 
18
+ title = "InstructionGen: Instructions from Text"
19
  description = "This demo compares the [flan-t5-small-instructiongen](https://huggingface.co/pszemraj/flan-t5-small-instructiongen) and [bart-base-instructiongen](https://huggingface.co/pszemraj/bart-base-instructiongen) models on 'creating' an instruction for arbitrary text."
20
  article = """---
21
 
 
23
 
24
 
25
  def inference(text):
26
+ params = {
27
+ "num_beams": 2,
28
+ "early_stopping": True,
29
+ "max_length": 100,
30
+ "truncation": True,
31
+ }
32
+
33
+ output_flan_t5 = pipe_flan_t5(text, **params)[0]["generated_text"]
34
+ output_bart_base = pipe_bart_base(text, **params)[0]["generated_text"]
35
+
36
  return [output_flan_t5, output_bart_base]
37
 
38