-
Notifications
You must be signed in to change notification settings - Fork 1.9k
C API VW Setup and Teardown
Nishant Kumar edited this page Feb 21, 2021
·
3 revisions
vw* initialize(config::options_i& options, io_buf* model = nullptr, bool skipModelLoad = false, trace_message_t trace_listener = nullptr, void* trace_context = nullptr);
vw* initialize(std::string s, io_buf* model = nullptr, bool skipModelLoad = false, trace_message_t trace_listener = nullptr, void* trace_context = nullptr);
vw* initialize(int argc, char* argv[], io_buf* model = nullptr, bool skipModelLoad = false, trace_message_t trace_listener = nullptr, void* trace_context = nullptr);
vw* seed_vw_model(vw vw_model, std::string extra_args, trace_message_t trace_listener = nullptr, void* trace_context = nullptr);
// Allows the input command line string to have spaces escaped by '\'
vw* initialize_escaped(std::string const& s, io_buf* model = nullptr, bool skipModelLoad = false, trace_message_t trace_listener = nullptr, void* trace_context = nullptr);
void cmd_string_replace_value(std::stringstream*& ss, std::string flag_to_replace, std::string new_value);
VW_DEPRECATED("By value version is deprecated, pass std::string by const ref instead using `to_argv`")
char** get_argv_from_string(std::string s, int& argc);
// The argv array from both of these functions must be freed.
char** to_argv(std::string const& s, int& argc);
char** to_argv_escaped(std::string const& s, int& argc);
void free_args(int argc, char* argv[]);
const char* are_features_compatible(vw& vw1, vw& vw2);
/*
Call finish() after you are done with the vw instance. This cleans up memory usage.
*/
void finish(vw& all, bool delete_all = true);
void sync_stats(vw& all);
vw* initialize(...); // Deprecate. Replace with initialize_escaped
void cmd_string_replace_value(std::stringstream*& ss, std::string flag_to_replace, std::string new_value); // Maybe deprecate?? Not sure what to make of this one
char** to_argv(std::string const& s, int& argc);
char** to_argv_escaped(std::string const& s, int& argc);
void free_args(int argc, char* argv[]); // Probably worth deprecating these 3 functions. We should just take in a const char* for the commandline options and run these functions on our side if needed
options* create_options()
ErrorCode add_option_str(options*, const char* opt_name, const char*)
ErrorCode add_option_int32(options*, const char* opt_name, int32_t)
ErrorCode add_option_float(options*, const char* opt_name, float)
// Options that can take in a list of inputs; eg: input files. Are these necessary?
ErrorCode add_option_list_str(options*, const char* opt_name, const char*)
ErrorCode add_option_list_int32(options*, const char* opt_name, int32)
ErrorCode add_option_list_float(options*, const char* opt_name, float)
void delete_options(options*)
ErrorCode initialize(options*, bool skipModelLoad, trace_message_t trace_listener, void* trace_context, vw** output)
ErrorCode initialize_with_model(options*, const uint8_t* model, size_t model_size, bool skipModelLoad, trace_message_t trace_listener, void* trace_context, vw** output)
ErrorCode initialize_cmdline_with_model(const char*, const uint8_t* model, size_t model_size, bool skipModelLoad, trace_message_t trace_listener, void* trace_context, vw** output);
ErrorCode seed_vw_model(const vw*, options* opts, trace_message_t trace_listener, void* trace_context, vw**);
ErrorCode seed_vw_model_cmdline(const vw*, const char* cmdline_opts, trace_message_t trace_listener, void* trace_context, vw**);
const char* are_features_compatible(const vw*, const vw*); // Probably better to return an enum with enum->string mappings available?
// finish is now broken up into finish() and delete_vw().
void finish(vw* all);
void delete_vw(vw* all);
void sync_stats(vw* all); // This is only used with allreduce. Should we move this up the tech stack into its own wrapper?
These interfaces are intended to be a temporary shim to allow migration of existing functions to the new interface. These would be removed in a future version of VW.
// Ideally this would exist outside of VW's core library. But for the time being, it needs to be part of the core API
ErrorCode cmdline_to_options(const char*, options**)
ReductionStack* create_reduction_stack() // Create a new empty reduction stack to manually configure it
ReductionStack* create_reduction_stack_from_vw(vw*) // Get a reduction stack from a fully realized vw object. This creates a new object which must be destroyed with destroy_reduction_stack
void destroy_reduction_stack(ReductionStack*)
ErrorCode create_and_append_reduction(ReductionStack*, ReductionType, const options*)
ErrorCode pop_reduction(ReductionStack*) // popping an empty reduction stack
ErrorCode push_reduction(ReductionStack, reduction) // Can result in an incompatible reduction error. Operation will still succeed in this case
size_t get_reductions_count(const ReductionStack*)
reduction get_reduction(ReductionStack*, size_t index)
ReductionDataType get_reduction_input_type(const reduction*)
ReductionDataType get_reduction_output_type(const reduction*)
ReductionType get_reduction_type(const reduction*)
float(?) predict(ReductionStack*, example*, size_t num_examples) // Might need to alter the return value to match the type coming out of pytorch. Vector of floats maybe?
float(?) learn(ReductionStack*, example*, size_t num_examples)
- Home
- First Steps
- Input
- Command line arguments
- Model saving and loading
- Controlling VW's output
- Audit
- Algorithm details
- Awesome Vowpal Wabbit
- Learning algorithm
- Learning to Search subsystem
- Loss functions
- What is a learner?
- Docker image
- Model merging
- Evaluation of exploration algorithms
- Reductions
- Contextual Bandit algorithms
- Contextual Bandit Exploration with SquareCB
- Contextual Bandit Zeroth Order Optimization
- Conditional Contextual Bandit
- Slates
- CATS, CATS-pdf for Continuous Actions
- Automl
- Epsilon Decay
- Warm starting contextual bandits
- Efficient Second Order Online Learning
- Latent Dirichlet Allocation
- VW Reductions Workflows
- Interaction Grounded Learning
- CB with Large Action Spaces
- CB with Graph Feedback
- FreeGrad
- Marginal
- Active Learning
- Eigen Memory Trees (EMT)
- Element-wise interaction
- Bindings
-
Examples
- Logged Contextual Bandit example
- One Against All (oaa) multi class example
- Weighted All Pairs (wap) multi class example
- Cost Sensitive One Against All (csoaa) multi class example
- Multiclass classification
- Error Correcting Tournament (ect) multi class example
- Malicious URL example
- Daemon example
- Matrix factorization example
- Rcv1 example
- Truncated gradient descent example
- Scripts
- Implement your own joint prediction model
- Predicting probabilities
- murmur2 vs murmur3
- Weight vector
- Matching Label and Prediction Types Between Reductions
- Zhen's Presentation Slides on enhancements to vw
- EZExample Archive
- Design Documents
- Contribute: