TheHickman commited on
Commit
8075d5e
·
verified ·
1 Parent(s): 2f164a7

Added Q&A

Browse files
Files changed (1) hide show
  1. app.py +33 -6
app.py CHANGED
@@ -200,17 +200,44 @@ QUESTION_ANSWER = f"""
200
  Answers to customer questions can be drawn from those documents.
201
  ⚡⚡ If you’d like to save inference time, you can first use <a href="https://huggingface.co/tasks/sentence-similarity">passage ranking</a> models to see which document might contain the answer to the question and iterate over that document with the QA model instead.
202
  </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  """
204
 
 
 
205
  # ---- Placeholder HTML pages ----
206
  TEXT_GENERATION_HTML = TEXT_GENERATION
207
 
208
- QUESTION_ANSWER_HTML = """
209
- <div style="max-width: 800px; margin: auto;">
210
- <h1>Question and Answer</h1>
211
- <p>Q&A content goes here...</p>
212
- </div>
213
- """
214
 
215
  SUMMARISATION_HTML = """
216
  <div style="max-width: 800px; margin: auto;">
 
200
  Answers to customer questions can be drawn from those documents.
201
  ⚡⚡ If you’d like to save inference time, you can first use <a href="https://huggingface.co/tasks/sentence-similarity">passage ranking</a> models to see which document might contain the answer to the question and iterate over that document with the QA model instead.
202
  </p>
203
+ <h2>Task Variants</h2>
204
+ <p>
205
+ There are different QA variants based on the inputs and outputs:
206
+ <ul>
207
+ <li><b>Extractive QA:</b> The model <b>extracts</b> the answer from a context.
208
+ The context here could be a provided text, a table or even HTML! This is usually solved with BERT-like models.</li>
209
+ <li><b>Open Generative QA:</b> The model <b>generates</b> free text directly based on the context.
210
+ You can learn more about the Text Generation task in its page.</li>
211
+ <li><b>Closed Generative QA:</b> In this case, no context is provided. The answer is completely generated by a model.</li>
212
+ </ul>
213
+ The schema above illustrates extractive, open book QA. The model takes a context and the question and extracts the answer from the given context.
214
+
215
+ You can also differentiate QA models depending on whether they are open-domain or closed-domain.
216
+ Open-domain models are not restricted to a specific domain, while closed-domain models are restricted to a specific domain (e.g. legal, medical documents).
217
+ </p>
218
+ <h2>Inference</h2>
219
+ <p>
220
+ You can infer with QA models with the 🤗 Transformers library using the question-answering pipeline.
221
+ If no model checkpoint is given, the pipeline will be initialized with distilbert-base-cased-distilled-squad.
222
+ This pipeline takes a question and a context from which the answer will be extracted and returned.
223
+ </p>
224
+ <pre style="background: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto;">
225
+ from transformers import pipeline
226
+
227
+ qa_model = pipeline("question-answering")
228
+ question = "Where do I live?"
229
+ context = "My name is Merve and I live in İstanbul."
230
+ qa_model(question = question, context = context)
231
+ ## {{'answer': 'İstanbul', 'end': 39, 'score': 0.953, 'start': 31}}
232
+ </pre>
233
  """
234
 
235
+ SUMMARISATION = ""
236
+
237
  # ---- Placeholder HTML pages ----
238
  TEXT_GENERATION_HTML = TEXT_GENERATION
239
 
240
+ QUESTION_ANSWER_HTML = QUESTION_ANSWER
 
 
 
 
 
241
 
242
  SUMMARISATION_HTML = """
243
  <div style="max-width: 800px; margin: auto;">