Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5fdb79b
feat: Adding Docling RAG demo
franciscojavierarceo Mar 1, 2025
9a2e8a6
updated demo
franciscojavierarceo Mar 2, 2025
d3af45d
cleaned up notebook
franciscojavierarceo Mar 2, 2025
caba9e9
adding chunk id
franciscojavierarceo Mar 2, 2025
2b5f622
adding quickstart demo that is WIP and updating docling-demo to expor…
franciscojavierarceo Mar 2, 2025
092184c
adding current tentative exmaple repo
franciscojavierarceo Mar 2, 2025
c032c7d
adding current temporary work
franciscojavierarceo Mar 2, 2025
f234bcb
updating demo script to rename things
franciscojavierarceo Mar 3, 2025
37debb0
updated quickstart
franciscojavierarceo Mar 3, 2025
bcc4d10
added comment
franciscojavierarceo Mar 3, 2025
24e8cb8
checking in progress
franciscojavierarceo Mar 6, 2025
4fc74de
checking in progress for now, still have some issues with vector retr…
franciscojavierarceo Mar 7, 2025
afc2bb6
okay think i have most things working
franciscojavierarceo Mar 8, 2025
79cb8e1
removing commenting and unnecessary code
franciscojavierarceo Mar 9, 2025
267b740
uploading demo
franciscojavierarceo Mar 17, 2025
5ba452e
uploading other files
franciscojavierarceo Mar 23, 2025
1953f86
updated repo exaxmple
franciscojavierarceo Mar 27, 2025
a929cae
checking in current notebook, almost there
franciscojavierarceo Mar 27, 2025
61a1fdf
fixed linter
franciscojavierarceo Mar 27, 2025
62f2ed3
fixed transformation logic:
franciscojavierarceo Apr 1, 2025
e829840
removed print
franciscojavierarceo Apr 1, 2025
e12731a
added README with description
franciscojavierarceo Apr 2, 2025
18251ce
removing print
franciscojavierarceo Apr 2, 2025
20e5ab2
updating
franciscojavierarceo Apr 2, 2025
ccc4be3
updating metadata file
franciscojavierarceo Apr 2, 2025
bacee11
updated readme and adding dataset
franciscojavierarceo Apr 2, 2025
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
Prev Previous commit
Next Next commit
uploading other files
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
  • Loading branch information
franciscojavierarceo committed Mar 23, 2025
commit 5ba452e9e4d5548c4b49e33bf373f65a40d44cde
87 changes: 87 additions & 0 deletions examples/rag-docling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# 🚀 Quickstart: Retrieval-Augmented Generation (RAG) using Feast and Large Language Models (LLMs)

This project demonstrates how to use **Feast** to power a **Retrieval-Augmented Generation (RAG)** application.
The RAG architecture combines retrieval of documents (using vector search) with In-Context-Learning (ICL) through a
**Large Language Model (LLM)** to answer user questions accurately using structured and unstructured data.

## 💡 Why Use Feast for RAG?

- **Online retrieval of features:** Ensure real-time access to precomputed document embeddings and other structured data.
- **Declarative feature definitions:** Define feature views and entities in a Python file and empower Data Scientists to easily ship scalabe RAG applications with all of the existing benefits of Feast.
- **Vector search:** Leverage Feast’s integration with vector databases like **Milvus** to find relevant documents based on a similarity metric (e.g., cosine).
- **Structured and unstructured context:** Retrieve both embeddings and traditional features, injecting richer context into LLM prompts.
- **Versioning and reusability:** Collaborate across teams with discoverable, versioned data pipelines.

---

## 📂 Project Structure

- **`data/`**: Contains the demo data, including Wikipedia summaries of cities with sentence embeddings stored in a Parquet file.
- **`example_repo.py`**: Defines the feature views and entity configurations for Feast.
- **`feature_store.yaml`**: Configures the offline and online stores (using local files and Milvus Lite in this demo).
- **`test_workflow.py`**: Demonstrates key Feast commands to define, retrieve, and push features.

---

## 🛠️ Setup

1. **Install the necessary packages**:
```bash
pip install feast torch transformers sentence_transformers openai
```
2. Initialize and inspect the feature store:

```bash
feast apply
```

3. Materialize features into the online store:

```python
store.write_to_online_store(feature_view_name='city_embeddings', df=df)
```
4. Run a query:

- Prepare your question:
`question = "Which city has the largest population in New York?"`
- Embed the question using sentence-transformers/all-MiniLM-L6-v2.
- Retrieve the top K most relevant documents using Milvus vector search.
- Pass the retrieved context to the OpenAI model for conversational output.

## 🛠️ Key Commands for Data Scientists
- Apply feature definitions:

```bash
feast apply
```

- Materialize features to the online store:
```python
store.write_to_online_store(feature_view_name='city_embeddings', df=df)
```

- Inspect retrieved features using Python:
```python
context_data = store.retrieve_online_documents_v2(
features=[
"city_embeddings:vector",
"city_embeddings:item_id",
"city_embeddings:state",
"city_embeddings:sentence_chunks",
"city_embeddings:wiki_summary",
],
query=query,
top_k=3,
distance_metric='COSINE',
).to_df()
display(context_data)
```

📊 Example Output
When querying: Which city has the largest population in New York?

The model provides:

```
The largest city in New York is New York City, often referred to as NYC. It is the most populous city in the United States, with an estimated population of 8,335,897 in 2022.
```
20 changes: 20 additions & 0 deletions examples/rag-docling/feature_repo/feature_store.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
project: rag
provider: local
registry: data/registry.db
online_store:
type: sqlite
path: data/online_store.db
vector_enabled: true
vector_len: 384
# type: milvus
# path: data/online_store.db
# embedding_dim: 384
# index_type: "IVF_FLAT"


offline_store:
type: file
entity_key_serialization_version: 3
# By default, no_auth for authentication and authorization, other possible values kubernetes and oidc. Refer the documentation for more details.
auth:
type: no_auth
Loading