diff --git a/docs/overview/cli.ipynb b/docs/overview/cli.ipynb index 5764ee24..38c4fa14 100644 --- a/docs/overview/cli.ipynb +++ b/docs/overview/cli.ipynb @@ -17,14 +17,14 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:16:18 [RedisVL] INFO RedisVL version 0.5.2\n" + "16:41:26 [RedisVL] INFO RedisVL version 0.7.0\n" ] } ], @@ -65,7 +65,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -99,14 +99,14 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:16:21 [RedisVL] INFO Index created successfully\n" + "16:43:40 [RedisVL] INFO Index created successfully\n" ] } ], @@ -117,15 +117,15 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:16:24 [RedisVL] INFO Indices:\n", - "19:16:24 [RedisVL] INFO 1. vectorizers\n" + "16:43:43 [RedisVL] INFO Indices:\n", + "16:43:43 [RedisVL] INFO 1. vectorizers\n" ] } ], @@ -136,7 +136,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -168,14 +168,14 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:16:29 [RedisVL] INFO Index deleted successfully\n" + "16:43:50 [RedisVL] INFO Index deleted successfully\n" ] } ], @@ -186,14 +186,14 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:16:32 [RedisVL] INFO Indices:\n" + "16:43:53 [RedisVL] INFO Indices:\n" ] } ], @@ -213,14 +213,14 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:16:35 [RedisVL] INFO Index created successfully\n" + "16:43:55 [RedisVL] INFO Index created successfully\n" ] } ], @@ -232,15 +232,15 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:16:38 [RedisVL] INFO Indices:\n", - "19:16:38 [RedisVL] INFO 1. vectorizers\n" + "16:43:58 [RedisVL] INFO Indices:\n", + "16:43:58 [RedisVL] INFO 1. vectorizers\n" ] } ], @@ -251,7 +251,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -318,15 +318,15 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:16:43 [RedisVL] INFO Indices:\n", - "19:16:43 [RedisVL] INFO 1. vectorizers\n" + "16:44:03 [RedisVL] INFO Indices:\n", + "16:44:03 [RedisVL] INFO 1. vectorizers\n" ] } ], @@ -346,17 +346,9 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "19:16:46 [RedisVL] ERROR Error 8 connecting to rediss:6379. nodename nor servname provided, or not known.\n" - ] - } - ], + "outputs": [], "source": [ "# connect to rediss://jane_doe:password123@localhost:6379\n", "!rvl index listall --user jane_doe -a password123 --ssl" @@ -364,14 +356,14 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:16:49 [RedisVL] INFO Index deleted successfully\n" + "16:44:13 [RedisVL] INFO Index deleted successfully\n" ] } ], @@ -382,7 +374,7 @@ ], "metadata": { "kernelspec": { - "display_name": "redisvl-dev", + "display_name": "redisvl-VnTEShF2-py3.13", "language": "python", "name": "python3" }, @@ -396,7 +388,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.0" + "version": "3.13.2" } }, "nbformat": 4, diff --git a/docs/user_guide/01_getting_started.ipynb b/docs/user_guide/01_getting_started.ipynb index 2c64b3d5..3efd93ff 100644 --- a/docs/user_guide/01_getting_started.ipynb +++ b/docs/user_guide/01_getting_started.ipynb @@ -81,7 +81,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -126,7 +126,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -187,7 +187,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -209,7 +209,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -230,7 +230,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -254,15 +254,15 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:17:09 [RedisVL] INFO Indices:\n", - "19:17:09 [RedisVL] INFO 1. user_simple\n" + "16:44:38 [RedisVL] INFO Indices:\n", + "16:44:38 [RedisVL] INFO 1. user_simple\n" ] } ], @@ -272,7 +272,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -318,14 +318,14 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "['user_simple_docs:01JT4PPPNJZMSK2395RKD208T9', 'user_simple_docs:01JT4PPPNM63J55ZESZ4TV1VR8', 'user_simple_docs:01JT4PPPNM59RCKS2YQ58B1HQW']\n" + "['user_simple_docs:01JWEWMDE9VCXNRVBBB3T3NG55', 'user_simple_docs:01JWEWMDECWRM26BXNTHWMBY6C', 'user_simple_docs:01JWEWMDECZ8B4Q8PNMBP9TZWY']\n" ] } ], @@ -346,28 +346,28 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Load invalid data\n", + "### Load INVALID data\n", "This will raise a `SchemaValidationError` if `validate_on_load` is set to true in the `SearchIndex` class." ] }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:17:21 redisvl.index.index ERROR Schema validation error while loading data\n", + "16:45:26 redisvl.index.index ERROR Schema validation error while loading data\n", "Traceback (most recent call last):\n", - " File \"/Users/justin.cechmanek/Documents/redisvl/redisvl/index/storage.py\", line 204, in _preprocess_and_validate_objects\n", + " File \"/Users/tyler.hutcherson/Documents/AppliedAI/redis-vl-python/redisvl/index/storage.py\", line 245, in _preprocess_and_validate_objects\n", " processed_obj = self._validate(processed_obj)\n", - " File \"/Users/justin.cechmanek/Documents/redisvl/redisvl/index/storage.py\", line 160, in _validate\n", + " File \"/Users/tyler.hutcherson/Documents/AppliedAI/redis-vl-python/redisvl/index/storage.py\", line 178, in _validate\n", " return validate_object(self.index_schema, obj)\n", - " File \"/Users/justin.cechmanek/Documents/redisvl/redisvl/schema/validation.py\", line 276, in validate_object\n", + " File \"/Users/tyler.hutcherson/Documents/AppliedAI/redis-vl-python/redisvl/schema/validation.py\", line 276, in validate_object\n", " validated = model_class.model_validate(flat_obj)\n", - " File \"/Users/justin.cechmanek/.pyenv/versions/3.13/envs/redisvl-dev/lib/python3.13/site-packages/pydantic/main.py\", line 627, in model_validate\n", + " File \"/Users/tyler.hutcherson/Library/Caches/pypoetry/virtualenvs/redisvl-VnTEShF2-py3.13/lib/python3.13/site-packages/pydantic/main.py\", line 627, in model_validate\n", " return cls.__pydantic_validator__.validate_python(\n", " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n", " obj, strict=strict, from_attributes=from_attributes, context=context\n", @@ -382,56 +382,42 @@ "The above exception was the direct cause of the following exception:\n", "\n", "Traceback (most recent call last):\n", - " File \"/Users/justin.cechmanek/Documents/redisvl/redisvl/index/index.py\", line 686, in load\n", + " File \"/Users/tyler.hutcherson/Documents/AppliedAI/redis-vl-python/redisvl/index/index.py\", line 772, in load\n", " return self._storage.write(\n", " ~~~~~~~~~~~~~~~~~~~^\n", - " self._redis_client, # type: ignore\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " self._redis_client,\n", + " ^^^^^^^^^^^^^^^^^^^\n", " ...<6 lines>...\n", " validate=self._validate_on_load,\n", " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", " )\n", " ^\n", - " File \"/Users/justin.cechmanek/Documents/redisvl/redisvl/index/storage.py\", line 265, in write\n", + " File \"/Users/tyler.hutcherson/Documents/AppliedAI/redis-vl-python/redisvl/index/storage.py\", line 306, in write\n", " prepared_objects = self._preprocess_and_validate_objects(\n", " list(objects), # Convert Iterable to List\n", " ...<3 lines>...\n", " validate=validate,\n", " )\n", - " File \"/Users/justin.cechmanek/Documents/redisvl/redisvl/index/storage.py\", line 211, in _preprocess_and_validate_objects\n", + " File \"/Users/tyler.hutcherson/Documents/AppliedAI/redis-vl-python/redisvl/index/storage.py\", line 252, in _preprocess_and_validate_objects\n", " raise SchemaValidationError(str(e), index=i) from e\n", "redisvl.exceptions.SchemaValidationError: Validation failed for object at index 0: 1 validation error for user_simple__PydanticModel\n", "user_embedding\n", " Input should be a valid bytes [type=bytes_type, input_value=True, input_type=bool]\n", + " For further information visit https://errors.pydantic.dev/2.10/v/bytes_type\n", + "Failed to load data Validation failed for object at index 0: 1 validation error for user_simple__PydanticModel\n", + "user_embedding\n", + " Input should be a valid bytes [type=bytes_type, input_value=True, input_type=bool]\n", " For further information visit https://errors.pydantic.dev/2.10/v/bytes_type\n" ] - }, - { - "ename": "SchemaValidationError", - "evalue": "Validation failed for object at index 0: 1 validation error for user_simple__PydanticModel\nuser_embedding\n Input should be a valid bytes [type=bytes_type, input_value=True, input_type=bool]\n For further information visit https://errors.pydantic.dev/2.10/v/bytes_type", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mValidationError\u001b[0m Traceback (most recent call last)", - "File \u001b[0;32m~/Documents/redisvl/redisvl/index/storage.py:204\u001b[0m, in \u001b[0;36mBaseStorage._preprocess_and_validate_objects\u001b[0;34m(self, objects, id_field, keys, preprocess, validate)\u001b[0m\n\u001b[1;32m 203\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m validate:\n\u001b[0;32m--> 204\u001b[0m processed_obj \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_validate\u001b[49m\u001b[43m(\u001b[49m\u001b[43mprocessed_obj\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 206\u001b[0m \u001b[38;5;66;03m# Store valid object with its key for writing\u001b[39;00m\n", - "File \u001b[0;32m~/Documents/redisvl/redisvl/index/storage.py:160\u001b[0m, in \u001b[0;36mBaseStorage._validate\u001b[0;34m(self, obj)\u001b[0m\n\u001b[1;32m 159\u001b[0m \u001b[38;5;66;03m# Pass directly to validation function and let any errors propagate\u001b[39;00m\n\u001b[0;32m--> 160\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mvalidate_object\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mindex_schema\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mobj\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/Documents/redisvl/redisvl/schema/validation.py:276\u001b[0m, in \u001b[0;36mvalidate_object\u001b[0;34m(schema, obj)\u001b[0m\n\u001b[1;32m 275\u001b[0m \u001b[38;5;66;03m# Validate against model\u001b[39;00m\n\u001b[0;32m--> 276\u001b[0m validated \u001b[38;5;241m=\u001b[39m \u001b[43mmodel_class\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodel_validate\u001b[49m\u001b[43m(\u001b[49m\u001b[43mflat_obj\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 277\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m validated\u001b[38;5;241m.\u001b[39mmodel_dump(exclude_none\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n", - "File \u001b[0;32m~/.pyenv/versions/3.13/envs/redisvl-dev/lib/python3.13/site-packages/pydantic/main.py:627\u001b[0m, in \u001b[0;36mBaseModel.model_validate\u001b[0;34m(cls, obj, strict, from_attributes, context)\u001b[0m\n\u001b[1;32m 626\u001b[0m __tracebackhide__ \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[0;32m--> 627\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mcls\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m__pydantic_validator__\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mvalidate_python\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 628\u001b[0m \u001b[43m \u001b[49m\u001b[43mobj\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstrict\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstrict\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfrom_attributes\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfrom_attributes\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcontext\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcontext\u001b[49m\n\u001b[1;32m 629\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n", - "\u001b[0;31mValidationError\u001b[0m: 1 validation error for user_simple__PydanticModel\nuser_embedding\n Input should be a valid bytes [type=bytes_type, input_value=True, input_type=bool]\n For further information visit https://errors.pydantic.dev/2.10/v/bytes_type", - "\nThe above exception was the direct cause of the following exception:\n", - "\u001b[0;31mSchemaValidationError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[31], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# NBVAL_SKIP\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m keys \u001b[38;5;241m=\u001b[39m \u001b[43mindex\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mload\u001b[49m\u001b[43m(\u001b[49m\u001b[43m[\u001b[49m\u001b[43m{\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43muser_embedding\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m}\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/Documents/redisvl/redisvl/index/index.py:686\u001b[0m, in \u001b[0;36mSearchIndex.load\u001b[0;34m(self, data, id_field, keys, ttl, preprocess, batch_size)\u001b[0m\n\u001b[1;32m 656\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Load objects to the Redis database. Returns the list of keys loaded\u001b[39;00m\n\u001b[1;32m 657\u001b[0m \u001b[38;5;124;03mto Redis.\u001b[39;00m\n\u001b[1;32m 658\u001b[0m \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 683\u001b[0m \u001b[38;5;124;03m RedisVLError: If there's an error loading data to Redis.\u001b[39;00m\n\u001b[1;32m 684\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 685\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 686\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_storage\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mwrite\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 687\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_redis_client\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# type: ignore\u001b[39;49;00m\n\u001b[1;32m 688\u001b[0m \u001b[43m \u001b[49m\u001b[43mobjects\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdata\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 689\u001b[0m \u001b[43m \u001b[49m\u001b[43mid_field\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mid_field\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 690\u001b[0m \u001b[43m \u001b[49m\u001b[43mkeys\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkeys\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 691\u001b[0m \u001b[43m \u001b[49m\u001b[43mttl\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mttl\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 692\u001b[0m \u001b[43m \u001b[49m\u001b[43mpreprocess\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpreprocess\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 693\u001b[0m \u001b[43m \u001b[49m\u001b[43mbatch_size\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbatch_size\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 694\u001b[0m \u001b[43m \u001b[49m\u001b[43mvalidate\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_validate_on_load\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 695\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 696\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m SchemaValidationError:\n\u001b[1;32m 697\u001b[0m \u001b[38;5;66;03m# Pass through validation errors directly\u001b[39;00m\n\u001b[1;32m 698\u001b[0m logger\u001b[38;5;241m.\u001b[39mexception(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSchema validation error while loading data\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", - "File \u001b[0;32m~/Documents/redisvl/redisvl/index/storage.py:265\u001b[0m, in \u001b[0;36mBaseStorage.write\u001b[0;34m(self, redis_client, objects, id_field, keys, ttl, preprocess, batch_size, validate)\u001b[0m\n\u001b[1;32m 262\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m []\n\u001b[1;32m 264\u001b[0m \u001b[38;5;66;03m# Pass 1: Preprocess and validate all objects\u001b[39;00m\n\u001b[0;32m--> 265\u001b[0m prepared_objects \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_preprocess_and_validate_objects\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 266\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mlist\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mobjects\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# Convert Iterable to List\u001b[39;49;00m\n\u001b[1;32m 267\u001b[0m \u001b[43m \u001b[49m\u001b[43mid_field\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mid_field\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 268\u001b[0m \u001b[43m \u001b[49m\u001b[43mkeys\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkeys\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 269\u001b[0m \u001b[43m \u001b[49m\u001b[43mpreprocess\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpreprocess\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 270\u001b[0m \u001b[43m \u001b[49m\u001b[43mvalidate\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mvalidate\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 271\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 273\u001b[0m \u001b[38;5;66;03m# Pass 2: Write all valid objects in batches\u001b[39;00m\n\u001b[1;32m 274\u001b[0m added_keys \u001b[38;5;241m=\u001b[39m []\n", - "File \u001b[0;32m~/Documents/redisvl/redisvl/index/storage.py:211\u001b[0m, in \u001b[0;36mBaseStorage._preprocess_and_validate_objects\u001b[0;34m(self, objects, id_field, keys, preprocess, validate)\u001b[0m\n\u001b[1;32m 207\u001b[0m prepared_objects\u001b[38;5;241m.\u001b[39mappend((key, processed_obj))\n\u001b[1;32m 209\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m ValidationError \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 210\u001b[0m \u001b[38;5;66;03m# Convert Pydantic ValidationError to SchemaValidationError with index context\u001b[39;00m\n\u001b[0;32m--> 211\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m SchemaValidationError(\u001b[38;5;28mstr\u001b[39m(e), index\u001b[38;5;241m=\u001b[39mi) \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01me\u001b[39;00m\n\u001b[1;32m 212\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 213\u001b[0m \u001b[38;5;66;03m# Capture other exceptions with context\u001b[39;00m\n\u001b[1;32m 214\u001b[0m object_id \u001b[38;5;241m=\u001b[39m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mat index \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mi\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n", - "\u001b[0;31mSchemaValidationError\u001b[0m: Validation failed for object at index 0: 1 validation error for user_simple__PydanticModel\nuser_embedding\n Input should be a valid bytes [type=bytes_type, input_value=True, input_type=bool]\n For further information visit https://errors.pydantic.dev/2.10/v/bytes_type" - ] } ], "source": [ "# NBVAL_SKIP\n", "\n", - "keys = index.load([{\"user_embedding\": True}])" + "try:\n", + " keys = index.load([{\"user_embedding\": True}])\n", + "except Exception as e:\n", + " print(f\"Failed to load data {str(e)}\")" ] }, { @@ -444,14 +430,14 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "['user_simple_docs:01JT4PPX63CH5YRN2BGEYB5TS2']\n" + "['user_simple_docs:01JWEWPKMA687KHAFRATVJ44BS']\n" ] } ], @@ -481,7 +467,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -506,7 +492,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -539,7 +525,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -558,7 +544,7 @@ " 'datatype': 'float32'}}]}" ] }, - "execution_count": 35, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -569,7 +555,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -582,7 +568,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -623,7 +609,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -648,14 +634,14 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:17:29 redisvl.index.index INFO Index already exists, overwriting.\n" + "16:46:01 redisvl.index.index INFO Index already exists, overwriting.\n" ] } ], @@ -666,13 +652,13 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceuseragejobcredit_score
0john1engineerhigh
0mary2doctorlow
0.0566299557686tyler9engineerhigh
" + "
vector_distanceuseragejobcredit_score
0mary2doctorlow
0john1engineerhigh
0.0566299557686tyler9engineerhigh
" ], "text/plain": [ "" @@ -698,7 +684,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -726,7 +712,7 @@ "│ offsets_per_term_avg │ 0 │\n", "│ records_per_doc_avg │ 5 │\n", "│ sortable_values_size_mb │ 0 │\n", - "│ total_indexing_time │ 0.74400001 │\n", + "│ total_indexing_time │ 1.58399999 │\n", "│ total_inverted_index_blocks │ 11 │\n", "│ vector_index_sz_mb │ 0.23560333 │\n", "╰─────────────────────────────┴────────────╯\n" @@ -757,7 +743,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 21, "metadata": {}, "outputs": [ { @@ -766,7 +752,7 @@ "4" ] }, - "execution_count": 42, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } @@ -778,7 +764,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 22, "metadata": {}, "outputs": [ { @@ -787,7 +773,7 @@ "True" ] }, - "execution_count": 43, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -799,7 +785,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ @@ -810,7 +796,7 @@ ], "metadata": { "kernelspec": { - "display_name": "redisvl-dev", + "display_name": "redisvl-VnTEShF2-py3.13", "language": "python", "name": "python3" }, @@ -824,7 +810,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.0" + "version": "3.13.2" }, "orig_nbformat": 4 }, diff --git a/docs/user_guide/02_hybrid_queries.ipynb b/docs/user_guide/02_hybrid_queries.ipynb index 3d399dcc..d051c4ca 100644 --- a/docs/user_guide/02_hybrid_queries.ipynb +++ b/docs/user_guide/02_hybrid_queries.ipynb @@ -79,15 +79,7 @@ "cell_type": "code", "execution_count": 3, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "11:40:25 redisvl.index.index INFO Index already exists, overwriting.\n" - ] - } - ], + "outputs": [], "source": [ "from redisvl.index import SearchIndex\n", "\n", @@ -100,9 +92,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "16:46:23 [RedisVL] INFO Indices:\n", + "16:46:23 [RedisVL] INFO 1. user_queries\n" + ] + } + ], "source": [ "# use the CLI to see the created index\n", "!rvl index listall" @@ -110,7 +111,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -120,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -129,7 +130,7 @@ "7" ] }, - "execution_count": 4, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -159,7 +160,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -194,7 +195,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -220,13 +221,13 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0johnhigh18engineer-122.4194,37.7749
0johnhigh18engineer-122.4194,37.7749
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.266666650772nancyhigh94doctor-122.4194,37.7749
0.266666650772nancyhigh94doctor-122.4194,37.7749
0.653301358223joemedium35dentist-122.0839,37.3861
0.653301358223joemedium35dentist-122.0839,37.3861
" + "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0johnhigh18engineer-122.4194,37.77491741627789
0.109129190445tylerhigh100engineer-122.0839,37.38611742232589
0.158808946609timhigh12dermatologist-122.0839,37.38611739644189
0.266666650772nancyhigh94doctor-122.4194,37.77491710696589
0.653301358223joemedium35dentist-122.0839,37.38611742232589
" ], "text/plain": [ "" @@ -246,13 +247,13 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0johnhigh18engineer-122.4194,37.7749
0johnhigh18engineer-122.4194,37.7749
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.266666650772nancyhigh94doctor-122.4194,37.7749
0.266666650772nancyhigh94doctor-122.4194,37.7749
0.653301358223joemedium35dentist-122.0839,37.3861
0.653301358223joemedium35dentist-122.0839,37.3861
" + "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0johnhigh18engineer-122.4194,37.77491741627789
0.109129190445tylerhigh100engineer-122.0839,37.38611742232589
0.158808946609timhigh12dermatologist-122.0839,37.38611739644189
0.266666650772nancyhigh94doctor-122.4194,37.77491710696589
0.653301358223joemedium35dentist-122.0839,37.38611742232589
" ], "text/plain": [ "" @@ -283,13 +284,13 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0johnhigh18engineer-122.4194,37.7749
0derricklow14doctor-122.4194,37.7749
0johnhigh18engineer-122.4194,37.7749
0derricklow14doctor-122.4194,37.7749
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.217882037163taimurlow15CEO-122.0839,37.3861
0.217882037163taimurlow15CEO-122.0839,37.3861
" + "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0johnhigh18engineer-122.4194,37.77491741627789
0derricklow14doctor-122.4194,37.77491741627789
0.109129190445tylerhigh100engineer-122.0839,37.38611742232589
0.158808946609timhigh12dermatologist-122.0839,37.38611739644189
0.217882037163taimurlow15CEO-122.0839,37.38611742232589
0.266666650772nancyhigh94doctor-122.4194,37.77491710696589
0.653301358223joemedium35dentist-122.0839,37.38611742232589
" ], "text/plain": [ "" @@ -318,7 +319,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -345,13 +346,13 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0derricklow14doctor-122.4194,37.7749
0derricklow14doctor-122.4194,37.7749
" + "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0derricklow14doctor-122.4194,37.77491741627789
" ], "text/plain": [ "" @@ -371,13 +372,13 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0johnhigh18engineer-122.4194,37.7749
0johnhigh18engineer-122.4194,37.7749
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.217882037163taimurlow15CEO-122.0839,37.3861
0.217882037163taimurlow15CEO-122.0839,37.3861
0.266666650772nancyhigh94doctor-122.4194,37.7749
0.266666650772nancyhigh94doctor-122.4194,37.7749
" + "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0johnhigh18engineer-122.4194,37.77491741627789
0.109129190445tylerhigh100engineer-122.0839,37.38611742232589
0.158808946609timhigh12dermatologist-122.0839,37.38611739644189
0.217882037163taimurlow15CEO-122.0839,37.38611742232589
0.266666650772nancyhigh94doctor-122.4194,37.77491710696589
0.653301358223joemedium35dentist-122.0839,37.38611742232589
" ], "text/plain": [ "" @@ -406,7 +407,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -444,7 +445,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -457,7 +458,7 @@ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0derricklow14doctor-122.4194,37.77491741627789
0johnhigh18engineer-122.4194,37.77491741627789
0.158808946609timhigh12dermatologist-122.0839,37.38611739644189
0.266666650772nancyhigh94doctor-122.4194,37.77491710696589
" + "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0johnhigh18engineer-122.4194,37.77491741627789
0derricklow14doctor-122.4194,37.77491741627789
0.158808946609timhigh12dermatologist-122.0839,37.38611739644189
0.266666650772nancyhigh94doctor-122.4194,37.77491710696589
" ], "text/plain": [ "" @@ -496,7 +497,7 @@ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0derricklow14doctor-122.4194,37.77491741627789
0johnhigh18engineer-122.4194,37.77491741627789
0.158808946609timhigh12dermatologist-122.0839,37.38611739644189
" + "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0johnhigh18engineer-122.4194,37.77491741627789
0derricklow14doctor-122.4194,37.77491741627789
0.158808946609timhigh12dermatologist-122.0839,37.38611739644189
" ], "text/plain": [ "" @@ -532,7 +533,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -560,13 +561,13 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0johnhigh18engineer-122.4194,37.7749
0johnhigh18engineer-122.4194,37.7749
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.217882037163taimurlow15CEO-122.0839,37.3861
0.217882037163taimurlow15CEO-122.0839,37.3861
0.653301358223joemedium35dentist-122.0839,37.3861
0.653301358223joemedium35dentist-122.0839,37.3861
" + "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0johnhigh18engineer-122.4194,37.77491741627789
0.109129190445tylerhigh100engineer-122.0839,37.38611742232589
0.158808946609timhigh12dermatologist-122.0839,37.38611739644189
0.217882037163taimurlow15CEO-122.0839,37.38611742232589
0.653301358223joemedium35dentist-122.0839,37.38611742232589
" ], "text/plain": [ "" @@ -586,13 +587,13 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0derricklow14doctor-122.4194,37.7749
0derricklow14doctor-122.4194,37.7749
0.266666650772nancyhigh94doctor-122.4194,37.7749
0.266666650772nancyhigh94doctor-122.4194,37.7749
" + "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0derricklow14doctor-122.4194,37.77491741627789
0.266666650772nancyhigh94doctor-122.4194,37.77491710696589
" ], "text/plain": [ "" @@ -612,13 +613,13 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0johnhigh18engineer-122.4194,37.7749
0johnhigh18engineer-122.4194,37.7749
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.109129190445tylerhigh100engineer-122.0839,37.3861
" + "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0johnhigh18engineer-122.4194,37.77491741627789
0.109129190445tylerhigh100engineer-122.0839,37.38611742232589
" ], "text/plain": [ "" @@ -638,13 +639,13 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0johnhigh18engineer-122.4194,37.7749
0derricklow14doctor-122.4194,37.7749
0johnhigh18engineer-122.4194,37.7749
0derricklow14doctor-122.4194,37.7749
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.266666650772nancyhigh94doctor-122.4194,37.7749
0.266666650772nancyhigh94doctor-122.4194,37.7749
" + "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0johnhigh18engineer-122.4194,37.77491741627789
0derricklow14doctor-122.4194,37.77491741627789
0.109129190445tylerhigh100engineer-122.0839,37.38611742232589
0.266666650772nancyhigh94doctor-122.4194,37.77491710696589
" ], "text/plain": [ "" @@ -664,13 +665,13 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0johnhigh18engineer-122.4194,37.7749
0derricklow14doctor-122.4194,37.7749
0johnhigh18engineer-122.4194,37.7749
0derricklow14doctor-122.4194,37.7749
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.217882037163taimurlow15CEO-122.0839,37.3861
0.217882037163taimurlow15CEO-122.0839,37.3861
" + "
vector_distanceusercredit_scoreagejoboffice_locationlast_updated
0johnhigh18engineer-122.4194,37.77491741627789
0derricklow14doctor-122.4194,37.77491741627789
0.109129190445tylerhigh100engineer-122.0839,37.38611742232589
0.158808946609timhigh12dermatologist-122.0839,37.38611739644189
0.217882037163taimurlow15CEO-122.0839,37.38611742232589
0.266666650772nancyhigh94doctor-122.4194,37.77491710696589
0.653301358223joemedium35dentist-122.0839,37.38611742232589
" ], "text/plain": [ "" @@ -697,95 +698,78 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[{'id': 'user_queries_docs:01JMJJHE28ZW4F33ZNRKXRHYCS',\n", - " 'score': 1.8181817787737895,\n", - " 'vector_distance': '0',\n", - " 'user': 'john',\n", - " 'credit_score': 'high',\n", - " 'age': '18',\n", - " 'job': 'engineer',\n", - " 'office_location': '-122.4194,37.7749'},\n", - " {'id': 'user_queries_docs:01JMJJHE2899024DYPXT6424N9',\n", - " 'score': 0.0,\n", - " 'vector_distance': '0',\n", - " 'user': 'derrick',\n", - " 'credit_score': 'low',\n", - " 'age': '14',\n", - " 'job': 'doctor',\n", - " 'office_location': '-122.4194,37.7749'},\n", - " {'id': 'user_queries_docs:01JMJJPEYCQ89ZQW6QR27J72WT',\n", - " 'score': 1.8181817787737895,\n", + "[{'id': 'user_queries_docs:01JWEWQHJX670FQM0GKCV403XE',\n", + " 'score': 0.9090908893868948,\n", " 'vector_distance': '0',\n", " 'user': 'john',\n", " 'credit_score': 'high',\n", " 'age': '18',\n", " 'job': 'engineer',\n", - " 'office_location': '-122.4194,37.7749'},\n", - " {'id': 'user_queries_docs:01JMJJPEYD544WB1TKDBJ3Z3J9',\n", + " 'office_location': '-122.4194,37.7749',\n", + " 'last_updated': '1741627789'},\n", + " {'id': 'user_queries_docs:01JWEWQHJY8AS66TA21M8BRE09',\n", " 'score': 0.0,\n", " 'vector_distance': '0',\n", " 'user': 'derrick',\n", " 'credit_score': 'low',\n", " 'age': '14',\n", " 'job': 'doctor',\n", - " 'office_location': '-122.4194,37.7749'},\n", - " {'id': 'user_queries_docs:01JMJJHE28B5R6T00DH37A7KSJ',\n", - " 'score': 1.8181817787737895,\n", - " 'vector_distance': '0.109129190445',\n", - " 'user': 'tyler',\n", - " 'credit_score': 'high',\n", - " 'age': '100',\n", - " 'job': 'engineer',\n", - " 'office_location': '-122.0839,37.3861'},\n", - " {'id': 'user_queries_docs:01JMJJPEYDPF9S5328WHCQN0ND',\n", - " 'score': 1.8181817787737895,\n", + " 'office_location': '-122.4194,37.7749',\n", + " 'last_updated': '1741627789'},\n", + " {'id': 'user_queries_docs:01JWEWQHJYR2WTWMWZJ7PQ62N1',\n", + " 'score': 0.9090908893868948,\n", " 'vector_distance': '0.109129190445',\n", " 'user': 'tyler',\n", " 'credit_score': 'high',\n", " 'age': '100',\n", " 'job': 'engineer',\n", - " 'office_location': '-122.0839,37.3861'},\n", - " {'id': 'user_queries_docs:01JMJJHE28G5F943YGWMB1ZX1V',\n", - " 'score': 0.0,\n", - " 'vector_distance': '0.158808946609',\n", - " 'user': 'tim',\n", - " 'credit_score': 'high',\n", - " 'age': '12',\n", - " 'job': 'dermatologist',\n", - " 'office_location': '-122.0839,37.3861'},\n", - " {'id': 'user_queries_docs:01JMJJPEYDKA9ARKHRK1D7KPXQ',\n", + " 'office_location': '-122.0839,37.3861',\n", + " 'last_updated': '1742232589'},\n", + " {'id': 'user_queries_docs:01JWEWQHJY30EW4B8X2EE6PPZS',\n", " 'score': 0.0,\n", " 'vector_distance': '0.158808946609',\n", " 'user': 'tim',\n", " 'credit_score': 'high',\n", " 'age': '12',\n", " 'job': 'dermatologist',\n", - " 'office_location': '-122.0839,37.3861'},\n", - " {'id': 'user_queries_docs:01JMJJHE28NR7KF0EZEA433T2J',\n", + " 'office_location': '-122.0839,37.3861',\n", + " 'last_updated': '1739644189'},\n", + " {'id': 'user_queries_docs:01JWEWQHJYF2EG7YHEK8QBHJ11',\n", " 'score': 0.0,\n", " 'vector_distance': '0.217882037163',\n", " 'user': 'taimur',\n", " 'credit_score': 'low',\n", " 'age': '15',\n", " 'job': 'CEO',\n", - " 'office_location': '-122.0839,37.3861'},\n", - " {'id': 'user_queries_docs:01JMJJPEYD9EAVGJ2AZ8K9VX7Q',\n", + " 'office_location': '-122.0839,37.3861',\n", + " 'last_updated': '1742232589'},\n", + " {'id': 'user_queries_docs:01JWEWQHJYVBNG97WEWDRQEKCD',\n", " 'score': 0.0,\n", - " 'vector_distance': '0.217882037163',\n", - " 'user': 'taimur',\n", - " 'credit_score': 'low',\n", - " 'age': '15',\n", - " 'job': 'CEO',\n", - " 'office_location': '-122.0839,37.3861'}]" + " 'vector_distance': '0.266666650772',\n", + " 'user': 'nancy',\n", + " 'credit_score': 'high',\n", + " 'age': '94',\n", + " 'job': 'doctor',\n", + " 'office_location': '-122.4194,37.7749',\n", + " 'last_updated': '1710696589'},\n", + " {'id': 'user_queries_docs:01JWEWQHJY9VYQTFS165HBYYJ2',\n", + " 'score': 0.0,\n", + " 'vector_distance': '0.653301358223',\n", + " 'user': 'joe',\n", + " 'credit_score': 'medium',\n", + " 'age': '35',\n", + " 'job': 'dentist',\n", + " 'office_location': '-122.0839,37.3861',\n", + " 'last_updated': '1742232589'}]" ] }, - "execution_count": 20, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -808,13 +792,13 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
scorevector_distanceusercredit_scoreagejoboffice_location
0.45454544469344740johnhigh18engineer-122.4194,37.7749
0.45454544469344740derricklow14doctor-122.4194,37.7749
0.45454544469344740johnhigh18engineer-122.4194,37.7749
0.45454544469344740derricklow14doctor-122.4194,37.7749
0.45454544469344740.266666650772nancyhigh94doctor-122.4194,37.7749
0.45454544469344740.266666650772nancyhigh94doctor-122.4194,37.7749
" + "
scorevector_distanceusercredit_scoreagejoboffice_locationlast_updated
0.45454544469344740johnhigh18engineer-122.4194,37.77491741627789
0.45454544469344740derricklow14doctor-122.4194,37.77491741627789
0.45454544469344740.266666650772nancyhigh94doctor-122.4194,37.77491710696589
" ], "text/plain": [ "" @@ -836,13 +820,13 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
scorevector_distanceusercredit_scoreagejoboffice_location
0.45454544469344740johnhigh18engineer-122.4194,37.7749
0.45454544469344740derricklow14doctor-122.4194,37.7749
0.45454544469344740johnhigh18engineer-122.4194,37.7749
0.45454544469344740derricklow14doctor-122.4194,37.7749
0.45454544469344740.109129190445tylerhigh100engineer-122.0839,37.3861
0.45454544469344740.109129190445tylerhigh100engineer-122.0839,37.3861
0.45454544469344740.158808946609timhigh12dermatologist-122.0839,37.3861
0.45454544469344740.158808946609timhigh12dermatologist-122.0839,37.3861
0.45454544469344740.217882037163taimurlow15CEO-122.0839,37.3861
0.45454544469344740.217882037163taimurlow15CEO-122.0839,37.3861
" + "
scorevector_distanceusercredit_scoreagejoboffice_locationlast_updated
0.45454544469344740johnhigh18engineer-122.4194,37.77491741627789
0.45454544469344740derricklow14doctor-122.4194,37.77491741627789
0.45454544469344740.109129190445tylerhigh100engineer-122.0839,37.38611742232589
0.45454544469344740.158808946609timhigh12dermatologist-122.0839,37.38611739644189
0.45454544469344740.217882037163taimurlow15CEO-122.0839,37.38611742232589
0.45454544469344740.266666650772nancyhigh94doctor-122.4194,37.77491710696589
0.45454544469344740.653301358223joemedium35dentist-122.0839,37.38611742232589
" ], "text/plain": [ "" @@ -862,13 +846,13 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
scorevector_distanceusercredit_scoreagejoboffice_location
0.00.109129190445tylerhigh100engineer-122.0839,37.3861
0.00.109129190445tylerhigh100engineer-122.0839,37.3861
0.00.158808946609timhigh12dermatologist-122.0839,37.3861
0.00.158808946609timhigh12dermatologist-122.0839,37.3861
0.00.217882037163taimurlow15CEO-122.0839,37.3861
0.00.217882037163taimurlow15CEO-122.0839,37.3861
0.00.653301358223joemedium35dentist-122.0839,37.3861
0.00.653301358223joemedium35dentist-122.0839,37.3861
" + "
scorevector_distanceusercredit_scoreagejoboffice_locationlast_updated
0.00.109129190445tylerhigh100engineer-122.0839,37.38611742232589
0.00.158808946609timhigh12dermatologist-122.0839,37.38611739644189
0.00.217882037163taimurlow15CEO-122.0839,37.38611742232589
0.00.653301358223joemedium35dentist-122.0839,37.38611742232589
" ], "text/plain": [ "" @@ -899,7 +883,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -943,7 +927,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 29, "metadata": {}, "outputs": [ { @@ -987,7 +971,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 30, "metadata": {}, "outputs": [], "source": [ @@ -1002,13 +986,13 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.109129190445tylerhigh100engineer-122.0839,37.3861
" + "
vector_distanceusercredit_scoreagejoboffice_location
0.109129190445tylerhigh100engineer-122.0839,37.3861
" ], "text/plain": [ "" @@ -1027,13 +1011,13 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.266666650772nancyhigh94doctor-122.4194,37.7749
0.266666650772nancyhigh94doctor-122.4194,37.7749
" + "
vector_distanceusercredit_scoreagejoboffice_location
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.266666650772nancyhigh94doctor-122.4194,37.7749
" ], "text/plain": [ "" @@ -1052,13 +1036,13 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.266666650772nancyhigh94doctor-122.4194,37.7749
0.266666650772nancyhigh94doctor-122.4194,37.7749
0.653301358223joemedium35dentist-122.0839,37.3861
0.653301358223joemedium35dentist-122.0839,37.3861
" + "
vector_distanceusercredit_scoreagejoboffice_location
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.266666650772nancyhigh94doctor-122.4194,37.7749
0.653301358223joemedium35dentist-122.0839,37.3861
" ], "text/plain": [ "" @@ -1077,13 +1061,13 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejoboffice_location
0johnhigh18engineer-122.4194,37.7749
0derricklow14doctor-122.4194,37.7749
0johnhigh18engineer-122.4194,37.7749
0derricklow14doctor-122.4194,37.7749
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.217882037163taimurlow15CEO-122.0839,37.3861
0.217882037163taimurlow15CEO-122.0839,37.3861
" + "
vector_distanceusercredit_scoreagejoboffice_location
0johnhigh18engineer-122.4194,37.7749
0derricklow14doctor-122.4194,37.7749
0.109129190445tylerhigh100engineer-122.0839,37.3861
0.158808946609timhigh12dermatologist-122.0839,37.3861
0.217882037163taimurlow15CEO-122.0839,37.3861
0.266666650772nancyhigh94doctor-122.4194,37.7749
0.653301358223joemedium35dentist-122.0839,37.3861
" ], "text/plain": [ "" @@ -1111,13 +1095,13 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
usercredit_scoreagejob
derricklow14doctor
taimurlow15CEO
derricklow14doctor
taimurlow15CEO
" + "
usercredit_scoreagejob
derricklow14doctor
taimurlow15CEO
" ], "text/plain": [ "" @@ -1153,14 +1137,14 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "4 records match the filter expression @credit_score:{low} for the given index.\n" + "2 records match the filter expression @credit_score:{low} for the given index.\n" ] } ], @@ -1187,13 +1171,13 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejob
0johnhigh18engineer
0derricklow14doctor
0johnhigh18engineer
0derricklow14doctor
0.109129190445tylerhigh100engineer
0.109129190445tylerhigh100engineer
0.158808946609timhigh12dermatologist
0.158808946609timhigh12dermatologist
" + "
vector_distanceusercredit_scoreagejob
0johnhigh18engineer
0derricklow14doctor
0.109129190445tylerhigh100engineer
0.158808946609timhigh12dermatologist
" ], "text/plain": [ "" @@ -1228,13 +1212,13 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejob
0johnhigh18engineer
0derricklow14doctor
0johnhigh18engineer
0derricklow14doctor
" + "
vector_distanceusercredit_scoreagejob
0johnhigh18engineer
0derricklow14doctor
" ], "text/plain": [ "" @@ -1259,13 +1243,13 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 39, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceusercredit_scoreagejob
0johnhigh18engineer
0johnhigh18engineer
" + "
vector_distanceusercredit_scoreagejob
0johnhigh18engineer
" ], "text/plain": [ "" @@ -1299,13 +1283,13 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
vector_distanceageusercredit_scorejoboffice_location
0.109129190445100tylerhighengineer-122.0839,37.3861
0.109129190445100tylerhighengineer-122.0839,37.3861
018johnhighengineer-122.4194,37.7749
018johnhighengineer-122.4194,37.7749
" + "
vector_distanceageusercredit_scorejoboffice_location
0.109129190445100tylerhighengineer-122.0839,37.3861
018johnhighengineer-122.4194,37.7749
" ], "text/plain": [ "" @@ -1340,7 +1324,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 41, "metadata": {}, "outputs": [ { @@ -1349,7 +1333,7 @@ "'@job:(\"engineer\")=>[KNN 5 @user_embedding $vector AS vector_distance] RETURN 6 user credit_score age job office_location vector_distance SORTBY age DESC DIALECT 3 LIMIT 0 5'" ] }, - "execution_count": 37, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -1361,7 +1345,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 42, "metadata": {}, "outputs": [ { @@ -1370,7 +1354,7 @@ "'@credit_score:{high}'" ] }, - "execution_count": 38, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -1383,7 +1367,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 43, "metadata": {}, "outputs": [ { @@ -1392,7 +1376,7 @@ "'((@credit_score:{high} @age:[18 +inf]) @age:[-inf 100])'" ] }, - "execution_count": 39, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } @@ -1417,21 +1401,17 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 44, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "{'id': 'user_queries_docs:01JMJJHE28G5F943YGWMB1ZX1V', 'payload': None, 'user': 'tim', 'age': '12', 'job': 'dermatologist', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': '>>\\x00\\x00\\x00?'}\n", - "{'id': 'user_queries_docs:01JMJJHE28ZW4F33ZNRKXRHYCS', 'payload': None, 'user': 'john', 'age': '18', 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': '==\\x00\\x00\\x00?'}\n", - "{'id': 'user_queries_docs:01JMJJHE28B5R6T00DH37A7KSJ', 'payload': None, 'user': 'tyler', 'age': '100', 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': '=>\\x00\\x00\\x00?'}\n", - "{'id': 'user_queries_docs:01JMJJHE28EX13NEE7BGBM8FH3', 'payload': None, 'user': 'nancy', 'age': '94', 'job': 'doctor', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': '333?=\\x00\\x00\\x00?'}\n", - "{'id': 'user_queries_docs:01JMJJPEYCQ89ZQW6QR27J72WT', 'payload': None, 'user': 'john', 'age': '18', 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': '==\\x00\\x00\\x00?'}\n", - "{'id': 'user_queries_docs:01JMJJPEYDAN0M3V7EQEVPS6HX', 'payload': None, 'user': 'nancy', 'age': '94', 'job': 'doctor', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': '333?=\\x00\\x00\\x00?'}\n", - "{'id': 'user_queries_docs:01JMJJPEYDPF9S5328WHCQN0ND', 'payload': None, 'user': 'tyler', 'age': '100', 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': '=>\\x00\\x00\\x00?'}\n", - "{'id': 'user_queries_docs:01JMJJPEYDKA9ARKHRK1D7KPXQ', 'payload': None, 'user': 'tim', 'age': '12', 'job': 'dermatologist', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': '>>\\x00\\x00\\x00?'}\n" + "{'id': 'user_queries_docs:01JWEWQHJX670FQM0GKCV403XE', 'payload': None, 'user': 'john', 'age': '18', 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': '==\\x00\\x00\\x00?', 'last_updated': '1741627789'}\n", + "{'id': 'user_queries_docs:01JWEWQHJYVBNG97WEWDRQEKCD', 'payload': None, 'user': 'nancy', 'age': '94', 'job': 'doctor', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': '333?=\\x00\\x00\\x00?', 'last_updated': '1710696589'}\n", + "{'id': 'user_queries_docs:01JWEWQHJYR2WTWMWZJ7PQ62N1', 'payload': None, 'user': 'tyler', 'age': '100', 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': '=>\\x00\\x00\\x00?', 'last_updated': '1742232589'}\n", + "{'id': 'user_queries_docs:01JWEWQHJY30EW4B8X2EE6PPZS', 'payload': None, 'user': 'tim', 'age': '12', 'job': 'dermatologist', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': '>>\\x00\\x00\\x00?', 'last_updated': '1739644189'}\n" ] } ], @@ -1443,7 +1423,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 45, "metadata": {}, "outputs": [], "source": [ @@ -1454,7 +1434,7 @@ ], "metadata": { "kernelspec": { - "display_name": "redisvl-Q9FZQJWe-py3.11", + "display_name": "redisvl-VnTEShF2-py3.13", "language": "python", "name": "python3" }, @@ -1468,7 +1448,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.13.2" }, "orig_nbformat": 4 }, diff --git a/docs/user_guide/03_llmcache.ipynb b/docs/user_guide/03_llmcache.ipynb index 4234a4e3..8ff681b3 100644 --- a/docs/user_guide/03_llmcache.ipynb +++ b/docs/user_guide/03_llmcache.ipynb @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": 110, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -49,14 +49,14 @@ }, { "cell_type": "code", - "execution_count": 111, + "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:17:51 httpx INFO HTTP Request: POST https://api.openai.com/v1/completions \"HTTP/1.1 200 OK\"\n", + "16:49:16 httpx INFO HTTP Request: POST https://api.openai.com/v1/completions \"HTTP/1.1 200 OK\"\n", "The capital of France is Paris.\n" ] } @@ -77,28 +77,35 @@ }, { "cell_type": "code", - "execution_count": 112, + "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:17:51 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", - "19:17:51 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: redis/langcache-embed-v1\n" + "16:49:16 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", + "16:49:16 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: redis/langcache-embed-v1\n", + "16:49:16 sentence_transformers.SentenceTransformer WARNING You try to use a model that was created with version 4.1.0, however, your version is 3.4.1. This might cause unexpected behavior or errors. In that case, try to update to the latest version.\n", + "\n", + "\n", + "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 17.57it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.18it/s]\n" ] } ], "source": [ + "import warnings\n", + "warnings.filterwarnings('ignore')\n", + "\n", "from redisvl.extensions.cache.llm import SemanticCache\n", - "from redisvl.utils .vectorize import HFTextVectorizer\n", + "from redisvl.utils.vectorize import HFTextVectorizer\n", "\n", "llmcache = SemanticCache(\n", " name=\"llmcache\", # underlying search index name\n", @@ -110,7 +117,7 @@ }, { "cell_type": "code", - "execution_count": 113, + "execution_count": 31, "metadata": {}, "outputs": [ { @@ -152,7 +159,7 @@ }, { "cell_type": "code", - "execution_count": 114, + "execution_count": 32, "metadata": {}, "outputs": [], "source": [ @@ -161,14 +168,14 @@ }, { "cell_type": "code", - "execution_count": 115, + "execution_count": 33, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 18.30it/s]" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 14.60it/s]" ] }, { @@ -204,14 +211,14 @@ }, { "cell_type": "code", - "execution_count": 116, + "execution_count": 34, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 26.10it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 18.57it/s]\n" ] }, { @@ -220,7 +227,7 @@ "'llmcache:115049a298532be2f181edb03f766770c0db84c22aff39003fec340deaec7545'" ] }, - "execution_count": 116, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -243,14 +250,14 @@ }, { "cell_type": "code", - "execution_count": 117, + "execution_count": 35, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 12.36it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 20.09it/s]" ] }, { @@ -259,6 +266,13 @@ "text": [ "[{'prompt': 'What is the capital of France?', 'response': 'Paris', 'metadata': {'city': 'Paris', 'country': 'france'}, 'key': 'llmcache:115049a298532be2f181edb03f766770c0db84c22aff39003fec340deaec7545'}]\n" ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\n" + ] } ], "source": [ @@ -271,14 +285,14 @@ }, { "cell_type": "code", - "execution_count": 118, + "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 12.22it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 16.65it/s]\n" ] }, { @@ -287,7 +301,7 @@ "'Paris'" ] }, - "execution_count": 118, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -312,7 +326,7 @@ }, { "cell_type": "code", - "execution_count": 119, + "execution_count": 37, "metadata": {}, "outputs": [], "source": [ @@ -322,14 +336,14 @@ }, { "cell_type": "code", - "execution_count": 120, + "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 19.20it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 17.66it/s]\n" ] }, { @@ -338,7 +352,7 @@ "'Paris'" ] }, - "execution_count": 120, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } @@ -352,14 +366,14 @@ }, { "cell_type": "code", - "execution_count": 121, + "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 26.71it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 20.65it/s]\n" ] }, { @@ -368,7 +382,7 @@ "[]" ] }, - "execution_count": 121, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -377,7 +391,7 @@ "# Invalidate the cache completely by clearing it out\n", "llmcache.clear()\n", "\n", - "# should be empty now\n", + "# Should be empty now\n", "llmcache.check(prompt=question)" ] }, @@ -395,7 +409,7 @@ }, { "cell_type": "code", - "execution_count": 122, + "execution_count": 40, "metadata": {}, "outputs": [], "source": [ @@ -404,14 +418,14 @@ }, { "cell_type": "code", - "execution_count": 123, + "execution_count": 41, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 20.45it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 18.25it/s]\n" ] } ], @@ -423,14 +437,14 @@ }, { "cell_type": "code", - "execution_count": 124, + "execution_count": 42, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 17.02it/s]" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 13.91it/s]" ] }, { @@ -457,7 +471,7 @@ }, { "cell_type": "code", - "execution_count": 125, + "execution_count": 43, "metadata": {}, "outputs": [], "source": [ @@ -476,7 +490,7 @@ }, { "cell_type": "code", - "execution_count": 126, + "execution_count": 44, "metadata": {}, "outputs": [], "source": [ @@ -500,29 +514,29 @@ }, { "cell_type": "code", - "execution_count": 127, + "execution_count": 45, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 14.88it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 18.02it/s]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "19:18:04 httpx INFO HTTP Request: POST https://api.openai.com/v1/completions \"HTTP/1.1 200 OK\"\n", - "Without caching, a call to openAI to answer this simple question took 0.8826751708984375 seconds.\n" + "16:49:27 httpx INFO HTTP Request: POST https://api.openai.com/v1/completions \"HTTP/1.1 200 OK\"\n", + "Without caching, a call to openAI to answer this simple question took 1.6722779273986816 seconds.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 18.38it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 12.05it/s]\n" ] }, { @@ -531,7 +545,7 @@ "'llmcache:67e0f6e28fe2a61c0022fd42bf734bb8ffe49d3e375fd69d692574295a20fc1a'" ] }, - "execution_count": 127, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } @@ -551,31 +565,31 @@ }, { "cell_type": "code", - "execution_count": 128, + "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 13.65it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 27.94it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 27.19it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 27.53it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 28.12it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 27.38it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 25.39it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 26.34it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 28.07it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 27.35it/s]" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 16.95it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 20.13it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.62it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.25it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.84it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.82it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.21it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 20.62it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.13it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.55it/s]" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "Avg time taken with LLM cache enabled: 0.0463670015335083\n", - "Percentage of time saved: 94.75%\n" + "Avg time taken with LLM cache enabled: 0.05201866626739502\n", + "Percentage of time saved: 96.89%\n" ] }, { @@ -603,7 +617,7 @@ }, { "cell_type": "code", - "execution_count": 129, + "execution_count": 47, "metadata": {}, "outputs": [ { @@ -631,7 +645,7 @@ "│ offsets_per_term_avg │ 0.75862067 │\n", "│ records_per_doc_avg │ 29 │\n", "│ sortable_values_size_mb │ 0 │\n", - "│ total_indexing_time │ 3.875 │\n", + "│ total_indexing_time │ 0.29899999 │\n", "│ total_inverted_index_blocks │ 21 │\n", "│ vector_index_sz_mb │ 3.01609802 │\n", "╰─────────────────────────────┴────────────╯\n" @@ -645,7 +659,7 @@ }, { "cell_type": "code", - "execution_count": 130, + "execution_count": 48, "metadata": {}, "outputs": [], "source": [ @@ -665,25 +679,28 @@ }, { "cell_type": "code", - "execution_count": 131, + "execution_count": 49, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:18:07 [RedisVL] WARNING The default vectorizer has changed from `sentence-transformers/all-mpnet-base-v2` to `redis/langcache-embed-v1` in version 0.6.0 of RedisVL. For more information about this model, please refer to https://arxiv.org/abs/2504.02268 or visit https://huggingface.co/redis/langcache-embed-v1. To continue using the old vectorizer, please specify it explicitly in the constructor as: vectorizer=HFTextVectorizer(model='sentence-transformers/all-mpnet-base-v2')\n", - "19:18:07 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", - "19:18:07 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: redis/langcache-embed-v1\n" + "16:49:30 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", + "16:49:30 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: redis/langcache-embed-v1\n", + "16:49:30 sentence_transformers.SentenceTransformer WARNING You try to use a model that was created with version 4.1.0, however, your version is 3.4.1. This might cause unexpected behavior or errors. In that case, try to update to the latest version.\n", + "\n", + "\n", + "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 8.98it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 24.89it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 26.95it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 16.14it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 19.67it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.51it/s]\n" ] }, { @@ -692,7 +709,7 @@ "'private_cache:2831a0659fb888e203cd9fedb9f65681bfa55e4977c092ed1bf87d42d2655081'" ] }, - "execution_count": 131, + "execution_count": 49, "metadata": {}, "output_type": "execute_result" } @@ -718,14 +735,14 @@ }, { "cell_type": "code", - "execution_count": 132, + "execution_count": 50, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 27.98it/s]" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.55it/s]" ] }, { @@ -761,7 +778,7 @@ }, { "cell_type": "code", - "execution_count": 133, + "execution_count": 51, "metadata": {}, "outputs": [], "source": [ @@ -778,27 +795,30 @@ }, { "cell_type": "code", - "execution_count": 134, + "execution_count": 52, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:18:09 [RedisVL] WARNING The default vectorizer has changed from `sentence-transformers/all-mpnet-base-v2` to `redis/langcache-embed-v1` in version 0.6.0 of RedisVL. For more information about this model, please refer to https://arxiv.org/abs/2504.02268 or visit https://huggingface.co/redis/langcache-embed-v1. To continue using the old vectorizer, please specify it explicitly in the constructor as: vectorizer=HFTextVectorizer(model='sentence-transformers/all-mpnet-base-v2')\n", - "19:18:09 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", - "19:18:09 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: redis/langcache-embed-v1\n" + "16:49:31 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", + "16:49:31 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: redis/langcache-embed-v1\n", + "16:49:31 sentence_transformers.SentenceTransformer WARNING You try to use a model that was created with version 4.1.0, however, your version is 3.4.1. This might cause unexpected behavior or errors. In that case, try to update to the latest version.\n", + "\n", + "\n", + "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 13.54it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 16.76it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.82it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 28.80it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.04it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 20.21it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 17.24it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 16.95it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.26it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 19.48it/s]\n" ] }, { @@ -807,7 +827,7 @@ "'account_data:944f89729b09ca46b99923d223db45e0bccf584cfd53fcaf87d2a58f072582d3'" ] }, - "execution_count": 134, + "execution_count": 52, "metadata": {}, "output_type": "execute_result" } @@ -847,14 +867,14 @@ }, { "cell_type": "code", - "execution_count": 135, + "execution_count": 53, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 28.15it/s]" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 21.76it/s]" ] }, { @@ -893,7 +913,7 @@ }, { "cell_type": "code", - "execution_count": 136, + "execution_count": 54, "metadata": {}, "outputs": [], "source": [ @@ -904,7 +924,7 @@ ], "metadata": { "kernelspec": { - "display_name": "redisvl-dev", + "display_name": "redisvl-VnTEShF2-py3.13", "language": "python", "name": "python3" }, @@ -918,7 +938,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.0" + "version": "3.13.2" }, "orig_nbformat": 4 }, diff --git a/docs/user_guide/05_hash_vs_json.ipynb b/docs/user_guide/05_hash_vs_json.ipynb index 7918949d..9ab4c6bd 100644 --- a/docs/user_guide/05_hash_vs_json.ipynb +++ b/docs/user_guide/05_hash_vs_json.ipynb @@ -27,7 +27,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -50,7 +50,7 @@ { "data": { "text/html": [ - "
useragejobcredit_scoreoffice_locationuser_embedding
john18engineerhigh-122.4194,37.7749b'\\xcd\\xcc\\xcc=\\xcd\\xcc\\xcc=\\x00\\x00\\x00?'
derrick14doctorlow-122.4194,37.7749b'\\xcd\\xcc\\xcc=\\xcd\\xcc\\xcc=\\x00\\x00\\x00?'
nancy94doctorhigh-122.4194,37.7749b'333?\\xcd\\xcc\\xcc=\\x00\\x00\\x00?'
tyler100engineerhigh-122.0839,37.3861b'\\xcd\\xcc\\xcc=\\xcd\\xcc\\xcc>\\x00\\x00\\x00?'
tim12dermatologisthigh-122.0839,37.3861b'\\xcd\\xcc\\xcc>\\xcd\\xcc\\xcc>\\x00\\x00\\x00?'
taimur15CEOlow-122.0839,37.3861b'\\x9a\\x99\\x19?\\xcd\\xcc\\xcc=\\x00\\x00\\x00?'
joe35dentistmedium-122.0839,37.3861b'fff?fff?\\xcd\\xcc\\xcc='
" + "
useragejobcredit_scoreoffice_locationuser_embeddinglast_updated
john18engineerhigh-122.4194,37.7749b'\\xcd\\xcc\\xcc=\\xcd\\xcc\\xcc=\\x00\\x00\\x00?'1741627789
derrick14doctorlow-122.4194,37.7749b'\\xcd\\xcc\\xcc=\\xcd\\xcc\\xcc=\\x00\\x00\\x00?'1741627789
nancy94doctorhigh-122.4194,37.7749b'333?\\xcd\\xcc\\xcc=\\x00\\x00\\x00?'1710696589
tyler100engineerhigh-122.0839,37.3861b'\\xcd\\xcc\\xcc=\\xcd\\xcc\\xcc>\\x00\\x00\\x00?'1742232589
tim12dermatologisthigh-122.0839,37.3861b'\\xcd\\xcc\\xcc>\\xcd\\xcc\\xcc>\\x00\\x00\\x00?'1739644189
taimur15CEOlow-122.0839,37.3861b'\\x9a\\x99\\x19?\\xcd\\xcc\\xcc=\\x00\\x00\\x00?'1742232589
joe35dentistmedium-122.0839,37.3861b'fff?fff?\\xcd\\xcc\\xcc='1742232589
" ], "text/plain": [ "" @@ -187,7 +187,8 @@ " 'job': 'engineer',\n", " 'credit_score': 'high',\n", " 'office_location': '-122.4194,37.7749',\n", - " 'user_embedding': b'\\xcd\\xcc\\xcc=\\xcd\\xcc\\xcc=\\x00\\x00\\x00?'}" + " 'user_embedding': b'\\xcd\\xcc\\xcc=\\xcd\\xcc\\xcc=\\x00\\x00\\x00?',\n", + " 'last_updated': 1741627789}" ] }, "execution_count": 6, @@ -221,29 +222,29 @@ "text": [ "\n", "Statistics:\n", - "╭─────────────────────────────┬─────────────╮\n", - "│ Stat Key │ Value │\n", - "├─────────────────────────────┼─────────────┤\n", - "│ num_docs │ 7 │\n", - "│ num_terms │ 6 │\n", - "│ max_doc_id │ 7 │\n", - "│ num_records │ 44 │\n", - "│ percent_indexed │ 1 │\n", - "│ hash_indexing_failures │ 0 │\n", - "│ number_of_uses │ 1 │\n", - "│ bytes_per_record_avg │ 3.40909 │\n", - "│ doc_table_size_mb │ 0.000767708 │\n", - "│ inverted_sz_mb │ 0.000143051 │\n", - "│ key_table_size_mb │ 0.000248909 │\n", - "│ offset_bits_per_record_avg │ 8 │\n", - "│ offset_vectors_sz_mb │ 8.58307e-06 │\n", - "│ offsets_per_term_avg │ 0.204545 │\n", - "│ records_per_doc_avg │ 6.28571 │\n", - "│ sortable_values_size_mb │ 0 │\n", - "│ total_indexing_time │ 1.053 │\n", - "│ total_inverted_index_blocks │ 18 │\n", - "│ vector_index_sz_mb │ 0.0202332 │\n", - "╰─────────────────────────────┴─────────────╯\n" + "╭─────────────────────────────┬────────────╮\n", + "│ Stat Key │ Value │\n", + "├─────────────────────────────┼────────────┤\n", + "│ num_docs │ 7 │\n", + "│ num_terms │ 6 │\n", + "│ max_doc_id │ 7 │\n", + "│ num_records │ 44 │\n", + "│ percent_indexed │ 1 │\n", + "│ hash_indexing_failures │ 0 │\n", + "│ number_of_uses │ 1 │\n", + "│ bytes_per_record_avg │ 40.2954559 │\n", + "│ doc_table_size_mb │ 7.27653503 │\n", + "│ inverted_sz_mb │ 0.00169086 │\n", + "│ key_table_size_mb │ 2.21252441 │\n", + "│ offset_bits_per_record_avg │ 8 │\n", + "│ offset_vectors_sz_mb │ 8.58306884 │\n", + "│ offsets_per_term_avg │ 0.20454545 │\n", + "│ records_per_doc_avg │ 6.28571414 │\n", + "│ sortable_values_size_mb │ 0 │\n", + "│ total_indexing_time │ 0.25699999 │\n", + "│ total_inverted_index_blocks │ 18 │\n", + "│ vector_index_sz_mb │ 0.02023315 │\n", + "╰─────────────────────────────┴────────────╯\n" ] } ], @@ -373,8 +374,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[32m11:54:18\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n", - "\u001b[32m11:54:18\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. user-json\n" + "16:51:53 [RedisVL] INFO Indices:\n", + "16:51:53 [RedisVL] INFO 1. user-json\n" ] } ], @@ -416,7 +417,8 @@ " 'job': 'engineer',\n", " 'credit_score': 'high',\n", " 'office_location': '-122.4194,37.7749',\n", - " 'user_embedding': [0.10000000149011612, 0.10000000149011612, 0.5]}" + " 'user_embedding': [0.10000000149011612, 0.10000000149011612, 0.5],\n", + " 'last_updated': 1741627789}" ] }, "execution_count": 15, @@ -507,15 +509,32 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "/Users/robert.shelton/.pyenv/versions/3.11.9/lib/python3.11/site-packages/huggingface_hub/file_download.py:1142: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n", - " warnings.warn(\n" + "/Users/tyler.hutcherson/Library/Caches/pypoetry/virtualenvs/redisvl-VnTEShF2-py3.13/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "16:51:55 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", + "16:51:55 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-mpnet-base-v2\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Batches: 100%|██████████| 1/1 [00:00<00:00, 7.52it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 1.03it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 13.12it/s]\n" ] } ], @@ -588,7 +607,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -601,17 +620,17 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['bike-json:de92cb9955434575b20f4e87a30b03d5',\n", - " 'bike-json:054ab3718b984532b924946fa5ce00c6']" + "['bike-json:01JWEX1RA1AX32Q5K4DN7DMH5Z',\n", + " 'bike-json:01JWEX1RA1JCFKZJ5A03GGA9C2']" ] }, - "execution_count": 47, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } @@ -622,9 +641,17 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 22, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Batches: 100%|██████████| 1/1 [00:00<00:00, 12.64it/s]\n" + ] + } + ], "source": [ "from redisvl.query import VectorQuery\n", "\n", @@ -653,23 +680,23 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[{'id': 'bike-json:054ab3718b984532b924946fa5ce00c6',\n", - " 'vector_distance': '0.519989073277',\n", + "[{'id': 'bike-json:01JWEX1RA1JCFKZJ5A03GGA9C2',\n", + " 'vector_distance': '0.519989132881',\n", " 'brand': 'Trek',\n", " '$.metadata.type': 'Enduro bikes'},\n", - " {'id': 'bike-json:de92cb9955434575b20f4e87a30b03d5',\n", - " 'vector_distance': '0.657624483109',\n", + " {'id': 'bike-json:01JWEX1RA1AX32Q5K4DN7DMH5Z',\n", + " 'vector_distance': '0.657624304295',\n", " 'brand': 'Specialized',\n", " '$.metadata.type': 'Enduro bikes'}]" ] }, - "execution_count": 49, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -687,7 +714,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 24, "metadata": {}, "outputs": [], "source": [ @@ -697,7 +724,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "redisvl-VnTEShF2-py3.13", "language": "python", "name": "python3" }, @@ -711,7 +738,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.13.2" }, "orig_nbformat": 4 }, diff --git a/docs/user_guide/07_message_history.ipynb b/docs/user_guide/07_message_history.ipynb index baf6ee0c..279e2c71 100644 --- a/docs/user_guide/07_message_history.ipynb +++ b/docs/user_guide/07_message_history.ipynb @@ -22,17 +22,10 @@ "cell_type": "code", "execution_count": 1, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "12:24:11 redisvl.index.index INFO Index already exists, not overwriting.\n" - ] - } - ], + "outputs": [], "source": [ "from redisvl.extensions.message_history import MessageHistory\n", + "\n", "chat_history = MessageHistory(name='student tutor')" ] }, @@ -200,14 +193,38 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/tyler.hutcherson/Library/Caches/pypoetry/virtualenvs/redisvl-VnTEShF2-py3.13/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "12:24:15 redisvl.index.index INFO Index already exists, not overwriting.\n" + "16:52:21 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", + "16:52:21 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-mpnet-base-v2\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Batches: 100%|██████████| 1/1 [00:00<00:00, 6.25it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 3.21it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 11.70it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 13.56it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 59.68it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 63.31it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 8.70it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 13.22it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 59.67it/s]\n" ] } ], @@ -223,12 +240,25 @@ "execution_count": 7, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Batches: 100%|██████████| 1/1 [00:00<00:00, 62.76it/s]" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "{'role': 'user', 'content': 'what is the size of England compared to Portugal?'}\n", - "{'role': 'llm', 'content': 'England is larger in land area than Portal by about 15000 square miles.'}\n" + "{'role': 'user', 'content': 'what is the size of England compared to Portugal?'}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\n" ] } ], @@ -254,6 +284,13 @@ "execution_count": 8, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Batches: 100%|██████████| 1/1 [00:00<00:00, 61.35it/s]" + ] + }, { "name": "stdout", "output_type": "stream", @@ -261,7 +298,15 @@ "{'role': 'user', 'content': 'what is the size of England compared to Portugal?'}\n", "{'role': 'llm', 'content': 'England is larger in land area than Portal by about 15000 square miles.'}\n", "{'role': 'user', 'content': 'What is the population of Great Britain?'}\n", - "{'role': 'llm', 'content': 'As of 2023 the population of Great Britain is approximately 67 million people.'}\n" + "{'role': 'llm', 'content': 'As of 2023 the population of Great Britain is approximately 67 million people.'}\n", + "{'role': 'user', 'content': 'And what is the capital of Spain?'}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\n" ] } ], @@ -287,6 +332,14 @@ "execution_count": 9, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Batches: 100%|██████████| 1/1 [00:00<00:00, 61.00it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 8.48it/s]\n" + ] + }, { "name": "stdout", "output_type": "stream", @@ -303,7 +356,7 @@ "semantic_history.store(\n", " prompt=\"what is the smallest country in Europe?\",\n", " response=\"Monaco is the smallest country in Europe at 0.78 square miles.\" # Incorrect. Vatican City is the smallest country in Europe\n", - " )\n", + ")\n", "\n", "# get the key of the incorrect message\n", "context = semantic_history.get_recent(top_k=1, raw=True)\n", @@ -328,7 +381,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "redisvl-VnTEShF2-py3.13", "language": "python", "name": "python3" }, @@ -342,7 +395,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.2" + "version": "3.13.2" } }, "nbformat": 4, diff --git a/docs/user_guide/08_semantic_router.ipynb b/docs/user_guide/08_semantic_router.ipynb index 376e62a9..108b5136 100644 --- a/docs/user_guide/08_semantic_router.ipynb +++ b/docs/user_guide/08_semantic_router.ipynb @@ -32,7 +32,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -88,25 +88,33 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 2, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/tyler.hutcherson/Library/Caches/pypoetry/virtualenvs/redisvl-VnTEShF2-py3.13/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "19:18:32 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", - "19:18:32 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-mpnet-base-v2\n" + "16:52:49 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", + "16:52:49 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-mpnet-base-v2\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 17.78it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 37.43it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 27.28it/s]\n", - "Batches: 100%|██████████| 1/1 [00:00<00:00, 48.76it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 7.67it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 8.97it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 5.24it/s]\n", + "Batches: 100%|██████████| 1/1 [00:00<00:00, 48.90it/s]\n" ] } ], @@ -129,7 +137,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -163,7 +171,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -172,7 +180,7 @@ "11" ] }, - "execution_count": 25, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -190,23 +198,23 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 6.40it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 8.83it/s]\n" ] }, { "data": { "text/plain": [ - "RouteMatch(name='technology', distance=0.419145842393)" + "RouteMatch(name='technology', distance=0.419145941734)" ] }, - "execution_count": 26, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -219,14 +227,14 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 39.83it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 12.45it/s]\n" ] }, { @@ -235,7 +243,7 @@ "RouteMatch(name=None, distance=None)" ] }, - "execution_count": 27, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -255,24 +263,24 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 40.50it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 10.98it/s]\n" ] }, { "data": { "text/plain": [ - "[RouteMatch(name='technology', distance=0.556493878365),\n", - " RouteMatch(name='sports', distance=0.671060125033)]" + "[RouteMatch(name='technology', distance=0.556493639946),\n", + " RouteMatch(name='sports', distance=0.671060085297)]" ] }, - "execution_count": 28, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -285,24 +293,24 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 66.18it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 52.93it/s]\n" ] }, { "data": { "text/plain": [ - "[RouteMatch(name='technology', distance=0.556493878365),\n", + "[RouteMatch(name='technology', distance=0.556493639946),\n", " RouteMatch(name='sports', distance=0.629264354706)]" ] }, - "execution_count": 29, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -331,7 +339,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -344,23 +352,23 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 41.89it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 10.93it/s]\n" ] }, { "data": { "text/plain": [ - "[RouteMatch(name='sports', distance=0.663254022598)]" + "[RouteMatch(name='sports', distance=0.663253903389)]" ] }, - "execution_count": 31, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -379,7 +387,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -411,7 +419,7 @@ " 'routing_config': {'max_k': 3, 'aggregation_method': 'min'}}" ] }, - "execution_count": 32, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -422,29 +430,29 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:18:38 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", - "19:18:38 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-mpnet-base-v2\n" + "16:52:53 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", + "16:52:53 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-mpnet-base-v2\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 54.94it/s]" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 45.24it/s]" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "19:18:40 redisvl.index.index INFO Index already exists, not overwriting.\n" + "16:52:54 redisvl.index.index INFO Index already exists, not overwriting.\n" ] }, { @@ -463,7 +471,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -472,29 +480,29 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "19:18:40 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", - "19:18:40 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-mpnet-base-v2\n" + "16:52:54 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", + "16:52:54 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-mpnet-base-v2\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 18.77it/s]" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 53.94it/s]" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "19:18:41 redisvl.index.index INFO Index already exists, not overwriting.\n" + "16:52:54 redisvl.index.index INFO Index already exists, not overwriting.\n" ] }, { @@ -520,14 +528,14 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 100%|██████████| 1/1 [00:00<00:00, 13.22it/s]\n" + "Batches: 100%|██████████| 1/1 [00:00<00:00, 7.24it/s]\n" ] }, { @@ -537,7 +545,7 @@ " 'topic-router:technology:7e4bca5853c1c3298b4d001de13c3c7a79a6e0f134f81acc2e7cddbd6845961f']" ] }, - "execution_count": 36, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -555,35 +563,35 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[{'id': 'topic-router:technology:7e4bca5853c1c3298b4d001de13c3c7a79a6e0f134f81acc2e7cddbd6845961f',\n", - " 'reference_id': '7e4bca5853c1c3298b4d001de13c3c7a79a6e0f134f81acc2e7cddbd6845961f',\n", + "[{'id': 'topic-router:technology:85cc73a1437df27caa2f075a29c497e5a2e532023fbb75378aedbae80779ab37',\n", + " 'reference_id': '85cc73a1437df27caa2f075a29c497e5a2e532023fbb75378aedbae80779ab37',\n", " 'route_name': 'technology',\n", - " 'reference': 'new tech gadgets'},\n", + " 'reference': 'tell me about the newest gadgets'},\n", + " {'id': 'topic-router:technology:851f51cce5a9ccfbbcb66993908be6b7871479af3e3a4b139ad292a1bf7e0676',\n", + " 'reference_id': '851f51cce5a9ccfbbcb66993908be6b7871479af3e3a4b139ad292a1bf7e0676',\n", + " 'route_name': 'technology',\n", + " 'reference': 'what are the latest advancements in AI?'},\n", " {'id': 'topic-router:technology:f243fb2d073774e81c7815247cb3013794e6225df3cbe3769cee8c6cefaca777',\n", " 'reference_id': 'f243fb2d073774e81c7815247cb3013794e6225df3cbe3769cee8c6cefaca777',\n", " 'route_name': 'technology',\n", " 'reference': 'latest AI trends'},\n", - " {'id': 'topic-router:technology:851f51cce5a9ccfbbcb66993908be6b7871479af3e3a4b139ad292a1bf7e0676',\n", - " 'reference_id': '851f51cce5a9ccfbbcb66993908be6b7871479af3e3a4b139ad292a1bf7e0676',\n", + " {'id': 'topic-router:technology:7e4bca5853c1c3298b4d001de13c3c7a79a6e0f134f81acc2e7cddbd6845961f',\n", + " 'reference_id': '7e4bca5853c1c3298b4d001de13c3c7a79a6e0f134f81acc2e7cddbd6845961f',\n", " 'route_name': 'technology',\n", - " 'reference': 'what are the latest advancements in AI?'},\n", + " 'reference': 'new tech gadgets'},\n", " {'id': 'topic-router:technology:149a9c9919c58534aa0f369e85ad95ba7f00aa0513e0f81e2aff2ea4a717b0e0',\n", " 'reference_id': '149a9c9919c58534aa0f369e85ad95ba7f00aa0513e0f81e2aff2ea4a717b0e0',\n", " 'route_name': 'technology',\n", - " 'reference': \"what's trending in tech?\"},\n", - " {'id': 'topic-router:technology:85cc73a1437df27caa2f075a29c497e5a2e532023fbb75378aedbae80779ab37',\n", - " 'reference_id': '85cc73a1437df27caa2f075a29c497e5a2e532023fbb75378aedbae80779ab37',\n", - " 'route_name': 'technology',\n", - " 'reference': 'tell me about the newest gadgets'}]" + " 'reference': \"what's trending in tech?\"}]" ] }, - "execution_count": 37, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -596,19 +604,19 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[{'id': 'topic-router:technology:7e4bca5853c1c3298b4d001de13c3c7a79a6e0f134f81acc2e7cddbd6845961f',\n", - " 'reference_id': '7e4bca5853c1c3298b4d001de13c3c7a79a6e0f134f81acc2e7cddbd6845961f',\n", + "[{'id': 'topic-router:technology:85cc73a1437df27caa2f075a29c497e5a2e532023fbb75378aedbae80779ab37',\n", + " 'reference_id': '85cc73a1437df27caa2f075a29c497e5a2e532023fbb75378aedbae80779ab37',\n", " 'route_name': 'technology',\n", - " 'reference': 'new tech gadgets'}]" + " 'reference': 'tell me about the newest gadgets'}]" ] }, - "execution_count": 38, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -628,7 +636,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -637,7 +645,7 @@ "5" ] }, - "execution_count": 39, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -650,7 +658,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 19, "metadata": {}, "outputs": [ { @@ -659,7 +667,7 @@ "1" ] }, - "execution_count": 40, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -679,7 +687,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -689,7 +697,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 21, "metadata": {}, "outputs": [], "source": [ @@ -700,7 +708,7 @@ ], "metadata": { "kernelspec": { - "display_name": "redisvl-dev", + "display_name": "redisvl-VnTEShF2-py3.13", "language": "python", "name": "python3" }, @@ -714,7 +722,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.0" + "version": "3.13.2" }, "orig_nbformat": 4 }, diff --git a/docs/user_guide/09_threshold_optimization.ipynb b/docs/user_guide/09_threshold_optimization.ipynb index 071f7fbc..e7948e2e 100644 --- a/docs/user_guide/09_threshold_optimization.ipynb +++ b/docs/user_guide/09_threshold_optimization.ipynb @@ -27,7 +27,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "/Users/justin.cechmanek/.pyenv/versions/3.13/envs/redisvl-dev/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + "/Users/tyler.hutcherson/Library/Caches/pypoetry/virtualenvs/redisvl-VnTEShF2-py3.13/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] }, @@ -35,18 +35,21 @@ "name": "stdout", "output_type": "stream", "text": [ - "16:16:11 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", - "16:16:11 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: redis/langcache-embed-v1\n" + "16:53:13 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n", + "16:53:13 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: redis/langcache-embed-v1\n", + "16:53:13 sentence_transformers.SentenceTransformer WARNING You try to use a model that was created with version 4.1.0, however, your version is 3.4.1. This might cause unexpected behavior or errors. In that case, try to update to the latest version.\n", + "\n", + "\n", + "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "Batches: 0%| | 0/1 [00:00"] license = "MIT" diff --git a/redisvl/extensions/cache/llm/semantic.py b/redisvl/extensions/cache/llm/semantic.py index 2d27ca36..8d0a4f40 100644 --- a/redisvl/extensions/cache/llm/semantic.py +++ b/redisvl/extensions/cache/llm/semantic.py @@ -31,6 +31,7 @@ validate_vector_dims, ) from redisvl.utils.vectorize.base import BaseVectorizer +from redisvl.utils.vectorize.text.huggingface import HFTextVectorizer logger = get_logger("[RedisVL]") @@ -104,24 +105,12 @@ def __init__( ) self._vectorizer = vectorizer else: - from redisvl.utils.vectorize.text.huggingface import HFTextVectorizer - - # Create a default vectorizer + # Create the default vectorizer vectorizer_kwargs = kwargs + if dtype: vectorizer_kwargs.update(dtype=dtype) - # raise a warning to inform users we changed the default model - # remove this warning in future releases - logger.warning( - "The default vectorizer has changed from `sentence-transformers/all-mpnet-base-v2` " - "to `redis/langcache-embed-v1` in version 0.6.0 of RedisVL. " - "For more information about this model, please refer to https://arxiv.org/abs/2504.02268 " - "or visit https://huggingface.co/redis/langcache-embed-v1. " - "To continue using the old vectorizer, please specify it explicitly in the constructor as: " - "vectorizer=HFTextVectorizer(model='sentence-transformers/all-mpnet-base-v2')" - ) - self._vectorizer = HFTextVectorizer( model="redis/langcache-embed-v1", **vectorizer_kwargs, diff --git a/redisvl/version.py b/redisvl/version.py index 906d362f..49e0fc1e 100644 --- a/redisvl/version.py +++ b/redisvl/version.py @@ -1 +1 @@ -__version__ = "0.6.0" +__version__ = "0.7.0"