readme: ---
  pipeline_tag: question-answering
  tags:
  - feature-extraction
  language:
  - en
  license: afl-3.0
  ---
  
  [Extractive Question Answering application.](https://raphaelsty.github.io/blog/template/)
  
  ```python
  import re
  
  from transformers import pipeline
  
  qa = pipeline(
      "question-answering", model="raphaelsty/carbonblog", tokenizer="raphaelsty/carbonblog"
  )
  
  def clean(document):
      """Pre-process the document."""
      document = re.sub("[^a-zA-Z0-9 \n\.]", " ", document)
      document = re.sub("\s\s+", " ", document)
      # [NONE] allows the model to handle missing components.
      document = f"[NONE] {document.lower()}"
      return document
  ```
  
  ```python
  document = clean("body: 83% nylon 17% spandex; lace: 86% nylon 14% spandex")
  ```
  
  ```python
  qa({"question": "What is the 1 component ?", "context": document})
  ```
  
  ```json
  {"score": 0.9999976754188538, "start": 32, "end": 36, "answer": "lace"}
  ```
  
  
  