This example should hopefully answer your question.

  

      github.com
  

  
    huggingface/transformers/blob/master/examples/pytorch/question-answering/run_qa.py 5


    #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Team All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Fine-tuning the library models for question answering.
"""
# You can also adapt this script on your own question answering task. Pointers for this are left as comments.




  This file has been truncated. show original

  

  
    
    
  

  


If the purpose is to have a good question answering model, you could also use one of the many pretrained models on the hugging face model hub. Models - Hugging Face 1