File size: 1,801 Bytes
fb1561b
 
f5f2caf
 
 
 
c464522
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
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:

1. Install the `transformers` library by Hugging Face:

   ```bash
   pip install transformers
   
# Load the model using its identifier:

  ```bash
  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}}
}