nguyennghia0902 commited on
Commit
12d5d83
1 Parent(s): 0f1e0e2

Update SampleQA.py

Browse files
Files changed (1) hide show
  1. SampleQA.py +14 -17
SampleQA.py CHANGED
@@ -5,7 +5,7 @@ import random
5
  from transformers import ElectraTokenizerFast, TFElectraForQuestionAnswering
6
  from datasets import Dataset, DatasetDict, load_dataset
7
 
8
- model_hf = "nguyennghia0902/bestfailed_electra-small-discriminator_5e-05_16"
9
  tokenizer = ElectraTokenizerFast.from_pretrained(model_hf)
10
  reload_model = TFElectraForQuestionAnswering.from_pretrained(model_hf)
11
 
@@ -31,33 +31,30 @@ def main():
31
 
32
  new_data = load_dataset("nguyennghia0902/project02_textming_dataset", data_files={'train': 'raw_newformat_data/traindata-00000-of-00001.arrow', 'test': 'raw_newformat_data/testdata-00000-of-00001.arrow'})
33
 
34
- sampleQ = ""
35
- sampleC = ""
36
- sampleA = ""
37
- if st.button("Sample"):
38
- sample = random.choice(new_data['test'])
39
- sampleQ = sample['question']
40
- sampleC = sample['context']
41
- sampleA = sample['answers']["text"][0]
42
 
43
- question = st.text_area(
44
- "Sample QUESTION: ",
45
- sampleQ,
46
- height=15,
47
- )
48
  text = st.text_area(
49
  "Sample CONTEXT:",
50
  sampleC,
51
- height=100,
52
  )
 
 
 
 
 
 
53
  answer = st.text_area(
54
  "True ANSWER:",
55
  sampleA,
56
- height=20,
57
  )
58
 
59
  # Create a prediction button
60
- if st.button("Predict"):
61
  prediction = ""
62
  prediction = predict(question, text)
63
  st.success(prediction)
 
5
  from transformers import ElectraTokenizerFast, TFElectraForQuestionAnswering
6
  from datasets import Dataset, DatasetDict, load_dataset
7
 
8
+ model_hf = "nguyennghia0902/electra-small-discriminator_0.0005_32"
9
  tokenizer = ElectraTokenizerFast.from_pretrained(model_hf)
10
  reload_model = TFElectraForQuestionAnswering.from_pretrained(model_hf)
11
 
 
31
 
32
  new_data = load_dataset("nguyennghia0902/project02_textming_dataset", data_files={'train': 'raw_newformat_data/traindata-00000-of-00001.arrow', 'test': 'raw_newformat_data/testdata-00000-of-00001.arrow'})
33
 
34
+ sample = random.choice(new_data['test'])
35
+ sampleQ = sample['question']
36
+ sampleC = sample['context']
37
+ sampleA = sample['answers']["text"][0]
 
 
 
 
38
 
 
 
 
 
 
39
  text = st.text_area(
40
  "Sample CONTEXT:",
41
  sampleC,
42
+ height=200,
43
  )
44
+ question = st.text_area(
45
+ "Sample QUESTION: ",
46
+ sampleQ,
47
+ height=5,
48
+ )
49
+
50
  answer = st.text_area(
51
  "True ANSWER:",
52
  sampleA,
53
+ height=5,
54
  )
55
 
56
  # Create a prediction button
57
+ if st.button("Sample & Predict"):
58
  prediction = ""
59
  prediction = predict(question, text)
60
  st.success(prediction)