First define your Embeddings and LLM

Define RAG

from txtai import Embeddings, RAG

# Create RAG instance
rag = RAG(embeddings, api)

Load your dataset

data = ["Giants hit 3 HRs to down Dodgers",
        "Giants 5 Dodgers 4 final",
        "Dodgers drop Game 2 against the Giants, 5-4",
        "Blue Jays beat Red Sox final score 2-1",
        "Red Sox lost to the Blue Jays, 2-1",
        "Blue Jays at Red Sox is over. Score: 2-1",
        "Phillies win over the Braves, 5-0",
        "Phillies 5 Braves 0 final",
        "Final: Braves lose to the Phillies in the series opener, 5-0",
        "Lightning goaltender pulled, lose to Flyers 4-1",
        "Flyers 4 Lightning 1 final",
        "Flyers win 4-1"]

Ask your query

rag([("answer", query, get_prompt("What team won the game?"), False)], data)

[('answer', 'The Flyers won the game.')]