{ "cells": [ { "cell_type": "code", "execution_count": 10, "id": "b3685e1d-9d66-4b38-867c-987f7b1af699", "metadata": { "scrolled": true, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Looking in indexes: https://pypi.org/simple, https://pip.repos.neuron.amazonaws.com\n", "Collecting ezsmdeploy==1.96.dev0\n", " Downloading ezsmdeploy-1.96.dev0-py3-none-any.whl (30 kB)\n", "Requirement already satisfied: sagemaker==2.173.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ezsmdeploy==1.96.dev0) (2.173.0)\n", "Requirement already satisfied: yaspin==0.16.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ezsmdeploy==1.96.dev0) (0.16.0)\n", "Requirement already satisfied: shortuuid==1.0.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ezsmdeploy==1.96.dev0) (1.0.1)\n", "Requirement already satisfied: sagemaker-studio-image-build==0.5.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ezsmdeploy==1.96.dev0) (0.5.0)\n", "Requirement already satisfied: boto3>=1.14.12 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ezsmdeploy==1.96.dev0) (1.26.157)\n", "Requirement already satisfied: attrs<24,>=23.1.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (23.1.0)\n", "Requirement already satisfied: cloudpickle==2.2.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (2.2.1)\n", "Requirement already satisfied: google-pasta in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (0.2.0)\n", "Requirement already satisfied: numpy<2.0,>=1.9.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (1.22.3)\n", "Requirement already satisfied: protobuf<5.0,>=3.12 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (3.20.3)\n", "Requirement already satisfied: smdebug-rulesconfig==1.0.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (1.0.1)\n", "Requirement already satisfied: importlib-metadata<7.0,>=1.4.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (4.13.0)\n", "Requirement already satisfied: packaging>=20.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (21.3)\n", "Requirement already satisfied: pandas in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (2.0.1)\n", "Requirement already satisfied: pathos in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (0.3.0)\n", "Requirement already satisfied: schema in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (0.7.5)\n", "Requirement already satisfied: PyYAML~=6.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (6.0)\n", "Requirement already satisfied: jsonschema in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (4.17.3)\n", "Requirement already satisfied: platformdirs in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (3.5.0)\n", "Requirement already satisfied: tblib==1.7.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (1.7.0)\n", "Requirement already satisfied: botocore<1.30.0,>=1.29.157 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from boto3>=1.14.12->ezsmdeploy==1.96.dev0) (1.29.157)\n", "Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from boto3>=1.14.12->ezsmdeploy==1.96.dev0) (1.0.1)\n", "Requirement already satisfied: s3transfer<0.7.0,>=0.6.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from boto3>=1.14.12->ezsmdeploy==1.96.dev0) (0.6.1)\n", "Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from botocore<1.30.0,>=1.29.157->boto3>=1.14.12->ezsmdeploy==1.96.dev0) (2.8.2)\n", "Requirement already satisfied: urllib3<1.27,>=1.25.4 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from botocore<1.30.0,>=1.29.157->boto3>=1.14.12->ezsmdeploy==1.96.dev0) (1.26.14)\n", "Requirement already satisfied: zipp>=0.5 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from importlib-metadata<7.0,>=1.4.0->sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (3.15.0)\n", "Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from packaging>=20.0->sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (3.0.9)\n", "Requirement already satisfied: six in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from google-pasta->sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (1.16.0)\n", "Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from jsonschema->sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (0.19.3)\n", "Requirement already satisfied: pytz>=2020.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from pandas->sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (2023.3)\n", "Requirement already satisfied: tzdata>=2022.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from pandas->sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (2023.3)\n", "Requirement already satisfied: ppft>=1.7.6.6 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from pathos->sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (1.7.6.6)\n", "Requirement already satisfied: dill>=0.3.6 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from pathos->sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (0.3.6)\n", "Requirement already satisfied: pox>=0.3.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from pathos->sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (0.3.2)\n", "Requirement already satisfied: multiprocess>=0.70.14 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from pathos->sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (0.70.14)\n", "Requirement already satisfied: contextlib2>=0.5.5 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from schema->sagemaker==2.173.0->ezsmdeploy==1.96.dev0) (21.6.0)\n", "Installing collected packages: ezsmdeploy\n", " Attempting uninstall: ezsmdeploy\n", " Found existing installation: ezsmdeploy 1.95.dev0\n", " Uninstalling ezsmdeploy-1.95.dev0:\n", " Successfully uninstalled ezsmdeploy-1.95.dev0\n", "Successfully installed ezsmdeploy-1.96.dev0\n" ] } ], "source": [ "%pip uninstall -y ezsmdeploy --quiet\n", "# !pip install --upgrade pip\n", "%pip install ezsmdeploy==2.0.0" ] }, { "cell_type": "code", "execution_count": 1, "id": "39588b3c-d7c8-41a9-909a-084574445f31", "metadata": { "tags": [] }, "outputs": [], "source": [ "import ezsmdeploy" ] }, { "cell_type": "code", "execution_count": 2, "id": "e4e3f085-642e-4035-abcb-7fe4cda63a79", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[K0:00:00.443265 | created model(s). Now deploying on ml.g5.2xlarge\n", "\u001b[K0:06:33.302085 | deployed model\n", "\u001b[K\u001b[32m0:06:33.302185 | Done! ✔\u001b[0m \n" ] } ], "source": [ "ezonsm = ezsmdeploy.Deploy(model=\"meta-textgeneration-llama-2-7b-f\",\n", " foundation_model=True)" ] }, { "cell_type": "code", "execution_count": 7, "id": "5758b8b0-98d3-4899-9bfa-982d98584460", "metadata": { "tags": [] }, "outputs": [], "source": [ "payload = {\n", " \"inputs\": \n", " [\n", " [\n", " {\"role\": \"system\", \"content\": \"Always answer with Haiku\"},\n", " {\"role\": \"user\", \"content\": \"I am going to Paris, what should I see?\"},\n", " ] \n", " ],\n", " \"parameters\":{\"max_new_tokens\":256, \"top_p\":0.9, \"temperature\":0.6}\n", "}" ] }, { "cell_type": "code", "execution_count": 8, "id": "1b2a40c0-7b4f-4ab9-a1a8-c6137c8e3e76", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "[{'generation': {'role': 'assistant',\n", " 'content': \" Eiffel Tower high\\nLove locks on Seine's banks\\nCity of lights shines\"}}]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ezonsm.predictor.predict(payload, custom_attributes=\"accept_eula=true\")" ] }, { "cell_type": "code", "execution_count": 11, "id": "00f6e434-971a-439b-9531-6a5de976b27e", "metadata": { "tags": [] }, "outputs": [], "source": [ "ezonsm.predictor.delete_endpoint()" ] }, { "cell_type": "code", "execution_count": null, "id": "f51d731e-c37a-49ed-bcf8-8e0d3313d45b", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "conda_python3", "language": "python", "name": "conda_python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.10" } }, "nbformat": 4, "nbformat_minor": 5 }