tlkh commited on
Commit
8f83cc7
·
1 Parent(s): 529f20b

add max length

Browse files
Files changed (2) hide show
  1. .ipynb_checkpoints/app-checkpoint.py +7 -10
  2. app.py +7 -10
.ipynb_checkpoints/app-checkpoint.py CHANGED
@@ -13,29 +13,26 @@ def query(payload):
13
 
14
  def infer(s1, s2):
15
  model_input = "Classify and explain the relationship between this pair of sentences: <S1> "+s1+" </S1><S2> "+s2+" </S2>"
16
- data = query(model_input)
 
 
 
17
 
18
  if "error" in data:
19
  return "Error: "+ data["error"]
20
  elif "generated_text" in data[0]:
21
- return data[0]["generated_text"]
 
22
  else:
23
  return data
24
 
25
  title = "Paraphrase Classification and Explanation"
26
  desc = "Classify and explain the semantic relationship between the two sentences"
27
- long_desc = "This is a Flan-T5-Large model fine-tuned to perform paraphrase classification and explanation. It takes in two sentences as inputs."
28
 
29
  s1 = gr.Textbox(value="On Monday, Tom went to the market.",label="Sentence 1")
30
  s2 = gr.Textbox(value="Tom went to the market.",label="Sentence 2")
31
 
32
- examples = gr.Examples(
33
- examples=[
34
- ["one", "two"],
35
- ],
36
- inputs=[s1, s2],
37
- )
38
-
39
  demo = gr.Interface(fn=infer, inputs=[s1,s2], outputs="text",
40
  title=title,
41
  description=desc,
 
13
 
14
  def infer(s1, s2):
15
  model_input = "Classify and explain the relationship between this pair of sentences: <S1> "+s1+" </S1><S2> "+s2+" </S2>"
16
+ data = query({
17
+ "inputs": model_input,
18
+ "parameters": {"max_length": 128},
19
+ })
20
 
21
  if "error" in data:
22
  return "Error: "+ data["error"]
23
  elif "generated_text" in data[0]:
24
+ output = data[0]["generated_text"].replace(" ; ", "\n")
25
+ return output
26
  else:
27
  return data
28
 
29
  title = "Paraphrase Classification and Explanation"
30
  desc = "Classify and explain the semantic relationship between the two sentences"
31
+ long_desc = "This is a Flan-T5-Large model fine-tuned to perform paraphrase classification and explanation. It takes in two sentences as inputs. Feel free to modify the example inputs or enter in your own sentences."
32
 
33
  s1 = gr.Textbox(value="On Monday, Tom went to the market.",label="Sentence 1")
34
  s2 = gr.Textbox(value="Tom went to the market.",label="Sentence 2")
35
 
 
 
 
 
 
 
 
36
  demo = gr.Interface(fn=infer, inputs=[s1,s2], outputs="text",
37
  title=title,
38
  description=desc,
app.py CHANGED
@@ -13,29 +13,26 @@ def query(payload):
13
 
14
  def infer(s1, s2):
15
  model_input = "Classify and explain the relationship between this pair of sentences: <S1> "+s1+" </S1><S2> "+s2+" </S2>"
16
- data = query(model_input)
 
 
 
17
 
18
  if "error" in data:
19
  return "Error: "+ data["error"]
20
  elif "generated_text" in data[0]:
21
- return data[0]["generated_text"]
 
22
  else:
23
  return data
24
 
25
  title = "Paraphrase Classification and Explanation"
26
  desc = "Classify and explain the semantic relationship between the two sentences"
27
- long_desc = "This is a Flan-T5-Large model fine-tuned to perform paraphrase classification and explanation. It takes in two sentences as inputs."
28
 
29
  s1 = gr.Textbox(value="On Monday, Tom went to the market.",label="Sentence 1")
30
  s2 = gr.Textbox(value="Tom went to the market.",label="Sentence 2")
31
 
32
- examples = gr.Examples(
33
- examples=[
34
- ["one", "two"],
35
- ],
36
- inputs=[s1, s2],
37
- )
38
-
39
  demo = gr.Interface(fn=infer, inputs=[s1,s2], outputs="text",
40
  title=title,
41
  description=desc,
 
13
 
14
  def infer(s1, s2):
15
  model_input = "Classify and explain the relationship between this pair of sentences: <S1> "+s1+" </S1><S2> "+s2+" </S2>"
16
+ data = query({
17
+ "inputs": model_input,
18
+ "parameters": {"max_length": 128},
19
+ })
20
 
21
  if "error" in data:
22
  return "Error: "+ data["error"]
23
  elif "generated_text" in data[0]:
24
+ output = data[0]["generated_text"].replace(" ; ", "\n")
25
+ return output
26
  else:
27
  return data
28
 
29
  title = "Paraphrase Classification and Explanation"
30
  desc = "Classify and explain the semantic relationship between the two sentences"
31
+ long_desc = "This is a Flan-T5-Large model fine-tuned to perform paraphrase classification and explanation. It takes in two sentences as inputs. Feel free to modify the example inputs or enter in your own sentences."
32
 
33
  s1 = gr.Textbox(value="On Monday, Tom went to the market.",label="Sentence 1")
34
  s2 = gr.Textbox(value="Tom went to the market.",label="Sentence 2")
35
 
 
 
 
 
 
 
 
36
  demo = gr.Interface(fn=infer, inputs=[s1,s2], outputs="text",
37
  title=title,
38
  description=desc,