vinayakdev commited on
Commit
1aa8621
1 Parent(s): d4cef87

Update generator models

Browse files
Files changed (1) hide show
  1. generator.py +7 -5
generator.py CHANGED
@@ -24,7 +24,7 @@ import sentencepiece
24
  import string
25
  import numpy as np
26
  from transformers import pipeline
27
- from transformers.pipelines import AggregationStrategy
28
  import pickle
29
  import streamlit as st
30
 
@@ -35,7 +35,7 @@ import streamlit as st
35
  # hfmodel = pickle.load(open('models/hfmodel.sav', 'rb'))
36
 
37
  def load_model():
38
- hfm = pickle.load(open('hfmodel.sav','rb'))
39
  hft = T5TokenizerFast.from_pretrained("t5-base")
40
  tok = et.from_pretrained("mrm8488/electra-small-finetuned-squadv2")
41
  model = pickle.load(open('electra_model.sav','rb'))
@@ -48,9 +48,9 @@ def run_model(input_string, **generator_args):
48
  generator_args = {
49
  "max_length": 256,
50
  "num_beams": 4,
51
- "length_penalty": 1.5,
52
- "no_repeat_ngram_size": 3,
53
- "early_stopping": True,
54
  }
55
  # tokenizer = att.from_pretrained("ThomasSimonini/t5-end2end-question-generation")
56
  input_string = "generate questions: " + input_string + " </s>"
@@ -117,6 +117,8 @@ def creator(context):
117
  questions = create_string_for_generator(context)
118
  pairs = []
119
  for ques in questions:
 
 
120
  pair = QA(ques,context)
121
  pairs.append(pair)
122
  return pairs
 
24
  import string
25
  import numpy as np
26
  from transformers import pipeline
27
+ # from transformers.pipelines import pipeline
28
  import pickle
29
  import streamlit as st
30
 
 
35
  # hfmodel = pickle.load(open('models/hfmodel.sav', 'rb'))
36
 
37
  def load_model():
38
+ hfm = pickle.load(open('t5_model.sav','rb'))
39
  hft = T5TokenizerFast.from_pretrained("t5-base")
40
  tok = et.from_pretrained("mrm8488/electra-small-finetuned-squadv2")
41
  model = pickle.load(open('electra_model.sav','rb'))
 
48
  generator_args = {
49
  "max_length": 256,
50
  "num_beams": 4,
51
+ # "length_penalty": 1.5,
52
+ "no_repeat_ngram_size": 2,
53
+ "early_stopping": False,
54
  }
55
  # tokenizer = att.from_pretrained("ThomasSimonini/t5-end2end-question-generation")
56
  input_string = "generate questions: " + input_string + " </s>"
 
117
  questions = create_string_for_generator(context)
118
  pairs = []
119
  for ques in questions:
120
+ if ques[-1] != '?':
121
+ ques.append('?')
122
  pair = QA(ques,context)
123
  pairs.append(pair)
124
  return pairs