metadata
license: apache-2.0
datasets:
- VenkatManda/KaggleQuestions
language:
- en
Kaggle Q&A Model Fine-tuned from GPT-2
Overview
This repository contains a question-answering (Q&A) model fine-tuned from OpenAI's GPT-2 on Kaggle data. The model is hosted on Hugging Face's model hub and can be easily used for various question-answering tasks.
Model Details
- Base Model: OpenAI's GPT-2
- Fine-tuned Dataset: Kaggle Q&A data
- Model Type: Transformer-based Language Model
- Framework: Hugging Face's Transformers Library
Usage
To use this model, follow these steps:
Install the
transformers
library by Hugging Face:pip install transformers
Load the model using its identifier:
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained("VenkatManda/KaggleQuestionsModelGPT2")
model = AutoModelForQuestionAnswering.from_pretrained("VenkatManda/KaggleQuestionsModelGPT2")
# Provide context and question
context = "Your context here"
question = "Your question here?"
# Tokenize input
inputs = tokenizer(question, context, return_tensors="pt")
# Perform inference
outputs = model(**inputs)
# Get answer
answer_start_scores = outputs.start_logits
answer_end_scores = outputs.end_logits
answer_start = torch.argmax(answer_start_scores)
answer_end = torch.argmax(answer_end_scores) + 1
answer = tokenizer.convert_tokens_to_string(tokenizer.convert_ids_to_tokens(inputs["input_ids"][0][answer_start:answer_end]))
print("Answer:", answer)
@article{venkat2024kagglegpt2qa,
title={Kaggle Q&A Model Fine-tuned from GPT-2},
author={Venkat},
journal={GitHub},
year={2024},
howpublished={\url{https://github.com/venkat/kaggle-gpt2-qa}}
}