Skip to content

Commit

Permalink
docs: Update the get started docs (#4513)
Browse files Browse the repository at this point in the history
Update the get started docs

Signed-off-by: Sherlock113 <sherlockxu07@gmail.com>
  • Loading branch information
Sherlock113 committed Feb 20, 2024
1 parent 6c2ac38 commit 89adfb2
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 71 additions & 1 deletion docs/source/bentocloud/get-started.rst
Expand Up @@ -43,7 +43,77 @@ Once you have your BentoCloud account, do the following to get started:
2. Create an :doc:`API token with Developer Operations Access </bentocloud/how-tos/manage-access-token>`.
3. Log in to BentoCloud with the ``bentoml cloud login`` command, which will be displayed on the BentoCloud console after you create the API token.

Now, you can try an `example project and deploy it to BentoCloud <https://github.com/bentoml/quickstart>`_.
Deploy your first model
-----------------------

Perform the following steps to quickly deploy an example application on BentoCloud. It is a summarization service powered by a Transformer model `sshleifer/distilbart-cnn-12-6 <https://huggingface.co/sshleifer/distilbart-cnn-12-6>`_.

1. Install the dependencies.

.. code-block:: bash
pip install bentoml torch transformers
2. Create a BentoML Service in a ``service.py`` file as below. The pre-trained model is pulled from Hugging Face.

.. code-block:: python
from __future__ import annotations
import bentoml
from transformers import pipeline
EXAMPLE_INPUT = "Breaking News: In an astonishing turn of events, the small \
town of Willow Creek has been taken by storm as local resident Jerry Thompson's cat, \
Whiskers, performed what witnesses are calling a 'miraculous and gravity-defying leap.' \
Eyewitnesses report that Whiskers, an otherwise unremarkable tabby cat, jumped \
a record-breaking 20 feet into the air to catch a fly. The event, which took \
place in Thompson's backyard, is now being investigated by scientists for potential \
breaches in the laws of physics. Local authorities are considering a town festival \
to celebrate what is being hailed as 'The Leap of the Century."
@bentoml.service(
resources={"cpu": "2"},
traffic={"timeout": 10},
)
class Summarization:
def __init__(self) -> None:
self.pipeline = pipeline('summarization')
@bentoml.api
def summarize(self, text: str = EXAMPLE_INPUT) -> str:
result = self.pipeline(text)
return result[0]['summary_text']
.. note::

You can test this Service locally by running ``bentoml serve service:Summarization``. For details of the Service, see :doc:`/get-started/quickstart`.

3. Create a ``bentofile.yaml`` file as below.

.. code-block:: yaml
service: 'service:Summarization'
labels:
owner: bentoml-team
project: gallery
include:
- '*.py'
python:
packages:
- torch
- transformers
4. Deploy the application to BentoCloud. The deployment status is displayed both in your terminal and the BentoCloud console.

.. code-block:: bash
bentoml deploy .
5. On the BentoCloud console, navigate to the **Deployments** page, and click your Deployment. Once it is up and running, interact with it using the Form, BentoML Python client, or CURL command on the **Playground** tab. The sample input already provides a new article and you can summarize it with the application.

.. image:: ../_static/img/bentocloud/get-started/bentocloud-playground-quickstart.png

Resources
---------
Expand Down

0 comments on commit 89adfb2

Please sign in to comment.