Streamline Your AI Workflows with Bitnami Package for Milvus
As the demands for artificial intelligence (AI) applications continue to grow, developers are seeking efficient tools within the open source ecosystem to manage processes like vector similarity search and data storage. In response to this, we're excited to include Milvus in Bitnami Application Catalog and its enterprise edition in VMware Tanzu Application Catalog––available both as a container and Helm chart—to help you simplify your AI workflows.
Milvus is an open source, highly-efficient vector database for AI applications that enables fast vector similarity search and analytics on large-scale vector datasets. It is designed to handle high-dimensional data for various purposes, such as image and video retrieval, natural language processing, and more.
In this blog post, we will discuss the basics of using Milvus, how to obtain the Bitnami package for the Milvus Helm chart from Bitnami Application Catalog and Tanzu Application Catalog, how to deploy the Helm chart, and finally, how to build an intelligent chatbot using Milvus and the BERT model for natural language processing (NLP).
Assumptions and prerequisites
Before starting the deployment, ensure the following prerequisites are met:
- An operational Kubernetes cluster
- Installed and configured kubectl CLI and Helm v3.x package manager. If you need help with these steps, you can check our article “Learn how to install kubectl and Helm v3.x.”
- Python 3 (3.7.1 or later) environment to interact with Milvus
- Optional: Access to VMware Tanzu Application Catalog
Deploying the Bitnami package for Milvus Helm chart
Having all the previous requirements met, it is time to get the Bitnami package for Milvus and deploy it in your Kubernetes cluster.
The sections below describe the steps to configure the deployment, get and deploy the community and enterprise versions of the Bitnami package for Milvus Helm chart, and obtain its external IP address to access Attu, the graphical user interface (GUI) of Milvus.
Getting and deploying the Bitnami package for Milvus Helm chart
You can deploy the free-to-consume community version of Bitnami-packaged Milvus Helm chart from Bitnami Application Catalog. Alternatively, if you have access to an enterprise Tanzu Application Catalog instance, it can also be deployed from there.
Deploying the community version of the chart through Bitnami Application Catalog
To deploy the chart in its namespace, run the following commands:
$ kubectl create namespace milvus
$ helm install milvus --namespace milvus bitnami/milvus
Deploying the enterprise version of the chart through Tanzu Application Catalog
This example shows a Milvus chart built using Ubuntu 22 as the base OS image, but feel free to customize the chart depending on your needs.
- Navigate to app-catalog.vmware.com and sign in to your catalog with your VMware account.
- In the My Applications section, search for the Milvus Helm chart and click on Details.
Tanzu Application Catalog Milvus listing
On the next screen, you will find instructions for deploying the chart on your cluster. Make sure that your cluster is up and running.
- Execute kubectl cluster-info, then run the commands you will find in the Consume your Helm chart section:
Milvus details page on Tanzu Application Catalog
Obtaining the external IP address and logging in to the Attu dashboard
Attu is an administration tool for Milvus that provides a dashboard to perform searches and manage users and collections. It is bundled as a part of the Bitnami package for the Milvus Helm chart so you don’t need to perform additional steps to access it.
Wait for the deployment to complete, and check that service milvus-attu has an external IP assigned.
$ kubectl get pods,svc --namespace milvus
NAME READY STATUS
pod/milvus-attu-9ddf7476c-8wnbt 1/1 Running
pod/milvus-data-coordinator-5f5957d6f7-672fx 1/1 Running
pod/milvus-data-node-7cc6d8b48b-m8vzh 1/1 Running
pod/milvus-etcd-0 1/1 Running
pod/milvus-etcd-1 1/1 Running
pod/milvus-etcd-2 1/1 Running
pod/milvus-index-coordinator-7bb479c4fc-cc2h9 1/1 Running
pod/milvus-index-node-7954698996-jm62c 1/1 Running
pod/milvus-kafka-controller-0 1/1 Running
pod/milvus-minio-6bd5777956-r7crf 1/1 Running
pod/milvus-minio-provisioning-xwrzw 0/1 Completed
pod/milvus-proxy-6c9fb797cc-66cmm 1/1 Running
pod/milvus-query-coordinator-5487566d69-qzdk8 1/1 Running
pod/milvus-query-node-6ffb6c8676-p6dls 1/1 Running
pod/milvus-root-coordinator-5b65755d6f-6zw7r 1/1 Running
NAME CLUSTER-IP EXTERNAL-IP PORT(S)
service/milvus-attu 10.159.25.28 35.245.159.48 80:31215/TCP
...
service/milvus-proxy 10.159.27.17 35.230.164.36 19530:31451/TCP
...
Browse to the external IP address of the milvus-attu service and log in using http://milvus-proxy:19530 as MILVUS_URL. You will see a default empty database. For the sake of simplicity, we have not previously set credentials, so no authentication is needed. For production purposes, it is recommended to enable user authentication (you can find more info in the upstream documentation).
Attu dashboard Overview page
Exploring all the components from the System View section, we can see the following architecture:
- Root coordinator (root coord) – Data definition language (DDL) and data control language (DCL) requests, TSO (Timestamp Oracle), and time tick messages
- Index coordinator (index coord) – Topology of the index nodes and index metadata
- Index node – Build indexes for vectors
- Data coordinator (data coord) – Topology of data nodes, metadata, and flush, compact, and other background data operations
- Data node – Incremental log data by subscribing to the log broker, mutation requests, and log data into log snapshots stored in the object storage
- Query coordinator (query coord) – Topology and load-balancing of the query nodes, and handoff operation from growing segments to sealed segments
- Query node – Hybrid search of vector and scalar data on incremental and historical data
Attu dashboard System View page
Apart from the above-mentioned components, the Bitnami package for Milvus Helm chart also includes:
- Proxy – Access layer of the system and endpoint to users.
- Attu – Administration dashboard for Milvus.
- Etcd – Metadata storage and access.
- Minio – Storage engine for data persistence.
- Kafka – Engine for reliable storage and publication/subscription of message streams.
Milvus architecture overview
Milvus is now fully prepared to create new databases and collections.
Creating a Milvus experiment
This demonstration is based on the Question Answering System example from towhee-io/examples repositories to build a question-answering engine. The example uses a subset of the InsuranceQA Corpus dataset with 1,000 pairs of questions and answers. With this dataset, you will be able to ask insurance-related queries and enable the system to deliver the most precise answer from the list.
First, download the CSV with the questions and answers from GitHub.
$ mkdir milvus-example
$ cd milvus-example
$ curl -L https://github.com/towhee-io/examples/releases/download/data/question_answer.csv -O
Now, let’s install all the requirements for our scenario. In this case, we will use:
- Towhee – An open source machine learning framework that helps you encode your unstructured data into embeddings. We will use it to insert the data into Milvus and also query questions.
- Gradio – A great tool to demo your machine learning model with a friendly web interface. We will use it to serve a chatbot in our browser where to input our questions.
- PyMilvus – The Python SDK for Milvus
$ pip3 install towhee towhee.models gradio pymilvus
Collecting towhee
Downloading towhee-1.1.2-py3-none-any.whl (222 kB)
...
To simplify the execution, we have written this adapted Python script that creates a collection, loads the CSV embedding into Milvus, queries a question, and builds a showcase interface for UI interaction. Place it in your /tmp folder:
curl -L https://raw.githubusercontent.com/bitnami-labs/examples/main/2023-nov-milvus-post/question_answering.py -O
To run the experiment, it is necessary to set these environment variables in our Python environment to point to the exposed milvus-proxy service:
$ export MILVUS_HOST=35.230.164.36
$ export MILVUS_PORT=19530
You are now ready to run the code:
$ python3 question_answering.py
-> Creating collection in Milvus
-> Loading question embedding into Milvus
-> Question query
+----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| question | answer |
+==============================================+=======================================================================================================================================+
| If I don't own the car, can I get insurance? | [Life Insurance Trusts allow Insurance proceeds to go into a trust and allocated where the person who controls the trust sees fit...] |
+----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
-> Showcase interface
Running on local URL: http://0.0.0.0:7860
Running on public URL: https://0bb5236d0f82a0c112.gradio.live
This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)
Alternative: Running the example without a Python environment
Alternatively, if you don’t have a Python environment— or if you want to run it in an isolated Python environment to prevent conflicts between applications and allow them to run without interference— you can make use of Bitnami’s Python container image to run the script using these steps instead:
# Set the requirements
cat > requirements.txt <<EOF
towhee
towhee.models
gradio
pymilvus
EOF
# Run the experiment
$ docker run -it --rm --name milvus-chatbot \
-v $PWD:/app \
-e MILVUS_HOST=35.230.164.36 \
-e MILVUS_PORT=19530 \
-p 7860:7860 \
bitnami/python:3.11 \
sh -c "pip install -r requirements.txt && python question_answering.py"
Checking the results
By accessing the Attu dashboard, we can see that the collection question_answer has been created successfully with the 1,000 entities inserted from the CSV file. As we set in our script, our collection applies the commonly used L2 distance metric and an IVF_FLAT index. You can check it from the Collection section:
Attu dashboard Collection page
Finally, as you can see from the script’s output, it is possible to access Gradio at http://127.0.0.1:7860 to interact with our chatbot. Let’s ask something, for example, “Are veterans allowed to obtain life insurance?”
Gradio web interface
As you can see in the screenshot above, Milvus will show a reply with the corresponding answer taken from the dataset previously embedded into Milvus.
This is just a simple example of how Milvus can speed up the creation of AI apps, but it is much more powerful. From here, you could explore how to run and manage your projects with Milvus, use it with your own datasets, add tags or authentication, secure it with certificates, move your models to stage or production, and so on.
Support and resources
The Bitnami package for Milvus is available in both the community version, through the Bitnami GitHub repository, as well as the enterprise version available through VMware Tanzu Application Catalog. Learn more about the differences between these two catalogs in this blog post.
Other ML/AI-related images like PyTorch or MLflow could also be found in Bitnami GitHub or Docker Hub repositories. Refer to this blog post to learn more about other ML/AI solutions packaged by Bitnami: Handling Your Machine Learning Workflows Is Now Easier, Thanks to Bitnami-Packaged MLflow
To solve the problems you may have with the Bitnami community packages—including deployment support, operational support, and bug fixes—please open an issue in the Bitnami Helm charts or containers GitHub repository. Also, if you want to contribute to the catalog, feel free to send us a pull request, and the team will check it and guide you in the process for a successful merge.
Check out the Milvus official documentation for detailed documentation on how to use the project in your code or processes.
If you are interested in learning more about Tanzu Application Catalog in general, check out the product webpage, Tech Zone page, technical documentation, and additional resources. If you would like to get in touch, contact us.
Read about all the news the VMware Tanzu team announced at VMware Explore 2023.