Interface class for the Inference API. More...
#include <live_model.h>
Public Types | |
| using | error_fn = void(*)(const api_status &, void *) |
| Error callback function. When live_model is constructed, a background error callback and a context (void*) is registered. If there is an error in the background thread, error callback will get invoked with api_status and the context (void*). More... | |
| template<typename ErrCntxt > | |
| using | error_fn_t = void(*)(const api_status &, ErrCntxt *) |
| Error callback function. When live_model is constructed, a background error callback and a context (void*) is registered. If there is an error in the background thread, error callback will get invoked with api_status and the context (void*). This error callback is typed by the context used in the callback. More... | |
Public Member Functions | |
| live_model (const utility::configuration &config, error_fn fn=nullptr, void *err_context=nullptr, trace_logger_factory_t *trace_factory=&trace_logger_factory, data_transport_factory_t *t_factory=&data_transport_factory, model_factory_t *m_factory=&model_factory, sender_factory_t *s_factory=&sender_factory, time_provider_factory_t *time_prov_factory=&time_provider_factory) | |
| Construct a new live model object. More... | |
| live_model (const utility::configuration &config, std::function< void(const api_status &)> error_cb, trace_logger_factory_t *trace_factory=&trace_logger_factory, data_transport_factory_t *t_factory=&data_transport_factory, model_factory_t *m_factory=&model_factory, sender_factory_t *s_factory=&sender_factory, time_provider_factory_t *time_prov_factory=&time_provider_factory) | |
| Construct a new live model object. More... | |
| int | init (api_status *status=nullptr) |
| Initialize inference library. Initialize the library and start the background threads used for model managment and sending actions and outcomes to the online trainer. More... | |
| int | choose_rank (const char *event_id, string_view context_json, ranking_response &resp, api_status *status=nullptr) |
| Choose an action, given a list of actions, action features and context features. The inference library chooses an action by creating a probability distribution over the actions and then sampling from it. More... | |
| int | choose_rank (string_view context_json, ranking_response &resp, api_status *status=nullptr) |
| Choose an action, given a list of actions, action features and context features. The inference library chooses an action by creating a probability distribution over the actions and then sampling from it. A unique event_id will be generated and returned in the ranking_response. The same event_id should be used when reporting the outcome for this action. More... | |
| int | choose_rank (const char *event_id, string_view context_json, unsigned int flags, ranking_response &resp, api_status *status=nullptr) |
| Choose an action, given a list of actions, action features and context features. The inference library chooses an action by creating a probability distribution over the actions and then sampling from it. More... | |
| int | choose_rank (string_view context_json, unsigned int flags, ranking_response &resp, api_status *status=nullptr) |
| Choose an action, given a list of actions, action features and context features. The inference library chooses an action by creating a probability distribution over the actions and then sampling from it. A unique event_id will be generated and returned in the ranking_response. The same event_id should be used when reporting the outcome for this action. More... | |
| int | request_continuous_action (const char *event_id, string_view context_json, unsigned int flags, continuous_action_response &response, api_status *status=nullptr) |
| (DEPRECATED) Choose an action from a continuous range, given a list of context features The inference library chooses an action by sampling the probability density function produced per continuous action range. The corresponding event_id should be used when reporting the outcome for the continuous action. More... | |
| int | request_continuous_action (const char *event_id, string_view context_json, continuous_action_response &response, api_status *status=nullptr) |
| (DEPRECATED) Choose an action from a continuous range, given a list of context features The inference library chooses an action by sampling the probability density function produced per continuous action range. The corresponding event_id should be used when reporting the outcome for the continuous action. More... | |
| int | request_continuous_action (string_view context_json, unsigned int flags, continuous_action_response &response, api_status *status=nullptr) |
| (DEPRECATED) Choose an action from a continuous range, given a list of context features The inference library chooses an action by sampling the probability density function produced per continuous action range. A unique event_id will be generated and returned in the continuous_action_response. The same event_id should be used when reporting the outcome for this action. More... | |
| int | request_continuous_action (string_view context_json, continuous_action_response &response, api_status *status=nullptr) |
| (DEPRECATED) Choose an action from a continuous range, given a list of context features The inference library chooses an action by sampling the probability density function produced per continuous action range. A unique event_id will be generated and returned in the continuous_action_response. The same event_id should be used when reporting the outcome for this action. More... | |
| int | request_decision (string_view context_json, unsigned int flags, decision_response &resp, api_status *status=nullptr) |
(DEPRECATED) Choose an action from the given set for each slot, given a list of actions, slots, action features, slot feautres and context features. The inference library chooses an action per slot by sampling the probability distribution produced per slot. A unique event_id can be supplied for each slot using the _id json field. The corresponding event_id should be used when reporting the outcome for each slot. More... | |
| int | request_decision (string_view context_json, decision_response &resp, api_status *status=nullptr) |
(DEPRECATED) Choose an action from the given set for each slot, given a list of actions, slots, action features, slot feautres and context features. The inference library chooses an action per slot by sampling the probability distribution produced per slot. A unique event_id can be supplied for each slot using the _id json field. The corresponding event_id should be used when reporting the outcome for each slot. More... | |
| int | request_multi_slot_decision (const char *event_id, string_view context_json, unsigned int flags, multi_slot_response &resp, api_status *status=nullptr) |
| (DEPRECATED) Choose an action from the given set for each slot, given a list of actions, slots, action features, slot features and context features. The inference library chooses an action per slot by sampling the probability distribution produced per slot. The corresponding event_id should be used when reporting the outcome for each slot. More... | |
| int | request_multi_slot_decision (const char *event_id, string_view context_json, multi_slot_response &resp, api_status *status=nullptr) |
| int | request_multi_slot_decision (string_view context_json, unsigned int flags, multi_slot_response &resp, api_status *status=nullptr) |
| int | request_multi_slot_decision (string_view context_json, multi_slot_response &resp, api_status *status=nullptr) |
| int | request_multi_slot_decision (const char *event_id, string_view context_json, unsigned int flags, multi_slot_response &resp, const int *baseline_actions, size_t baseline_actions_size, api_status *status=nullptr) |
| int | request_multi_slot_decision (const char *event_id, string_view context_json, unsigned int flags, multi_slot_response_detailed &resp, api_status *status=nullptr) |
| int | request_multi_slot_decision (const char *event_id, string_view context_json, multi_slot_response_detailed &resp, api_status *status=nullptr) |
| int | request_multi_slot_decision (string_view context_json, unsigned int flags, multi_slot_response_detailed &resp, api_status *status=nullptr) |
| int | request_multi_slot_decision (string_view context_json, multi_slot_response_detailed &resp, api_status *status=nullptr) |
| int | request_multi_slot_decision (const char *event_id, string_view context_json, unsigned int flags, multi_slot_response_detailed &resp, const int *baseline_actions, size_t baseline_actions_size, api_status *status=nullptr) |
| int | request_episodic_decision (const char *event_id, const char *previous_id, string_view context_json, ranking_response &resp, episode_state &episode, api_status *status=nullptr) |
| int | request_episodic_decision (const char *event_id, const char *previous_id, string_view context_json, unsigned int flags, ranking_response &resp, episode_state &episode, api_status *status=nullptr) |
| int | report_action_taken (const char *event_id, api_status *status=nullptr) |
| Report that action was taken. More... | |
| int | report_action_taken (const char *primary_id, const char *secondary_id, api_status *status=nullptr) |
| Report that action was taken. More... | |
| int | report_outcome (const char *event_id, const char *outcome, api_status *status=nullptr) |
| Report the outcome for the top action. More... | |
| int | report_outcome (const char *event_id, float outcome, api_status *status=nullptr) |
| Report the outcome for the top action. More... | |
| int | report_outcome (const char *primary_id, int secondary_id, float outcome, api_status *status=nullptr) |
| Report outcome of a decision based on a pair of primary and secondary indentifiers. This identifier pair is problem specific. For CCB, the primary is the event id and the secondary is the index of the slot. More... | |
| int | report_outcome (const char *primary_id, const char *secondary_id, float outcome, api_status *status=nullptr) |
| Report outcome of a decision based on a pair of primary and secondary indentifiers. This identifier pair is problem specific. For CCB, the primary is the event id and the secondary is the index of the slot. More... | |
| int | report_outcome (const char *primary_id, int secondary_id, const char *outcome, api_status *status=nullptr) |
| Report outcome of a decision based on a pair of primary and secondary indentifiers. This identifier pair is problem specific. For CCB, the primary is the event id and the secondary is the index of the slot. More... | |
| int | report_outcome (const char *primary_id, const char *secondary_id, const char *outcome, api_status *status=nullptr) |
| Report outcome of a decision based on a pair of primary and secondary indentifiers. This identifier pair is problem specific. For CCB, the primary is the event id and the secondary is the index of the slot. More... | |
| int | refresh_model (api_status *status=nullptr) |
| template<typename ErrCntxt > | |
| live_model (const utility::configuration &config, error_fn_t< ErrCntxt > fn, ErrCntxt *err_context=nullptr, trace_logger_factory_t *trace_factory=&trace_logger_factory, data_transport_factory_t *t_factory=&data_transport_factory, model_factory_t *m_factory=&model_factory, sender_factory_t *s_factory=&sender_factory, time_provider_factory_t *time_prov_factory=&time_provider_factory) | |
| Construct a new live model object. More... | |
| live_model (live_model &&other) noexcept | |
| Move constructor for live model object. | |
| live_model & | operator= (live_model &&other) noexcept |
| Move assignment operator swaps implementation. | |
| live_model (const live_model &)=delete | |
| live_model & | operator= (live_model &)=delete |
| Prevent accidental copy, since destructor will deallocate the implementation. | |
| ~live_model () | |
| Prevent accidental copy, since destructor will deallocate the implementation. | |
Interface class for the Inference API.
| using reinforcement_learning::live_model::error_fn = void (*)(const api_status&, void*) |
Error callback function. When live_model is constructed, a background error callback and a context (void*) is registered. If there is an error in the background thread, error callback will get invoked with api_status and the context (void*).
NOTE: Error callback will get invoked in a background thread.
| using reinforcement_learning::live_model::error_fn_t = void (*)(const api_status&, ErrCntxt*) |
Error callback function. When live_model is constructed, a background error callback and a context (void*) is registered. If there is an error in the background thread, error callback will get invoked with api_status and the context (void*). This error callback is typed by the context used in the callback.
NOTE: Error callback will get invoked in a background thread.
| ErrCntxt | Context type used when the error callback is invoked |
|
explicit |
Construct a new live model object.
| config | Name-Value based configuration |
| fn | Error callback for handling errors in background thread |
| err_context | Context passed back during Error callback |
| t_factory | Transport factory. The default transport factory is initialized with a REST based transport that gets data from an Azure storage account |
| m_factory | Model factory. The default model factory hydrates vw models used for local inference. |
| sender_factory | Sender factory. The default factory provides two senders, one for interaction and the other for observation which logs to Event Hub. |
|
explicit |
Construct a new live model object.
| config | Name-Value based configuration |
| error_cb | Error callback that takes no context |
| t_factory | Transport factory. The default transport factory is initialized with a REST based transport that gets data from an Azure storage account |
| m_factory | Model factory. The default model factory hydrates vw models used for local inference. |
| sender_factory | Sender factory. The default factory provides two senders, one for interaction and the other for observation which logs to Event Hub. |
|
explicit |
Construct a new live model object.
| ErrCntxt | Context type used in error callback. |
| config | Name-Value based configuration |
| fn | Error callback for handling errors in background thread |
| err_context | Context passed back during Error callback |
| t_factory | Transport factory. The default transport factory is initialized with a REST based transport that gets data from an Azure storage account |
| m_factory | Model factory. The default model factory hydrates vw models used for local inference. |
| sender_factory | Sender factory. The default factory provides two senders, one for interaction and the other for observation which logs to Event Hub. |
| ErrCntxt | Context type used in error callback. |
| config | Name-Value based configuration |
| fn | Error callback for handling errors in background thread |
| err_context | Context passed back during Error callback |
| t_factory | Transport factory. The default transport factory is initialized with a REST based transport that gets data from an Azure storage account |
| m_factory | Model factory. The default model factory hydrates vw models used for local inference. |
| sender_factory | Sender factory. The default factory provides two senders, one for interaction and the other for observations which logs to Event Hub. |
| int reinforcement_learning::live_model::choose_rank | ( | const char * | event_id, |
| string_view | context_json, | ||
| ranking_response & | resp, | ||
| api_status * | status = nullptr |
||
| ) |
Choose an action, given a list of actions, action features and context features. The inference library chooses an action by creating a probability distribution over the actions and then sampling from it.
| event_id | The unique identifier for this interaction. The same event_id should be used when reporting the outcome for this action. |
| context_json | Contains action, action features and context features in json format |
| resp | Ranking response contains the chosen action, probability distribution used for sampling actions and ranked actions |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::choose_rank | ( | const char * | event_id, |
| string_view | context_json, | ||
| unsigned int | flags, | ||
| ranking_response & | resp, | ||
| api_status * | status = nullptr |
||
| ) |
Choose an action, given a list of actions, action features and context features. The inference library chooses an action by creating a probability distribution over the actions and then sampling from it.
| event_id | The unique identifier for this interaction. The same event_id should be used when reporting the outcome for this action. |
| context_json | Contains action, action features and context features in json format |
| flags | Action flags (see action_flags.h) |
| resp | Ranking response contains the chosen action, probability distribution used for sampling actions and ranked actions |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::choose_rank | ( | string_view | context_json, |
| ranking_response & | resp, | ||
| api_status * | status = nullptr |
||
| ) |
Choose an action, given a list of actions, action features and context features. The inference library chooses an action by creating a probability distribution over the actions and then sampling from it. A unique event_id will be generated and returned in the ranking_response. The same event_id should be used when reporting the outcome for this action.
| context_json | Contains action, action features and context features in json format |
| resp | Ranking response contains the chosen action, probability distribution used for sampling actions and ranked actions |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::choose_rank | ( | string_view | context_json, |
| unsigned int | flags, | ||
| ranking_response & | resp, | ||
| api_status * | status = nullptr |
||
| ) |
Choose an action, given a list of actions, action features and context features. The inference library chooses an action by creating a probability distribution over the actions and then sampling from it. A unique event_id will be generated and returned in the ranking_response. The same event_id should be used when reporting the outcome for this action.
| context_json | Contains action, action features and context features in json format |
| flags | Action flags (see action_flags.h) |
| resp | Ranking response contains the chosen action, probability distribution used for sampling actions and ranked actions |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::init | ( | api_status * | status = nullptr | ) |
Initialize inference library. Initialize the library and start the background threads used for model managment and sending actions and outcomes to the online trainer.
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::report_action_taken | ( | const char * | event_id, |
| api_status * | status = nullptr |
||
| ) |
Report that action was taken.
| event_id | The unique event_id used when choosing an action should be presented here. This is so that the action taken can be matched with feedback received. |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::report_action_taken | ( | const char * | primary_id, |
| const char * | secondary_id, | ||
| api_status * | status = nullptr |
||
| ) |
Report that action was taken.
| primary_id | The unique primary_id used when choosing an action should be presented here. This is so that the action taken can be matched with feedback received. |
| secondary_id | Index of the partial outcome. |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::report_outcome | ( | const char * | event_id, |
| const char * | outcome, | ||
| api_status * | status = nullptr |
||
| ) |
Report the outcome for the top action.
| event_id | The unique event_id used when choosing an action should be presented here. This is so that the action taken can be matched with feedback received. |
| outcome | Outcome serialized as a string |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::report_outcome | ( | const char * | event_id, |
| float | outcome, | ||
| api_status * | status = nullptr |
||
| ) |
Report the outcome for the top action.
| event_id | The unique event_id used when choosing an action should be presented here. This is so that the action taken can be matched with feedback received. |
| outcome | Outcome as float |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::report_outcome | ( | const char * | primary_id, |
| const char * | secondary_id, | ||
| const char * | outcome, | ||
| api_status * | status = nullptr |
||
| ) |
Report outcome of a decision based on a pair of primary and secondary indentifiers. This identifier pair is problem specific. For CCB, the primary is the event id and the secondary is the index of the slot.
| primary_id | The unique primary_id used when choosing an action should be presented here. This is so that the action taken can be matched with feedback received. |
| secondary_id | Index of the partial outcome. |
| outcome | Outcome as float. |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::report_outcome | ( | const char * | primary_id, |
| const char * | secondary_id, | ||
| float | outcome, | ||
| api_status * | status = nullptr |
||
| ) |
Report outcome of a decision based on a pair of primary and secondary indentifiers. This identifier pair is problem specific. For CCB, the primary is the event id and the secondary is the index of the slot.
| primary_id | The unique primary_id used when choosing an action should be presented here. This is so that the action taken can be matched with feedback received. |
| secondary_id | Index of the partial outcome. |
| outcome | Outcome as float. |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::report_outcome | ( | const char * | primary_id, |
| int | secondary_id, | ||
| const char * | outcome, | ||
| api_status * | status = nullptr |
||
| ) |
Report outcome of a decision based on a pair of primary and secondary indentifiers. This identifier pair is problem specific. For CCB, the primary is the event id and the secondary is the index of the slot.
| primary_id | The unique primary_id used when choosing an action should be presented here. This is so that the action taken can be matched with feedback received. |
| secondary_id | Index of the partial outcome. |
| outcome | Outcome as float. |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::report_outcome | ( | const char * | primary_id, |
| int | secondary_id, | ||
| float | outcome, | ||
| api_status * | status = nullptr |
||
| ) |
Report outcome of a decision based on a pair of primary and secondary indentifiers. This identifier pair is problem specific. For CCB, the primary is the event id and the secondary is the index of the slot.
| primary_id | The unique primary_id used when choosing an action should be presented here. This is so that the action taken can be matched with feedback received. |
| secondary_id | Index of the partial outcome. |
| outcome | Outcome as float. |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::request_continuous_action | ( | const char * | event_id, |
| string_view | context_json, | ||
| continuous_action_response & | response, | ||
| api_status * | status = nullptr |
||
| ) |
(DEPRECATED) Choose an action from a continuous range, given a list of context features The inference library chooses an action by sampling the probability density function produced per continuous action range. The corresponding event_id should be used when reporting the outcome for the continuous action.
| event_id | The unique identifier for this interaction. The same event_id should be used when reporting the outcome for this action. |
| context_json | Contains context features in json format |
| response | Continuous action response contains the chosen action and the probability density value of the chosen action location from the continuous range. |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::request_continuous_action | ( | const char * | event_id, |
| string_view | context_json, | ||
| unsigned int | flags, | ||
| continuous_action_response & | response, | ||
| api_status * | status = nullptr |
||
| ) |
(DEPRECATED) Choose an action from a continuous range, given a list of context features The inference library chooses an action by sampling the probability density function produced per continuous action range. The corresponding event_id should be used when reporting the outcome for the continuous action.
| event_id | The unique identifier for this interaction. The same event_id should be used when reporting the outcome for this action. |
| context_json | Contains context features in json format |
| flags | Action flags (see action_flags.h) |
| response | Continuous action response contains the chosen action and the probability density value of the chosen action location from the continuous range. |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::request_continuous_action | ( | string_view | context_json, |
| continuous_action_response & | response, | ||
| api_status * | status = nullptr |
||
| ) |
(DEPRECATED) Choose an action from a continuous range, given a list of context features The inference library chooses an action by sampling the probability density function produced per continuous action range. A unique event_id will be generated and returned in the continuous_action_response. The same event_id should be used when reporting the outcome for this action.
| context_json | Contains context features in json format |
| response | Continuous action response contains the chosen action and the probability density value of the chosen action location from the continuous range. |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::request_continuous_action | ( | string_view | context_json, |
| unsigned int | flags, | ||
| continuous_action_response & | response, | ||
| api_status * | status = nullptr |
||
| ) |
(DEPRECATED) Choose an action from a continuous range, given a list of context features The inference library chooses an action by sampling the probability density function produced per continuous action range. A unique event_id will be generated and returned in the continuous_action_response. The same event_id should be used when reporting the outcome for this action.
| context_json | Contains context features in json format |
| flags | Action flags (see action_flags.h) |
| response | Continuous action response contains the chosen action and the probability density value of the chosen action location from the continuous range. |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::request_decision | ( | string_view | context_json, |
| decision_response & | resp, | ||
| api_status * | status = nullptr |
||
| ) |
(DEPRECATED) Choose an action from the given set for each slot, given a list of actions, slots, action features, slot feautres and context features. The inference library chooses an action per slot by sampling the probability distribution produced per slot. A unique event_id can be supplied for each slot using the _id json field. The corresponding event_id should be used when reporting the outcome for each slot.
| context_json | Contains slots, slot_features, slot ids, actions, action features and context features in json format |
| resp | Decision response contains the chosen action per slot, probability distribution used for sampling actions and ranked actions. |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::request_decision | ( | string_view | context_json, |
| unsigned int | flags, | ||
| decision_response & | resp, | ||
| api_status * | status = nullptr |
||
| ) |
(DEPRECATED) Choose an action from the given set for each slot, given a list of actions, slots, action features, slot feautres and context features. The inference library chooses an action per slot by sampling the probability distribution produced per slot. A unique event_id can be supplied for each slot using the _id json field. The corresponding event_id should be used when reporting the outcome for each slot.
| context_json | Contains slots, slot_features, slot ids, actions, action features and context features in json format |
| flags | Action flags (see action_flags.h) |
| resp | Decision response contains the chosen action per slot, probability distribution used for sampling actions and ranked actions. |
| status | Optional field with detailed string description if there is an error |
| int reinforcement_learning::live_model::request_multi_slot_decision | ( | const char * | event_id, |
| string_view | context_json, | ||
| unsigned int | flags, | ||
| multi_slot_response & | resp, | ||
| api_status * | status = nullptr |
||
| ) |
(DEPRECATED) Choose an action from the given set for each slot, given a list of actions, slots, action features, slot features and context features. The inference library chooses an action per slot by sampling the probability distribution produced per slot. The corresponding event_id should be used when reporting the outcome for each slot.
| event_id | The unique identifier for this interaction. The same event_id should be used when reporting the outcome for this action. |
| context_json | Contains slots, slot_features, slot ids, actions, action features and context features in json format |
| flags | Action flags (see action_flags.h) |
| resp | Decision response contains the chosen action per slot, probability distribution used for sampling actions and ranked actions. |
| status | Optional field with detailed string description if there is an error |