Skip to content

Instantly share code, notes, and snippets.

@davidmezzetti
Created September 30, 2024 17:56
Show Gist options
  • Save davidmezzetti/66d57c1c076526931a71caec37acb7b1 to your computer and use it in GitHub Desktop.
Save davidmezzetti/66d57c1c076526931a71caec37acb7b1 to your computer and use it in GitHub Desktop.
from txtai import Embeddings, RAG
# Load embeddings index
embeddings = Embeddings()
embeddings.load(provider="huggingface-hub", container="neuml/txtai-wikipedia")
template = """
Answer the following question using the provided context.
Question:
{question}
Context:
{context}
Answer:
"""
# Create and run pipeline
rag = RAG(
embeddings,
"hugging-quants/Llama-3.2-1B-Instruct-Q4_K_M-GGUF/llama-3.2-1b-instruct-q4_k_m.gguf",
template=template
)
rag("Tell me about Mars in a short sentence")["answer"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment