This is an example of how to deploy a PyTorch model on GCP AI platform.
Download a pre-trained model and labels into models/ dir:
mkdir models/| # This code is an example of using Apache Beam with a VLLM model handler. | |
| from typing import Iterable | |
| from apache_beam.ml.inference.base import RunInference, KeyedModelHandler | |
| from apache_beam.ml.inference.vllm_inference import ( | |
| VLLMChatModelHandler, | |
| OpenAIChatMessage, | |
| ) | |
| from apache_beam.ml.inference.base import PredictionResult | |
| import apache_beam as beam |
| import io | |
| import xml.etree.ElementTree as ET | |
| class BaseElement(ET.Element): | |
| def __init__(self, tag, attrib={}, **extra): | |
| super(BaseElement, self).__init__(tag, attrib=attrib, **extra) | |
| self._parent = None | |
| @property | |
| def parent(self): |