Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions 15-metadata-intro/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Metadata Management in Contextual AI

A comprehensive notebook demonstrating how to add, configure, and utilize metadata within the Contextual AI Platform for enhanced document retrieval and filtering. Learn to organize documents with rich metadata, apply precise filters, and leverage metadata in reranking and generation.

## 📋 Overview

This example showcases how to implement advanced metadata management for RAG systems that can:

1. **Configure Metadata at Ingest Time** with flexible field settings and configurations
2. **Update Metadata Post-Processing** for dynamic document organization
3. **Apply Precise Document Filters** using multiple operators and complex logic
4. **Enhance Retrieval Quality** through metadata-based filtering and reranking
5. **Leverage Metadata in Generation** for contextually aware responses

## 🗂️ Project Structure

```
📁 Metadata Management/
├── 📁 data/ # Sample policy documents
│ ├── 📄 POL_EU-v3.md # EU refund policy document
│ ├── 📄 POL_US-v2.md # US refund policy document
│ ├── 📄 KB_Template_US.md # US customer email template
│ ├── 📄 KB_Template_EU.md # EU customer email template
│ └── 📄 KB_Template_DE.md # German customer template
├── 📓 metadata_intro.ipynb # Main metadata notebook
└── 📄 README.md # This file
```

## 🚀 Quick Start

### Prerequisites
- **API Key:** Contextual AI API key from your workspace dashboard
- **Python Environment:** Google Colab or Jupyter with internet access
- **Python Client:** Version 0.8.0 or higher required

### Run on Google Colab
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ContextualAI/examples/blob/main/15-metadata-intro/metadata_intro.ipynb)


## 📚 Related Examples

- 🔗 **RAG Agent Monitoring**: [14-monitoring](../14-monitoring/)
- 🔗 **Retrieval Analysis**: [11-retrieval-analysis](../11-retrieval-analysis/)
- 🔗 **Policy Change Management**: [05-policy-changes](../05-policy-changes/)
- 🔗 **Agent Performance**: [06-improve-agent-performance](../06-improve-agent-performance/)

## 📖 Additional Resources

- **Contextual AI Documentation**: [docs.contextual.ai](https://docs.contextual.ai/)
- **Metadata API Reference**: [API Documentation](https://docs.contextual.ai/api-reference/datastores-documents/get-document-metadata)
- **Best Practices Guide**: [Metadata Management](https://docs.contextual.ai/user-guides/beginner-guide)

3 changes: 3 additions & 0 deletions 15-metadata-intro/data/KB_Template_DE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# KB — Customer email template (DE)

Localized template for customer emails for Germany / Deutschland. Sehr geehrte Kundin, sehr geehrter Kunde, vielen Dank für Ihren Einkauf bei uns. Für Produkte, die in Deutschland erworben wurden, gilt eine gesetzliche Gewährleistung von 24 Monaten. Darüber hinaus können Sie innerhalb von 30 Tagen nach Lieferung eine Rückerstattung beantragen.
3 changes: 3 additions & 0 deletions 15-metadata-intro/data/KB_Template_EU.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# KB — Customer email template (EU)

Localized template for customer emails for European Union. Subject: Your refund and warranty information Dear Customer, Thank you for your purchase. For products purchased in the European Union: You may request a refund within 30 days of delivery. Digital goods are refundable only if they have not been used or downloaded. Warranty coverage is provided according to EU consumer law.
3 changes: 3 additions & 0 deletions 15-metadata-intro/data/KB_Template_US.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# KB — Customer email template (US)

Localized template for customer emails for United States Dear Customer, Thank you for shopping with us. For products purchased in the United States: Refunds are available for 30 days on physical goods. Refunds for digital goods are limited to 14 days and only if the product has not been activated. Subscriptions are generally non-refundable once started.
3 changes: 3 additions & 0 deletions 15-metadata-intro/data/POL_EU-v3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Refund Policy EU v3

EU customers: refunds within 30 days. Digital goods only if unused.
3 changes: 3 additions & 0 deletions 15-metadata-intro/data/POL_US-v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Refund Policy US v2

US customers: refunds within 14 days. Subscriptions non-refundable.
Loading
Loading