prabinpanta0/Rep00Zon
Viewer • Updated • 439 • 41 • 1
How to use prabinpanta0/ZenGQ with Transformers:
# Use a pipeline as a high-level helper
# Warning: Pipeline type "question-answering" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# pip install "transformers<5.0.0"
from transformers import pipeline
pipe = pipeline("question-answering", model="prabinpanta0/ZenGQ") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
tokenizer = AutoTokenizer.from_pretrained("prabinpanta0/ZenGQ")
model = AutoModelForQuestionAnswering.from_pretrained("prabinpanta0/ZenGQ", device_map="auto")This is a fine-tuned BERT model for question answering tasks, trained on a custom dataset.
from transformers import AutoTokenizer, AutoModelForQuestionAnswering, pipeline
# Load the tokenizer and model from Hugging Face
tokenizer = AutoTokenizer.from_pretrained("prabinpanta0/ZenGQ")
model = AutoModelForQuestionAnswering.from_pretrained("prabinpanta0/ZenGQ")
# Create a pipeline for question answering
qa_pipeline = pipeline("question-answering", model=model, tokenizer=tokenizer)
# Define your context and questions
contexts = ["Berlin is the capital of Germany.",
"Paris is the capital of France.",
"Madrid is the capital of Spain."]
questions = [
"What is the capital of Germany?",
"Which city is the capital of France?",
"What is the capital of Spain?"
]
# Get answers
for context, question in zip(contexts, questions):
result = qa_pipeline(question=question, context=context)
print(f"Question: {question}")
print(f"Answer: {result['answer']}\n")
text = "Berlin is the capital of Germany. Paris is the capital of France. Madrid is the capital of Spain."
tokens = tokenizer.tokenize(text)
print(tokens)
Output:
['berlin', 'is', 'the', 'capital', 'of', 'germany', '.', 'paris', 'is', 'the', 'capital', 'of', 'france', '.', 'madrid', 'is', 'the', 'capital', 'of', 'spain', '.']
The model was trained on the Rep00Zon dataset.
This model is licensed under the MIT License.