This repository contains example notebooks demonstrating how to use the Contextual AI Platform for creating and deploying generative AI agents. The examples focus on implementing Retrieval-Augmented Generation (RAG) for financial use cases.
This repository includes two implementation approaches:
- Quick-start.ipynb: Get started fast!
- End-to-end-example.ipynb: A complete walkthrough of a use case from creation to tuning.
The examples can be completed in under 15 minutes (excluding model tuning). Each notebook is self-contained and includes detailed explanations for each step.
For comprehensive platform documentation, visit docs.contextual.ai
- Contextual AI Platform access
- Python 3.8+
- Python client
pip install --pre contextual-client
To use the notebooks, you will need an API key to securely access the API. To generate an API key, your admin can follow the process below:
- Log into your tenant at app.contextual.ai
- Click on "API Keys"
- Click on "Create API Key"
- Please keep your key in a secure place, and do not share it with anyone
These examples focus on creating a financial RAG agent that:
- Answers questions based on provided documents
- Avoids making forward-looking statements
- Handles financial data responsibly
- Provides accurate, document-based responses
Three data files are used in these notebooks, an ingested document, evaluation dataset, and a training dataset. These are toy datasets to illustrate the functionality of the platform.
-
Ingestion:
Apple.pdf
-
Evaluation:
eval_short.csv
-
Training:
fin_train.jsonl
To quickly get started running the notebook we reccomend using Google Colab. If you'd prefer to run it locally, you can run in VS Code following these steps:
-
📥 Clone this repository
git clone https://github.com/ContextualAI/examples cd examples/
-
🌎 Create a virtual environment:
python -m venv . && source bin/activate
-
📦 Install required dependencies
pip install -r requirements.txt
-
🎮 Open the notebook in VS Code, click on "Select Kernel" (top right) -> "Python Environments" and select the newly created
venv
environment: -
🔑 Set up your API credentials in the respective notebook
API_TOKEN = '...' # Replace with your actual API token