prabinpanta0
commited on
Commit
•
56bb402
1
Parent(s):
e7bf5a3
Update README.md
Browse files
README.md
CHANGED
@@ -29,15 +29,17 @@ This is a fine-tuned BERT model for question answering tasks, trained on a custo
|
|
29 |
```python
|
30 |
from transformers import AutoTokenizer, AutoModelForQuestionAnswering, pipeline
|
31 |
|
32 |
-
# Load
|
33 |
-
tokenizer = AutoTokenizer.from_pretrained("
|
34 |
-
model = AutoModelForQuestionAnswering.from_pretrained("
|
35 |
|
36 |
# Create a pipeline for question answering
|
37 |
qa_pipeline = pipeline("question-answering", model=model, tokenizer=tokenizer)
|
38 |
|
39 |
# Define your context and questions
|
40 |
-
|
|
|
|
|
41 |
questions = [
|
42 |
"What is the capital of Germany?",
|
43 |
"Which city is the capital of France?",
|
@@ -45,7 +47,7 @@ questions = [
|
|
45 |
]
|
46 |
|
47 |
# Get answers
|
48 |
-
for question in questions:
|
49 |
result = qa_pipeline(question=question, context=context)
|
50 |
print(f"Question: {question}")
|
51 |
print(f"Answer: {result['answer']}\n")
|
|
|
29 |
```python
|
30 |
from transformers import AutoTokenizer, AutoModelForQuestionAnswering, pipeline
|
31 |
|
32 |
+
# Load the tokenizer and model from Hugging Face
|
33 |
+
tokenizer = AutoTokenizer.from_pretrained("prabinpanta0/ZenGQ")
|
34 |
+
model = AutoModelForQuestionAnswering.from_pretrained("prabinpanta0/ZenGQ")
|
35 |
|
36 |
# Create a pipeline for question answering
|
37 |
qa_pipeline = pipeline("question-answering", model=model, tokenizer=tokenizer)
|
38 |
|
39 |
# Define your context and questions
|
40 |
+
contexts = ["Berlin is the capital of Germany.",
|
41 |
+
"Paris is the capital of France.",
|
42 |
+
"Madrid is the capital of Spain."]
|
43 |
questions = [
|
44 |
"What is the capital of Germany?",
|
45 |
"Which city is the capital of France?",
|
|
|
47 |
]
|
48 |
|
49 |
# Get answers
|
50 |
+
for context, question in zip(contexts, questions):
|
51 |
result = qa_pipeline(question=question, context=context)
|
52 |
print(f"Question: {question}")
|
53 |
print(f"Answer: {result['answer']}\n")
|