File size: 662 Bytes
ffe3c68
80fa8ee
 
 
ffe3c68
80fa8ee
 
ffe3c68
80fa8ee
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import streamlit as st
from datasets import load_dataset
from haystack import Document
from haystack.components.readers import ExtractiveReader

# Load the dataset
dataset = load_dataset("PedroCJardim/QASports", "basketball", split="validation")

# Load the model
reader = ExtractiveReader(model="laurafcamargos/distilbert-qasports-basket-small")
reader.warm_up()

# Running using the Reader
docs = [
    Document(content="Paris is the capital of France."),
    Document(content="Berlin is the capital of Germany.")
]

query = "What is the capital of France?"
answer = reader.run(query="What is the capital of France?", documents=docs, top_k=1)

st.json(answer)