Views
No views yet
pip install transformers1from transformers import BertTokenizerFast, BertForQuestionAnswering, pipeline
2import torch
3
4# Load the tokenizer and model
5tokenizer = BertTokenizerFast.from_pretrained('bert-large-uncased-whole-word-masking-finetuned-squad')
6model = BertForQuestionAnswering.from_pretrained('bert-large-uncased-whole-word-masking-finetuned-squad')
7
8# Define question-answering pipeline
9question_answerer = pipeline(
10 "question-answering",
11 model="fawez9/gilper",
12 tokenizer="fawez9/gilper",
13 device=0 if torch.cuda.is_available() else -1
14)
15
16# Example input
17question = "How many parameters does BLOOM have?"
18context = "BLOOM has 176 billion parameters and can generate text in 46 natural languages and 13 programming languages."
19
20# Get response
21response = question_answerer(question=question, context=context)
22print(response)1@misc{gilper2024,
2 title={Gilper: Fine-Tuned BERT Model for Question Answering},
3 author={Fawez},
4 year={2024},
5 publisher={Hugging Face},
6 howpublished={\url{https://huggingface.co/fawez9/gilper}}
7}