Example
HTTP
Create HTTP APIs that respond to prediction requests in real-time.
Implement
mkdir text-generator && cd text-generator
touch predictor.py requirements.txt text_generator.yaml# predictor.py
from transformers import pipeline
class PythonPredictor:
def __init__(self, config):
self.model = pipeline(task="text-generation")
def predict(self, payload):
return self.model(payload["text"])[0]# requirements.txt
transformers
torchDeploy
Monitor
Stream logs
Make a request
Delete
gRPC
To make the above API use gRPC as its protocol, make the following changes (the rest of the steps are the same):
Add protobuf file
Create a predictor.proto file in your project's directory:
Set the predictor.protobuf_path field in the API spec to point to the predictor.proto file:
Make a gRPC request
Last updated