Skip to content

doc: Support for generation of Jumpstart model table on build #2924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ed7dce3
Add deprecation warning in Clarify DataConfig (#2847)
keerthanvasist Jan 26, 2022
7a347c7
feature: Update instance types for integ test (#2881)
jeniyat Jan 29, 2022
34b07c0
feature: Adds support for async inference (#2846)
bhaoz Jan 29, 2022
4d0bfed
doc: added support for generation of jumpstart model table on build
bencrabtree Feb 1, 2022
1f9b88f
test: update linting
bencrabtree Feb 1, 2022
f94245c
fix: use request url so that we dont have to pass aws creds
bencrabtree Feb 2, 2022
90b0b0f
fix: update to incorporate black v22, pin tox versions (#2889)
jeniyat Feb 3, 2022
858a0dc
Merge branch 'dev' into feat/jumpstart-docs-model-table
mufaddal-rohawala Feb 3, 2022
4886405
fix: set sagemaker_connection and image_uri in register method (#2526)
iasoon Feb 3, 2022
7203862
feature: JumpStart Integration (#2870)
evakravi Feb 3, 2022
89b682f
documentation: Add Jumpstart support documentation (#2890)
IvyBazan Feb 3, 2022
7979d97
fix: black check to lint files
bencrabtree Feb 3, 2022
e5d785b
Merge branch 'feat/jumpstart-docs-model-table' of github.com:bencrabt…
bencrabtree Feb 3, 2022
bb3d3fa
fix: unit tests
bencrabtree Feb 3, 2022
b0891fa
fix: unit tests 2
bencrabtree Feb 3, 2022
6987b5b
fix: passing linter for import
bencrabtree Feb 3, 2022
86b2b57
fix: sphinx import
bencrabtree Feb 3, 2022
b0c1706
Merge branch 'dev' of https://github.com/aws/sagemaker-python-sdk int…
bencrabtree Feb 3, 2022
6cc1212
fix: reference jumpstart.rst
bencrabtree Feb 3, 2022
de88492
fix: add jumpstart to ctree
bencrabtree Feb 3, 2022
0b6fb78
fix: pin pytest-xdist to avoid release failures (#2896)
mufaddal-rohawala Feb 4, 2022
57ade33
fix: jumpstart typo (#2895)
evakravi Feb 4, 2022
e3398d9
documentation: Jumpstart doc strings and added new sections (#2893)
evakravi Feb 4, 2022
f05b04e
Merge branch 'dev' of https://github.com/aws/sagemaker-python-sdk int…
bencrabtree Feb 4, 2022
7932372
fix: update link and some logic
bencrabtree Feb 7, 2022
11aea41
fix: linting issue
bencrabtree Feb 7, 2022
44ad05e
fix: lint
bencrabtree Feb 7, 2022
9038820
Merge branch 'dev' into feat/jumpstart-docs-model-table
bencrabtree Feb 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

import pkg_resources
from datetime import datetime
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), "."))
from doc_utils.jumpstart_doc_utils import create_jumpstart_model_table # noqa: E402

project = "sagemaker"
version = pkg_resources.require(project)[0].version
Expand Down Expand Up @@ -71,6 +76,12 @@
# For Adobe Analytics
html_js_files = [
"https://a0.awsstatic.com/s_code/js/3.0/awshome_s_code.js",
"https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js",
"js/datatable.js",
]

html_css_files = [
"https://cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css",
]

html_context = {"css_files": ["_static/theme_overrides.css"]}
Expand All @@ -83,3 +94,7 @@

# autosectionlabel
autosectionlabel_prefix_document = True


def setup(app):
create_jumpstart_model_table()
Empty file added doc/doc_utils/__init__.py
Empty file.
Empty file added doc/doc_utils/jumpstart.rst
Empty file.
89 changes: 89 additions & 0 deletions doc/doc_utils/jumpstart_doc_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
from __future__ import absolute_import
from urllib import request
import json
from packaging.version import Version

JUMPSTART_REGION = "eu-west-2"
SDK_MANIFEST_FILE = "models_manifest.json"
JUMPSTART_BUCKET_BASE_URL = "https://jumpstart-cache-prod-{}.s3.{}.amazonaws.com".format(
JUMPSTART_REGION, JUMPSTART_REGION
)


def get_jumpstart_sdk_manifest():
url = "{}/{}".format(JUMPSTART_BUCKET_BASE_URL, SDK_MANIFEST_FILE)
with request.urlopen(url) as f:
models_manifest = f.read().decode("utf-8")
return json.loads(models_manifest)


def get_jumpstart_sdk_spec(key):
url = "{}/{}".format(JUMPSTART_BUCKET_BASE_URL, key)
with request.urlopen(url) as f:
model_spec = f.read().decode("utf-8")
return json.loads(model_spec)


def create_jumpstart_model_table():
sdk_manifest = get_jumpstart_sdk_manifest()
sdk_manifest_top_versions_for_models = {}

for model in sdk_manifest:
if model["model_id"] not in sdk_manifest_top_versions_for_models:
sdk_manifest_top_versions_for_models[model["model_id"]] = model
else:
if Version(
sdk_manifest_top_versions_for_models[model["model_id"]]["version"]
) < Version(model["version"]):
sdk_manifest_top_versions_for_models[model["model_id"]] = model

file_content = []

file_content.append("==================================\n")
file_content.append("JumpStart Available Model Table\n")
file_content.append("==================================\n")
file_content.append(
"""
JumpStart for the SageMaker Python SDK uses model ids and model versions to access the necessary
utilities. This table serves to provide the core material plus some extra information that can be useful
in selecting the correct model id and corresponding parameters.\n
"""
)
file_content.append(
"""
If you want to automatically use the latest version of the model, use "*" for the `model_version` attribute.
We highly suggest pinning an exact model version however.\n
"""
)
file_content.append("\n")
file_content.append(".. list-table:: Available Models\n")
file_content.append(" :widths: 50 20 20 20\n")
file_content.append(" :header-rows: 1\n")
file_content.append(" :class: datatable\n")
file_content.append("\n")
file_content.append(" * - Model ID\n")
file_content.append(" - Fine Tunable?\n")
file_content.append(" - Latest Version\n")
file_content.append(" - Min SDK Version\n")

for model in sorted(sdk_manifest, key=lambda elt: elt["model_id"]):
model_spec = get_jumpstart_sdk_spec(model["spec_key"])
file_content.append(" * - {}\n".format(model["model_id"]))
file_content.append(" - {}\n".format(model_spec["training_supported"]))
file_content.append(" - {}\n".format(model["version"]))
file_content.append(" - {}\n".format(model["min_version"]))

f = open("doc_utils/jumpstart.rst", "w")
f.writelines(file_content)
98 changes: 51 additions & 47 deletions doc/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,11 @@ Here is an example:
Use Prebuilt Models with SageMaker JumpStart
********************************************

.. toctree::
:maxdepth: 2

doc_utils/jumpstart

`Amazon SageMaker JumpStart <https://aws.amazon.com/sagemaker/getting-started/>`__ is a
SageMaker feature that helps users bring machine learning (ML)
applications to market using prebuilt solutions for common use cases,
Expand Down Expand Up @@ -628,11 +633,11 @@ the ``model_id`` and ``model_version`` needed to retrieve the URI.

- ``model_id``: A unique identifier for the JumpStart model.
- ``model_version``: The version of the specifications for the
model. To use the latest version, enter ``*``. This is a
model. To use the latest version, enter ``"*"``. This is a
required parameter.

To retrieve a model, first select a ``model id`` and ``version`` from
the Available Models.
the :doc:`available models <./doc_utils/jumpstart>`.

.. code:: python

Expand All @@ -652,7 +657,7 @@ Then use those values to retrieve the model as follows.
JumpStart scripts
-----------------

To adapt JumpStart models for the SageMaker Python SDK, a custom
To adapt JumpStart models for SageMaker, a custom
script is needed to perform training or inference. JumpStart
maintains a suite of scripts used for each of the models in the
JumpStart S3 bucket, which can be accessed using the SageMaker Python
Expand Down Expand Up @@ -769,7 +774,7 @@ Deployment may take about 5 minutes.
   predictor_cls=Predictor
)

Because ``catboost`` relies on the PyTorch Deep Learning Containers
Because ``catboost`` and ``lightgbm`` rely on the PyTorch Deep Learning Containers
image, the corresponding Models and Endpoints display the “pytorch”
prefix when viewed in the AWS console. To verify that these models
were created successfully with your desired base model, refer to
Expand All @@ -780,7 +785,7 @@ Perform Inference

Finally, use the ``predictor`` instance to query your endpoint. For
``catboost-classification-model``, for example, the predictor accepts
a string. For more information about how to use the predictor, see
a csv. For more information about how to use the predictor, see
the
`Appendix <https://sagemaker.readthedocs.io/en/stable/overview.html#appendix>`__.

Expand All @@ -807,9 +812,8 @@ using “training” as the model scope. Use the utility functions to
retrieve the URI of each of the three components you need to
continue. The HuggingFace model in this example requires a GPU
instance, so use the ``ml.p3.2xlarge`` instance type. For a complete
list of available SageMaker instance types , see `Available SageMaker
Studio Instance
Types <https://docs.aws.amazon.com/sagemaker/latest/dg/notebooks-available-instance-types.html>`__.
list of available SageMaker instance types, see the `SageMaker On-Demand Pricing
Table <https://aws.amazon.com/sagemaker/pricing/#On-Demand_Pricing>`__ and select 'Training'.

.. code:: python

Expand Down Expand Up @@ -970,45 +974,45 @@ ContentType of ``application/list-text``.

.. container::

+-----------------------+-----------------------+-----------------------+
| Task | Identifier | ContentType |
+-----------------------+-----------------------+-----------------------+
| Image Classification | ic | "application/x-image" |
+-----------------------+-----------------------+-----------------------+
| Object Detection | od, od1 | "application/x-image" |
+-----------------------+-----------------------+-----------------------+
| Semantic Segmentation | semseg | "application/x-image" |
+-----------------------+-----------------------+-----------------------+
| Instance Segmentation | is | "application/x-image" |
+-----------------------+-----------------------+-----------------------+
| Text Classification | tc | "application/x-text" |
+-----------------------+-----------------------+-----------------------+
| Sentence Pair | spc | "a |
| Classification | | pplication/list-text" |
+-----------------------+-----------------------+-----------------------+
| Extractive Question | eqa | "a |
| Answering | | pplication/list-text" |
+-----------------------+-----------------------+-----------------------+
| Text Generation | textgeneration | "application/x-text" |
+-----------------------+-----------------------+-----------------------+
| Image Classification | icembedding | "application/x-image" |
| Embedding | | |
+-----------------------+-----------------------+-----------------------+
| Text Classification | tcembedding | "application/x-text" |
| Embedding | | |
+-----------------------+-----------------------+-----------------------+
| Named-entity | ner | "application/x-text" |
| Recognition | | |
+-----------------------+-----------------------+-----------------------+
| Text Summarization | summarization | "application/x-text" |
+-----------------------+-----------------------+-----------------------+
| Text Translation | translation | "application/x-text" |
+-----------------------+-----------------------+-----------------------+
| Tabular Regression | regression | "text/csv" |
+-----------------------+-----------------------+-----------------------+
| Tabular | classification | "text/csv" |
| Classification | | |
+-----------------------+-----------------------+-----------------------+
+-----------------------+-----------------------+-------------------------+
| Task | Identifier | ContentType |
+-----------------------+-----------------------+-------------------------+
| Image Classification | ic | "application/x-image" |
+-----------------------+-----------------------+-------------------------+
| Object Detection | od, od1 | "application/x-image" |
+-----------------------+-----------------------+-------------------------+
| Semantic Segmentation | semseg | "application/x-image" |
+-----------------------+-----------------------+-------------------------+
| Instance Segmentation | is | "application/x-image" |
+-----------------------+-----------------------+-------------------------+
| Text Classification | tc | "application/x-text" |
+-----------------------+-----------------------+-------------------------+
| Sentence Pair | spc | "application/list-text" |
| Classification | | |
+-----------------------+-----------------------+-------------------------+
| Extractive Question | eqa | "application/list-text" |
| Answering | | |
+-----------------------+-----------------------+-------------------------+
| Text Generation | textgeneration | "application/x-text" |
+-----------------------+-----------------------+-------------------------+
| Image Classification | icembedding | "application/x-image" |
| Embedding | | |
+-----------------------+-----------------------+-------------------------+
| Text Classification | tcembedding | "application/x-text" |
| Embedding | | |
+-----------------------+-----------------------+-------------------------+
| Named-entity | ner | "application/x-text" |
| Recognition | | |
+-----------------------+-----------------------+-------------------------+
| Text Summarization | summarization | "application/x-text" |
+-----------------------+-----------------------+-------------------------+
| Text Translation | translation | "application/x-text" |
+-----------------------+-----------------------+-------------------------+
| Tabular Regression | regression | "text/csv" |
+-----------------------+-----------------------+-------------------------+
| Tabular | classification | "text/csv" |
| Classification | | |
+-----------------------+-----------------------+-------------------------+

********************************
SageMaker Automatic Model Tuning
Expand Down
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sphinx==3.1.1
sphinx-rtd-theme==0.5.0
docutils==0.15.2
packaging==20.9