Kafka SpaCy SKlearn NLP
In this model we will build upon the code from the Seldon SpaCy NLP example for text classification.
You will learn how to deploy the model using the Kafka protocol.
Requirements
In your commands:
helm 3.x
kubectl
In cluster:
Install Kafka as per the instructions below
Setup Kafka
Ensure your helm repo has access to the strimzi Kafka charts which we'll use to install.
!helm repo add strimzi https://strimzi.io/charts/"strimzi" has been added to your repositoriesInstall the Kafka operator in your cluster
!helm install my-release strimzi/strimzi-kafka-operatorNAME: my-release
LAST DEPLOYED: Tue Sep 29 08:31:41 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for installing strimzi-kafka-operator-0.19.0
To create a Kafka cluster refer to the following documentation.
https://strimzi.io/docs/operators/0.19.0/using.html#deploying-cluster-operator-helm-chart-strWe now create a kafka cluster instantiation with a simple setup as outlined below.
We can now check that kafka was installed correctly
Create topics
We now need to create the input and output topics for our reddit classifier
Train Spacy Sklearn Model
To train the spacy sklearn model you can follow the instructions in the SKlearn Spacy Model Example.
Alternatively you can just use the image that is saved in the seldon dockerhub with the image seldonio/reddit-classifier:0.1
Deploy SpaCy Text Classifier
Now we're able to define the YAML that will be used to deploy the configuration.
We can confirm that now the model is running as expected:
Send real time data for stream processing
We can now send real time data for stream processing.
Below we send a single input with the text "This is an input", which will be consumed from the input topic.
Check the data processed
We now are able to see all the data that has been pushed to the output topic reddit-classifier-output.
This allows us to see all the inputs that have been processed. We will be listening for 10 seconds to ensure all data is found.
Last updated
Was this helpful?