Reuters Newswire Recommendation
This example will take you through creating a simple recommendation service for the the Reuters-21578 newswire dataset. It will create a simple static document similarity algorithm run as a microservice through the Seldon API server.
- Create Reuters client and meta-data
- Create recommendation model
- Create microservice
- Serve recommendations
- Next Steps
- You have installed Seldon on a Kubernetes cluster
- You haved added
seldon-server/kubernetes/binto you shell PATH environment variable.
The first step is to create a Reuters Seldon client and import the meta-data for the items we want to recommend into the Seldon database. These tasks are all packaged into a Docker container
seldonio/examples-reuters-data whose source can be found in
docker/examples/reuters/data. The tasks run are:
- Create a JSON file describing the meta-data attributes
- Create a CSV of the meta data from the downloaded Reuters data
- Use the seldon-cli to:
- Create a client “reuters”
- Upload its meta-data definitions into the db
- Load the meta-data itself into the db
The Docker container can be run as a one-off Kubernetes job to carry out the tasks:
Check for successful completion using
kubectl get jobs -l job-name=reuters-import-data which should show:
You can delete the job once its run with
kubectl delete -f import-data-job.json
For this simple example we will build a document similarity model to provide recommendations for newswire article given the current newswire article a user is reading. For this we will build a gensim document similarity model. The detailed steps to build the model can be followed in a Jupyter notebook. These have been packaged into a docker container
In general, Seldon provides several content recommendation models in Spark as well as python based modules.
To serve predictions from our model we need to run the prepackaged docker image which exposes a miroservice endpoint for the model scoring. To start any microservice and connect it to a client using the script
The script create a Kubernetes deployment for the microservice in
kubernetes/conf/microservices. If the microserice is already running Kubernetes will roll-down the previous version and roll-up the new version.
To start the Reuters gensim model serving run:
The script will create the Kubernetes Deployment and use the seldon-cli to update the “reuters” client to add the microservice as a runtime algorithm. Check with
kubectl get pods -l name=reuters-example that the pod running the mircroservice is running.
You can now call the Seldon server using the Seldon CLI to test recommendations:
The response should be like:
- No results are returned by the seldon-cli api call above
Check your Kuberentes DNS is working correctly and the reuters-example hostname can be found. Open a bash terminal into the seldon-control container and check using nslookup.: