mohamedemam commited on
Commit
b130785
1 Parent(s): 2ca526b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -5,7 +5,16 @@ import re
5
  model_name = "mohamedemam/QA_GeneraToR"
6
  tokenizer = AutoTokenizer.from_pretrained(model_name)
7
  model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
 
 
8
 
 
 
 
 
 
 
 
9
  # Recommended words for users to choose from
10
  recommended_words = [
11
  "which", "how", "when", "where", "who", "whom", "whose", "why",
@@ -15,15 +24,6 @@ recommended_words = [
15
  ]
16
 
17
  # Example contexts
18
- example_contexts = [
19
- "when: Lionel Andrés Messi...",
20
- "where: Lionel Andrés Messi...",
21
- "how: Lionel Andrés Messi...",
22
- "what: Lionel Andrés Messi...",
23
- "where: Egypt...",
24
- "where: There is evidence..."
25
- # Add more examples here
26
- ]
27
 
28
  # Function to generate questions and answers with configurable parameters
29
  def generate_qa(context, recommended_word, temperature, top_p,num_seq, num_samples=3):
 
5
  model_name = "mohamedemam/QA_GeneraToR"
6
  tokenizer = AutoTokenizer.from_pretrained(model_name)
7
  model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
8
+ model.eval()
9
+ import wikipediaapi
10
 
11
+
12
+ # Create a Wikipedia API instance
13
+ wiki_wiki = wikipediaapi.Wikipedia('MyProjectName (merlin@example.com)', 'en')
14
+ page_py = wiki_wiki.page('Leo messi')
15
+ example_contexts=page_py.text.split(f"\n")
16
+ for i in range(len(example_contexts)):
17
+ example_contexts[i]=re.sub(f'\n'," ", example_contexts[i])
18
  # Recommended words for users to choose from
19
  recommended_words = [
20
  "which", "how", "when", "where", "who", "whom", "whose", "why",
 
24
  ]
25
 
26
  # Example contexts
 
 
 
 
 
 
 
 
 
27
 
28
  # Function to generate questions and answers with configurable parameters
29
  def generate_qa(context, recommended_word, temperature, top_p,num_seq, num_samples=3):