diff --git a/solutions/question_answering_system/question_answering.ipynb b/solutions/question_answering_system/question_answering.ipynb index 2290cbb4e..a8569f911 100644 --- a/solutions/question_answering_system/question_answering.ipynb +++ b/solutions/question_answering_system/question_answering.ipynb @@ -5,7 +5,9 @@ "metadata": {}, "source": [ "# Question Answering System\n", - "In this example we will be going over the code used to build a question answering system. This example uses a modified BERT model to extract features from questions and Milvus to search for similar questions and answers. " + "In this example we will be going over the code used to build a question answering system. This example uses a modified BERT model to extract features from questions and Milvus to search for similar questions and answers. \n", + "\n", + "> This project based Milvus 2.0.0-rc5." ] }, { @@ -29,7 +31,7 @@ "\n", "| Packages | Servers |\n", "|- | - | \n", - "| pymilvus-orm==2.0.0rc1 | milvus 2.0.0 |\n", + "| pymilvus==2.0.0rc5 | milvus 2.0.0-rc5 |\n", "| sentence_transformers | |\n", "| psmysql | mysql |\n", "| pandas | |\n", @@ -146,10 +148,7 @@ "outputs": [], "source": [ "#Connectings to Milvus, BERT and Postgresql\n", - "from pymilvus_orm import connections, utility\n", - "from pymilvus_orm.types import DataType\n", - "from pymilvus_orm.schema import FieldSchema, CollectionSchema\n", - "from pymilvus_orm.collection import Collection\n", + "from pymilvus import connections, FieldSchema, CollectionSchema, DataType, Collection, utility\n", "import pymysql\n", "\n", "connections.connect(host='localhost', port='19537')\n", @@ -454,4 +453,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} +} \ No newline at end of file diff --git a/solutions/question_answering_system/quick_deploy/README.md b/solutions/question_answering_system/quick_deploy/README.md index c930cc405..efb913e8c 100644 --- a/solutions/question_answering_system/quick_deploy/README.md +++ b/solutions/question_answering_system/quick_deploy/README.md @@ -3,6 +3,8 @@ This project combines Milvus and BERT to build a question and answer system. This aims to provide a solution to achieve semantic similarity matching with Milvus combined with AI models. +> This project based Milvus2.0.0-rc5 + ## Data description The dataset needed for this system is a CSV format file which needs to contain a column of questions and a column of answers. @@ -163,4 +165,4 @@ After starting the service, Please visit `127.0.0.1:8000/docs` in your browser iii. **Obtain answer**: Click any of the similar questions obtained in the previous step, and you'll get the answer. - \ No newline at end of file + diff --git a/solutions/question_answering_system/quick_deploy/server/.idea/.gitignore b/solutions/question_answering_system/quick_deploy/server/.idea/.gitignore deleted file mode 100644 index 73f69e095..000000000 --- a/solutions/question_answering_system/quick_deploy/server/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/solutions/question_answering_system/quick_deploy/server/.idea/inspectionProfiles/Project_Default.xml b/solutions/question_answering_system/quick_deploy/server/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 1dac59044..000000000 --- a/solutions/question_answering_system/quick_deploy/server/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - \ No newline at end of file diff --git a/solutions/question_answering_system/quick_deploy/server/.idea/inspectionProfiles/profiles_settings.xml b/solutions/question_answering_system/quick_deploy/server/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2da2..000000000 --- a/solutions/question_answering_system/quick_deploy/server/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/solutions/question_answering_system/quick_deploy/server/.idea/misc.xml b/solutions/question_answering_system/quick_deploy/server/.idea/misc.xml deleted file mode 100644 index 0541f214f..000000000 --- a/solutions/question_answering_system/quick_deploy/server/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/solutions/question_answering_system/quick_deploy/server/.idea/modules.xml b/solutions/question_answering_system/quick_deploy/server/.idea/modules.xml deleted file mode 100644 index fbd90b4d4..000000000 --- a/solutions/question_answering_system/quick_deploy/server/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/solutions/question_answering_system/quick_deploy/server/.idea/server.iml b/solutions/question_answering_system/quick_deploy/server/.idea/server.iml deleted file mode 100644 index bc01ef925..000000000 --- a/solutions/question_answering_system/quick_deploy/server/.idea/server.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/solutions/question_answering_system/quick_deploy/server/.idea/vcs.xml b/solutions/question_answering_system/quick_deploy/server/.idea/vcs.xml deleted file mode 100644 index 4fce1d86b..000000000 --- a/solutions/question_answering_system/quick_deploy/server/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solutions/question_answering_system/quick_deploy/server/requirements.txt b/solutions/question_answering_system/quick_deploy/server/requirements.txt index dd8a4c48a..eb6961f11 100644 --- a/solutions/question_answering_system/quick_deploy/server/requirements.txt +++ b/solutions/question_answering_system/quick_deploy/server/requirements.txt @@ -1,7 +1,7 @@ PyMySQL uvicorn numpy -pymilvus-orm==2.0.0rc1 +pymilvus==2.0.0rc5 fastapi python-multipart pandas diff --git a/solutions/question_answering_system/quick_deploy/server/src/milvus_helpers.py b/solutions/question_answering_system/quick_deploy/server/src/milvus_helpers.py index 133734a2b..466d94770 100644 --- a/solutions/question_answering_system/quick_deploy/server/src/milvus_helpers.py +++ b/solutions/question_answering_system/quick_deploy/server/src/milvus_helpers.py @@ -1,13 +1,11 @@ import sys -from pymilvus_orm import connections -from pymilvus_orm.types import DataType -from pymilvus_orm.schema import FieldSchema, CollectionSchema -from pymilvus_orm.collection import Collection +from pymilvus import connections, FieldSchema, CollectionSchema, DataType, Collection, utility + from config import MILVUS_HOST, MILVUS_PORT, VECTOR_DIMENSION, METRIC_TYPE -from pymilvus_orm import utility from logs import LOGGER + class MilvusHelper: def __init__(self): try: @@ -25,7 +23,7 @@ def set_collection(self, collection_name): else: raise Exception("There has no collection named:{}".format(collection_name)) except Exception as e: - LOGGER.error("Failed to load data to Milvus: {}".format(e)) + LOGGER.error("ERROR: {}".format(e)) sys.exit(1) # Return if Milvus has the collection @@ -33,7 +31,7 @@ def has_collection(self, collection_name): try: return utility.has_collection(collection_name) except Exception as e: - LOGGER.error("Failed to load data to Milvus: {}".format(e)) + LOGGER.error("Failed: {}".format(e)) sys.exit(1) # Create milvus collection if not exists @@ -46,6 +44,8 @@ def create_collection(self, collection_name): schema = CollectionSchema(fields=[field1, field2], description="collection description") self.collection = Collection(name=collection_name, schema=schema) LOGGER.debug("Create Milvus collection: {}".format(self.collection)) + else: + self.collection = Collection(name=collection_name) return "OK" except Exception as e: LOGGER.error("Failed to load data to Milvus: {}".format(e)) @@ -55,7 +55,7 @@ def create_collection(self, collection_name): def insert(self, collection_name, vectors): try: self.create_collection(collection_name) - self.collection = Collection(name=collection_name) + # self.collection = Collection(name=collection_name) data = [vectors] mr = self.collection.insert(data) ids = mr.primary_keys diff --git a/solutions/question_answering_system/requirements.txt b/solutions/question_answering_system/requirements.txt index e49ecbca2..67fd65d40 100644 --- a/solutions/question_answering_system/requirements.txt +++ b/solutions/question_answering_system/requirements.txt @@ -1,5 +1,5 @@ PyMySQL numpy -pymilvus-orm==2.0.0rc1 +pymilvus==2.0.0rc5 pandas sentence_transformers==1.2.0