Skip to content

Document Indexing and RAG

In this tutorial, we'll demonstrate how RAG operations can be implemented in Pixeltable. In particular, we'll develop a RAG application that summarizes a collection of PDF documents and uses ChatGPT to answer questions about them.

Agents · Notebook · Updated

Colab runs it in your browser. If it calls a model provider, it asks for that provider's API key in a cell.

What it covers

  • Outline
  • Document Indexing
  • Querying
  • Incremental Updates

What it uses

Install
terminal
pip install pixeltable sentence-transformers tiktoken openai openpyxl
Environment variables it names
OPENAI_API_KEY
Pixeltable calls
document.document_splitter()openai.chat_completions()pxt.create_table()pxt.create_view()@pxt.query@pxt.udfinsert()add_embedding_index()similarity()add_computed_column()

A look at the code

rag-demo.ipynb
from pixeltable.functions.huggingface import sentence_transformer
chunks_t.add_embedding_index(
'text',
embedding=sentence_transformer.using(model_id='intfloat/e5-large-v2'),
)

One cell of the notebook, copied as it is. Open it in Colab for the rest.

Browse all 103