|
17 | 17 | "source": [
|
18 | 18 | "# Overview\n",
|
19 | 19 | "\n",
|
20 |
| - "In this tutorial, we'll use Feast to inject documents and structured data (i.e., features) into the context of an LLM (Large Language Model) to power a RAG Application (Retrieval Augmented Generation).\n", |
| 20 | + "In this tutorial, we'll use Feast to inject documents and structured data (i.e., features) into the context of an LLM (Large Language Model) to power a RAG Application (Retrieval Augmented Generation) with Milvus as the online vector database.\n", |
21 | 21 | "\n",
|
22 | 22 | "Feast solves several common issues in this flow:\n",
|
23 | 23 | "1. **Online retrieval:** At inference time, LLMs often need access to data that isn't readily \n",
|
24 | 24 | " available and needs to be precomputed from other data sources.\n",
|
25 | 25 | " * Feast manages deployment to a variety of online stores (e.g. Milvus, DynamoDB, Redis, Google Cloud Datastore) and \n",
|
26 | 26 | " ensures necessary features are consistently _available_ and _freshly computed_ at inference time.\n",
|
27 |
| - "2. **Vector Search:** Feast has built support for vector similarity search that is easily configured declaritively so users can focus on their application.\n", |
| 27 | + "2. **Vector Search:** Feast has built support for vector similarity search that is easily configured declaritively so users can focus on their application. Milvus provides powerful and efficient vector similarity search capabilities.\n", |
28 | 28 | "3. **Richer structured data:** Along with vector search, users can query standard structured fields to inject into the LLM context for better user experiences.\n",
|
29 | 29 | "4. **Feature/Context and versioning:** Different teams within an organization are often unable to reuse \n",
|
30 | 30 | " data across projects and services, resulting in duplicate application logic. Models have data dependencies that need \n",
|
|
33 | 33 | " data.\n",
|
34 | 34 | "\n",
|
35 | 35 | "We will:\n",
|
36 |
| - "1. Deploy a local feature store with a **Parquet file offline store** and **Sqlite online store**.\n", |
37 |
| - "2. Write/materialize the data (i.e., feature values) from the offline store (a parquet file) into the online store (Sqlite).\n", |
38 |
| - "3. Serve the features using the Feast SDK\n", |
| 36 | + "1. Deploy a local feature store with a **Parquet file offline store** and **Milvus online store**.\n", |
| 37 | + "2. Write/materialize the data (i.e., feature values) from the offline store (a parquet file) into the online store (Milvus).\n", |
| 38 | + "3. Serve the features using the Feast SDK with Milvus's vector search capabilities\n", |
39 | 39 | "4. Inject the document into the LLM's context to answer questions"
|
40 | 40 | ]
|
41 | 41 | },
|
|
68 | 68 | "\n",
|
69 | 69 | "A feature repository is a directory that contains the configuration of the feature store and individual features. This configuration is written as code (Python/YAML) and it's highly recommended that teams track it centrally using git. See [Feature Repository](https://docs.feast.dev/reference/feature-repository) for a detailed explanation of feature repositories.\n",
|
70 | 70 | "\n",
|
71 |
| - "The easiest way to create a new feature repository to use the `feast init` command. For this demo, you **do not** need to initialize a feast repo.\n", |
| 71 | + "The easiest way to create a new feature repository to use the `feast init` command in your terminal. For this RAG demo with Milvus, you **do not** need to initialize a feast repo. We have already provided a complete feature repository for you in the current directory (check `feature_repo`) with all the necessary Milvus configurations set up and ready to use.\n", |
72 | 72 | "\n",
|
73 | 73 | "\n",
|
74 | 74 | "### Demo data scenario \n",
|
75 |
| - "- We data from Wikipedia about states that we have embedded into sentence embeddings to be used for vector retrieval in a RAG application.\n", |
76 |
| - "- We want to generate predictions for driver satisfaction for the rest of the users so we can reach out to potentially dissatisfied users." |
77 |
| - ] |
78 |
| - }, |
79 |
| - { |
80 |
| - "cell_type": "raw", |
81 |
| - "id": "61dfdc9d8732d5a6", |
82 |
| - "metadata": {}, |
83 |
| - "source": [ |
84 |
| - "!feast init feature_repo" |
| 75 | + "- We're using Wikipedia summaries about cities that have been transformed into vector embeddings using a sentence transformer model. These embeddings enable semantic search capabilities in our RAG application.\n", |
| 76 | + "- Our goal is to retrieve the most relevant city information based on user queries, combining the power of Milvus' vector similarity search with Feast's feature management to provide accurate, contextual responses through an LLM." |
85 | 77 | ]
|
86 | 78 | },
|
87 | 79 | {
|
|
96 | 88 | "\n",
|
97 | 89 | "* `data/` contains raw demo parquet data\n",
|
98 | 90 | "* `example_repo.py` contains demo feature definitions\n",
|
99 |
| - "* `feature_store.yaml` contains a demo setup configuring where data sources are\n", |
| 91 | + "* `feature_store.yaml` contains a demo setup configuring where data sources are, including Milvus settings\n", |
100 | 92 | "* `test_workflow.py` showcases how to run all key Feast commands, including defining, retrieving, and pushing features.\n",
|
101 | 93 | " * You can run this with `python test_workflow.py`."
|
102 | 94 | ]
|
|
136 | 128 | "metadata": {},
|
137 | 129 | "source": [
|
138 | 130 | "### Step 2b: Inspecting the project configuration\n",
|
| 131 | + "\n", |
139 | 132 | "Let's inspect the setup of the project in `feature_store.yaml`. \n",
|
140 | 133 | "\n",
|
141 | 134 | "The key line defining the overall architecture of the feature store is the **provider**. \n",
|
|
145 | 138 | " values for serving). \n",
|
146 | 139 | "* The online store is a low latency store of the latest feature values (for powering real-time inference).\n",
|
147 | 140 | "\n",
|
| 141 | + "In this demo, we use the local provider with Parquet files for offline storage and **Milvus** for online storage\n", |
| 142 | + "\n", |
| 143 | + "Our Milvus configuration includes:\n", |
| 144 | + "* Vector search enabled with 384-dimensional embeddings\n", |
| 145 | + "* FLAT index type with COSINE similarity metric\n", |
| 146 | + "* Local storage path at data/online_store.db\n", |
| 147 | + "\n", |
| 148 | + "This setup enables efficient vector similarity search for our RAG application while maintaining Feast's feature management capabilities.\n", |
| 149 | + "\n", |
| 150 | + "\n", |
148 | 151 | "Valid values for `provider` in `feature_store.yaml` are:\n",
|
149 | 152 | "\n",
|
150 | 153 | "* local: use file source with Milvus Lite\n",
|
|
153 | 156 | "\n",
|
154 | 157 | "Note that there are many other offline / online stores Feast works with, including Azure, Hive, Trino, and PostgreSQL via community plugins. See https://docs.feast.dev/roadmap for all supported connectors.\n",
|
155 | 158 | "\n",
|
156 |
| - "A custom setup can also be made by following [Customizing Feast](https://docs.feast.dev/v/master/how-to-guides/customizing-feast)" |
| 159 | + "A custom setup can also be made by following [Customizing Feast](https://docs.feast.dev/v/master/how-to-guides/customizing-feast)\n", |
| 160 | + "\n", |
| 161 | + "\n" |
157 | 162 | ]
|
158 | 163 | },
|
159 | 164 | {
|
160 | 165 | "cell_type": "code",
|
161 |
| - "execution_count": 2, |
| 166 | + "execution_count": 5, |
162 | 167 | "id": "14c830ef-f5a4-4867-ad5c-87e709df7057",
|
163 | 168 | "metadata": {},
|
164 | 169 | "outputs": [
|
|
174 | 179 | "\u001b[37m \u001b[39;49;00m\u001b[94mpath\u001b[39;49;00m:\u001b[37m \u001b[39;49;00mdata/online_store.db\u001b[37m\u001b[39;49;00m\n",
|
175 | 180 | "\u001b[37m \u001b[39;49;00m\u001b[94mvector_enabled\u001b[39;49;00m:\u001b[37m \u001b[39;49;00mtrue\u001b[37m\u001b[39;49;00m\n",
|
176 | 181 | "\u001b[37m \u001b[39;49;00m\u001b[94membedding_dim\u001b[39;49;00m:\u001b[37m \u001b[39;49;00m384\u001b[37m\u001b[39;49;00m\n",
|
177 |
| - "\u001b[37m \u001b[39;49;00m\u001b[94mindex_type\u001b[39;49;00m:\u001b[37m \u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m\u001b[33mIVF_FLAT\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", |
| 182 | + "\u001b[37m \u001b[39;49;00m\u001b[94mindex_type\u001b[39;49;00m:\u001b[37m \u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m\u001b[33mFLAT\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", |
| 183 | + "\u001b[37m \u001b[39;49;00m\u001b[94mmetric_type\u001b[39;49;00m:\u001b[37m \u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m\u001b[33mCOSINE\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", |
178 | 184 | "\u001b[37m\u001b[39;49;00m\n",
|
179 | 185 | "\u001b[37m\u001b[39;49;00m\n",
|
180 | 186 | "\u001b[94moffline_store\u001b[39;49;00m:\u001b[37m\u001b[39;49;00m\n",
|
|
424 | 430 | "metadata": {},
|
425 | 431 | "source": [
|
426 | 432 | "### Step 3b: Applying feature definitions\n",
|
427 |
| - "Now we run `feast apply` to register the feature views and entities defined in `example_repo.py`, and sets up SQLite online store tables. Note that we had previously specified SQLite as the online store in `feature_store.yaml` by specifying a `local` provider." |
| 433 | + "Now we run `feast apply` to register the feature views and entities defined in `example_repo.py`, and sets up Milvus online store tables. Note that we had previously specified Milvus as the online store in `feature_store.yaml` by specifying a `local` provider." |
428 | 434 | ]
|
429 | 435 | },
|
430 | 436 | {
|
|
1001 | 1007 | ],
|
1002 | 1008 | "metadata": {
|
1003 | 1009 | "kernelspec": {
|
1004 |
| - "display_name": "Python 3 (ipykernel)", |
| 1010 | + "display_name": "feast", |
1005 | 1011 | "language": "python",
|
1006 | 1012 | "name": "python3"
|
1007 | 1013 | },
|
|
1015 | 1021 | "name": "python",
|
1016 | 1022 | "nbconvert_exporter": "python",
|
1017 | 1023 | "pygments_lexer": "ipython3",
|
1018 |
| - "version": "3.11.10" |
| 1024 | + "version": "3.11.11" |
1019 | 1025 | }
|
1020 | 1026 | },
|
1021 | 1027 | "nbformat": 4,
|
|
0 commit comments