Spaces:
Sleeping
Sleeping
Added Q&A
Browse files199 unmodified lines200201202203204205206207208209210211212213214215216199 unmodified linesAnswers to customer questions can be drawn from those documents.⚡⚡ 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.</p>"""# ---- Placeholder HTML pages ----TEXT_GENERATION_HTML = TEXT_GENERATIONQUESTION_ANSWER_HTML = """<div style="max-width: 800px; margin: auto;"><h1>Question and Answer</h1><p>Q&A content goes here...</p></div>"""SUMMARISATION_HTML = """<div style="max-width: 800px; margin: auto;">199 unmodified lines200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243199 unmodified linesAnswers to customer questions can be drawn from those documents.⚡⚡ 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.</p><h2>Task Variants</h2><p>There are different QA variants based on the inputs and outputs:<ul><li><b>Extractive QA:</b> The model <b>extracts</b> the answer from a context.The context here could be a provided text, a table or even HTML! This is usually solved with BERT-like models.</li><li><b>Open Generative QA:</b> The model <b>generates</b> free text directly based on the context.You can learn more about the Text Generation task in its page.</li><li><b>Closed Generative QA:</b> In this case, no context is provided. The answer is completely generated by a model.</li></ul>The schema above illustrates extractive, open book QA. The model takes a context and the question and extracts the answer from the given context.You can also differentiate QA models depending on whether they are open-domain or closed-domain.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).</p><h2>Inference</h2><p>You can infer with QA models with the 🤗 Transformers library using the question-answering pipeline.If no model checkpoint is given, the pipeline will be initialized with distilbert-base-cased-distilled-squad.This pipeline takes a question and a context from which the answer will be extracted and returned.</p><pre style="background: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto;">from transformers import pipelineqa_model = pipeline("question-answering")question = "Where do I live?"context = "My name is Merve and I live in İstanbul."qa_model(question = question, context = context)## {{'answer': 'İstanbul', 'end': 39, 'score': 0.953, 'start': 31}}</pre>"""SUMMARISATION = ""# ---- Placeholder HTML pages ----TEXT_GENERATION_HTML = TEXT_GENERATIONQUESTION_ANSWER_HTML = QUESTION_ANSWERSUMMARISATION_HTML = """<div style="max-width: 800px; margin: auto;">
app.py+33-6