Generic container for deploying pickled python prediction functions
4.4K
Clipper is a prediction serving system that sits between user-facing applications and a wide range of commonly used machine learning models and frameworks. Learn more about Clipper and view documentation at our website http://clipper.ai.
Clipper simplifies integration of machine learning techniques into user facing applications by providing a simple standard REST interface for prediction and feedback across a wide range of commonly used machine learning frameworks. Clipper makes product teams happy.
Clipper simplifies model deployment and helps reduce common bugs by using the same tools and libraries used in model development to render live predictions. Clipper makes data scientists happy.
Clipper improves throughput and ensures reliable millisecond latencies by introducing adaptive batching, caching, and straggler mitigation techniques. Clipper makes the infra-team less unhappy.
Clipper improves prediction accuracy by introducing state-of-the-art bandit and ensemble methods to intelligently select and combine predictions and achieve real-time personalization across machine learning frameworks. Clipper makes users happy.
Note: This quickstart works for the latest version of code. For a quickstart that works with the released version of Clipper available on PyPi, go to our website
This quickstart requires Docker and Docker Compose.
# From the root of the Clipper repo
$ pip install -e .
$ python
>>> from clipper_admin import Clipper
>>> import numpy as np
# Start a Clipper instance on localhost
>>> clipper = Clipper("localhost")
Checking if Docker is running...
# Start Clipper. Running this command for the first time will
# download several Docker containers, so it may take some time.
>>> clipper.start()
Clipper is running
# Register an application called "hello_world". This will create
# a prediction REST endpoint at http://localhost:1337/hello_world/predict
>>> clipper.register_application("hello_world", "doubles", "-1.0", 100000)
Success!
# Inspect Clipper to see the registered apps
>>> clipper.get_all_apps()
[u'hello_world']
# Define a simple model that just returns the sum of each feature vector.
# Note that the prediction function takes a list of feature vectors as
# input and returns a list of strings.
>>> def feature_sum_function(xs):
return [str(np.sum(x)) for x in xs]
# Deploy the model, naming it "feature_sum_model" and giving it version 1
>>> clipper.deploy_predict_function("feature_sum_model", 1, feature_sum_function, "doubles")
# Let Clipper know that queries to your app should be served by
# your newly deployed model.
>>> clipper.link_model_to_app("hello_world", "feature_sum_model")
Success!
Now that you've deployed your first model, you can start requesting predictions at the
REST endpoint that clipper created for your application:
http://localhost:1337/hello_world/predict
With curl:
$ curl -X POST --header "Content-Type:application/json" -d '{"uid": 0, "input": [1.1, 2.2, 3.3]}' 127.0.0.1:1337/hello_world/predict
From a Python REPL:
>>> import requests, json, numpy as np
>>> headers = {"Content-type": "application/json"}
>>> requests.post("http://localhost:1337/hello_world/predict", headers=headers, data=json.dumps({"uid": 0, "input": list(np.random.random(10))})).json()
To file a bug or request a feature, please file a GitHub issue. Pull requests are welcome. Additional help and instructions for contributors can be found on our website at http://clipper.ai/contributing.
You can contact us at [email protected]
This research is supported in part by DHS Award HSHQDC-16-3-00083, DOE Award SN10040 DE-SC0012463, NSF CISE Expeditions Award CCF-1139158, and gifts from Ant Financial, Amazon Web Services, CapitalOne, Ericsson, GE, Google, Huawei, Intel, IBM, Microsoft and VMware.
docker pull clipper/python-container:latest