Type: New Feature
Affects Version/s: None
Fix Version/s: 6.3
Security Level: Public (Default Security Level. Issues are Public)
This ticket describes a framework for optimizing, storing and deploying AI models within the Streaming Expression framework.
Cao Manh Dat, has contributed
SOLR-9252 which provides Streaming Expressions for both feature selection and optimization of a logistic regression text classifier. SOLR-9252 also provides a great working example of optimization of a machine learning model using an in-place parallel iterative algorithm.
The id field can be added to the featureSelection expression so that features can be later retrieved from the collection it's stored in.
With the introduction of the topic() expression, SolrCloud can be treated as a distributed message queue. This messaging capability can be used to deploy models and process data through the models.
To implement this approach a classify() function can be created that uses a topic() function to return both the model and the data to be classified:
The pseudo code looks like this:
In the example above the classify() function uses the topic() function to retrieve the model. Each time there is an update to the model in the index, the topic() expression will automatically read the new model.
The topic function() is also used to pull in the data set that is being classified. Notice the version parameter. This will be added to the topic function to support pulling results from a specific version number (jira ticket to follow).
With this approach both the model and the data to process through the model are treated as messages in a message queue.
The daemon function can be used to send the classify function to Solr where it will be run in the background. The pseudo code looks like this:
In this scenario the daemon will run the classify function repeatedly in the background. With each run the topic() functions will re-pull the model if the model has been updated. It will also pull a new set of emails to be classified. The classified emails can be stored in another SolrCloud collection using the update() function.
Using this approach emails can be classified in batches. The daemon can continue to run even after all all the emails have been classified. New emails added to the emails collections will then be automatically classified when they enter the index.
Classification can be done in parallel once
SOLR-9240 is completed. This will allow topic() results to be partitioned across worker nodes so they can be processed in parallel. The pseudo code for this is:
The code above sends a daemon to 20 workers, which will each classify a partition of records pulled by the topic() function.
AI based alerting
If the version parameter is not supplied to the topic stream it will stream only new content from the topic, rather then starting from an older version number.
In this scenario the topic function behaves like an alert. Pseudo code for alerts look like this:
In the example above an alert() function wraps the classify() function and takes actions based on the classification of documents. Developers can build there own alert functions using the Streaming API and plug them in to provide custom actions.