alyxx commited on
Commit
be4dba2
·
1 Parent(s): 720c9e9

edit app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -1,20 +1,36 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
 
4
  question_answerer = pipeline("question-answering",
5
  model='kaiku03/Q-andA-bert-finetuned-squad-accelerate',
6
  tokenizer='kaiku03/Q-andA-bert-finetuned-squad-accelerate')
7
 
 
8
  examples = [
9
- ["The capital of France is Paris.", "What is the capital of France?"],
 
 
 
 
 
 
 
 
 
10
  ["J.K. Rowling is the author of Harry Potter books.", "Who is the author of Harry Potter?"],
11
  ["The largest mammal is the blue whale.", "What is the largest mammal?"]
12
  ]
13
 
14
- interface = gr.Interface.from_pipeline(question_answerer,
15
- title='Question Answering demo with transformers and gradio',
 
 
16
  theme="peach",
17
  description='Enter a context and a related question, and this demo will provide an answer.',
18
  article='This demo was trained on the SQuAD dataset using only 5% of the training data and 2% of the validation data for the sake of speed',
19
-
20
- examples=examples).launch()
 
 
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load the question-answering pipeline
5
  question_answerer = pipeline("question-answering",
6
  model='kaiku03/Q-andA-bert-finetuned-squad-accelerate',
7
  tokenizer='kaiku03/Q-andA-bert-finetuned-squad-accelerate')
8
 
9
+ # Example contexts and questions
10
  examples = [
11
+ ['''Statistics is the branch of mathematics that deals with the collection, analysis, interpretation, presentation, and organization of data. Here are the key components:
12
+ Descriptive Statistics: These summarize and describe the features of a dataset. Key tools include:
13
+ Measures of Central Tendency: Mean (average), median (middle value), and mode (most frequent value).
14
+ Measures of Spread: Range (difference between highest and lowest values), variance (average squared deviation from the mean), and standard deviation (square root of variance).
15
+ Graphs and Charts: Histograms, bar charts, pie charts, and box plots.
16
+ Inferential Statistics: These make predictions or inferences about a population based on a sample of data. Key concepts include:
17
+ Hypothesis Testing: A method for testing a claim or hypothesis about a parameter in a population, using sample data.
18
+ Confidence Intervals: A range of values, derived from the sample, that is likely to contain the value of an unknown population parameter.
19
+ Regression Analysis: A statistical process for estimating the relationships among variables.''',
20
+ "What do you call the statistical process for estimating the relationships among variables?"],
21
  ["J.K. Rowling is the author of Harry Potter books.", "Who is the author of Harry Potter?"],
22
  ["The largest mammal is the blue whale.", "What is the largest mammal?"]
23
  ]
24
 
25
+ # Create and launch the Gradio interface
26
+ interface = gr.Interface.from_pipeline(
27
+ question_answerer,
28
+ title='Question Answering Demo with Transformers and Gradio',
29
  theme="peach",
30
  description='Enter a context and a related question, and this demo will provide an answer.',
31
  article='This demo was trained on the SQuAD dataset using only 5% of the training data and 2% of the validation data for the sake of speed',
32
+ examples=examples
33
+ )
34
+
35
+ # Launch the interface with share enabled
36
+ interface.launch(share=False)