Zasso-75 commited on
Commit
88087e6
1 Parent(s): 99aef7d

Update model.py

Browse files
Files changed (1) hide show
  1. model.py +12 -10
model.py CHANGED
@@ -1,4 +1,4 @@
1
-
2
  from transformers import BertForQuestionAnswering
3
  model=BertForQuestionAnswering.from_pretrained("deepset/bert-base-cased-squad2")
4
  from transformers import AutoTokenizer
@@ -27,16 +27,18 @@ The average surface temperature of Earth is maintained by a balance of various f
27
 
28
  The amount of solar radiation absorbed by Earth’s surface is only a small fraction of the total solar radiation entering the atmosphere. For every 100 units of incoming solar radiation, roughly 30 units are reflected back to space by either clouds, the atmosphere, or reflective regions of Earth’s surface. This reflective capacity is referred to as Earth’s planetary albedo, and it need not remain fixed over time, since the spatial extent and distribution of reflective formations, such as clouds and ice cover, can change. The 70 units of solar radiation that are not reflected may be absorbed by the atmosphere, clouds, or the surface. In the absence of further complications, in order to maintain thermodynamic equilibrium, Earth’s surface and atmosphere must radiate these same 70 units back to space. Earth’s surface temperature (and that of the lower layer of the atmosphere essentially in contact with the surface) is tied to the magnitude of this emission of outgoing radiation according to the Stefan-Boltzmann law.""")
29
 
30
- print("hello")
31
- question=input()
32
- tokenizer.encode(question,truncation=True,padding=True)
33
- nlp=pipeline ("question-answering",model=model,tokenizer=tokenizer)
34
- output=nlp({
35
- 'question':question[0],
36
- 'context':context
37
- })
38
 
39
- print("model executed")
 
 
 
 
 
 
 
 
 
 
40
 
41
  """import pickle
42
  pickle.dump(nlp,open('nlp_model.pkl','wb'))"""
 
1
+ import streamlit as st
2
  from transformers import BertForQuestionAnswering
3
  model=BertForQuestionAnswering.from_pretrained("deepset/bert-base-cased-squad2")
4
  from transformers import AutoTokenizer
 
27
 
28
  The amount of solar radiation absorbed by Earth’s surface is only a small fraction of the total solar radiation entering the atmosphere. For every 100 units of incoming solar radiation, roughly 30 units are reflected back to space by either clouds, the atmosphere, or reflective regions of Earth’s surface. This reflective capacity is referred to as Earth’s planetary albedo, and it need not remain fixed over time, since the spatial extent and distribution of reflective formations, such as clouds and ice cover, can change. The 70 units of solar radiation that are not reflected may be absorbed by the atmosphere, clouds, or the surface. In the absence of further complications, in order to maintain thermodynamic equilibrium, Earth’s surface and atmosphere must radiate these same 70 units back to space. Earth’s surface temperature (and that of the lower layer of the atmosphere essentially in contact with the surface) is tied to the magnitude of this emission of outgoing radiation according to the Stefan-Boltzmann law.""")
29
 
 
 
 
 
 
 
 
 
30
 
31
+ question=st.text_area("enter question")
32
+ if text:
33
+ #tokenizer.encode(question,truncation=True,padding=True)
34
+ nlp=pipeline ("question-answering",model=model,tokenizer=tokenizer)
35
+ output=nlp({
36
+ 'question':question,
37
+ 'context':context
38
+ })
39
+ out=output['answer']
40
+ st.json(out)
41
+
42
 
43
  """import pickle
44
  pickle.dump(nlp,open('nlp_model.pkl','wb'))"""