Package: alaas
ALaaS: Active Learning as a Service.Active Learning as a Service (ALaaS) is a fast and scalable framework for automatically selecting a subset to be labeled
from a full dataset so to reduce labeling cost. It provides a out-of-the-box and standalone experience for users to quickly
utilize active learning.ALaaS is featured for:hatching_chick:Easy-to-useWith <10 lines of code to start the system to employ active learning.:rocket:FastUse the stage-level parallellism to achieve over 10x speedup than under-optimized active learning process.:collision:ElasticScale up and down multiple active workers, depending on the number of GPU devices.The project is still under the active development. Welcome to join us!Demo on AWSInstallationQuick StartALaaS Server Customization (for Advance users)Strategy ZooCitationDemo on AWS :coffee:Free ALaaS demo on AWS (Support HTTP & gRPC)Use least confidence sampling withResNet-18to select images to be labeled for your tasks!We have deployed ALaaS on AWS for demonstration. Try it by yourself!Call ALaaS with HTTP 🌐Call ALaaS with gRPC 🔐curl\-XPOSThttp://13.213.29.8:8081/post\-H'Content-Type: application/json'\-d'{"data":[{"uri": "https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane1.png"},{"uri": "https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane2.png"},{"uri": "https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane3.png"},{"uri": "https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane4.png"},{"uri": "https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane5.png"}],"parameters": {"budget": 3},"execEndpoint":"/query"}'# pip install alaasfromalaas.clientimportClienturl_list=['https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane1.png','https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane2.png','https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane3.png','https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane4.png','https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane5.png']client=Client('grpc://13.213.29.8:60035')print(client.query_by_uri(url_list,budget=3))Then you will see 3 data samples (the most informative) has been selected from all the 5 data points by ALaaS.Installation :construction:You can easily install the ALaaS byPyPI,pipinstallalaasThe package of ALaaS contains both client and server parts. You can build an active data selection service on your own
servers or just apply the client to perform data selection.:warning: For deep learning frameworks likeTensorFlowandPytorch, you may need to install manually since the version to meet your deployment can be different (as well astransformersif you are running models from it).You can also useDockerto run ALaaS:dockerpullhuangyz0918/alaasand start a service by the following command:dockerrun-it--rm-p8081:8081\--mounttype=bind,source=<configpath>,target=/server/config.yml,readonlyhuangyz0918/alaas:latestQuick Start :truck:After the installation of ALaaS, you can easily start a local server, here is the simplest example that can be executed with only 2 lines of code.fromalaas.serverimportServerServer.start()The example code (by default) will start an image data selection (PyTorch ResNet-18 for image classification task) HTTP server in port8081for you. After this, you can try to get the selection results on your own image dataset, a client-side example is likecurl\-XPOSThttp://0.0.0.0:8081/post\-H'Content-Type: application/json'\-d'{"data":[{"uri": "https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane1.png"},{"uri": "https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane2.png"},{"uri": "https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane3.png"},{"uri": "https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane4.png"},{"uri": "https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane5.png"}],"parameters": {"budget": 3},"execEndpoint":"/query"}'You can also usealaas.Clientto build the query request (for bothhttpandgrpcprotos) like this,fromalaas.clientimportClienturl_list=['https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane1.png','https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane2.png','https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane3.png','https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane4.png','https://www.cs.toronto.edu/~kriz/cifar-10-sample/airplane5.png']client=Client('http://0.0.0.0:8081')print(client.query_by_uri(url_list,budget=3))The output data is a subset uris/data in your input dataset, which indicates selected results for further data labeling.ALaaS Server Customization :wrench:We support two different methods to start your server, 1. by input parameters 2. by YAML configurationInput ParametersYou can modify your server by setting different input parameters,fromalaas.serverimportServerServer.start(proto='http',# the server proto, can be 'grpc', 'http' and 'https'.port=8081,# the access port of your server.host='0.0.0.0',# the access IP address of your server.job_name='default_app',# the server name.model_hub='pytorch/vision:v0.10.0',# the active learning model hub, the server will automatically download it for data selection.model_name='resnet18',# the active learning model name (should be available in your model hub).device='cpu',# the deploy location/device (can be something like 'cpu', 'cuda' or 'cuda:0').strategy='LeastConfidence',# the selection strategy (read the document to see what ALaaS supports).batch_size=1,# the batch size of data processing.replica=1,# the number of workers to select/query data.tokenizer=None,# the tokenizer name (should be available in your model hub), only for NLP tasks.transformers_task=None# the NLP task name (for Hugging Face [Pipelines](https://huggingface.co/docs/transformers/main_classes/pipelines)), only for NLP tasks.)YAML ConfigurationYou can also start the server by setting an input YAML configuration like this,fromalaasimportServer# start the server by an input configuration file.Server.start_by_config('path_to_your_configuration.yml')Details about building a configuration for your deployment scenarios can be foundhere.Strategy Zoo :art:Currently we supported several active learning strategies shown in the following table,TypeSettingAbbrStrategyYearReferenceRandomPool-baseRSRandom Sampling--UncertaintyPoolLCLeast Confidence Sampling1994DD Lew et al.UncertaintyPoolMCMargin Confidence Sampling2001T Scheffer et al.UncertaintyPoolRCRatio Confidence Sampling2009B Settles et al.UncertaintyPoolVRCVariation Ratios Sampling1965EH Johnson et al.UncertaintyPoolESEntropy Sampling2009B Settles et al.UncertaintyPoolMSTDMean Standard Deviation2016M Kampffmeyer et al.UncertaintyPoolBALDBayesian Active Learning Disagreement2017Y Gal et al.ClusteringPoolKCGK-Center Greedy Sampling2017Ozan Sener et al.ClusteringPoolKMK-Means Sampling2011Z Bodó et al.ClusteringPoolCSCore-Set Selection Approach2018Ozan Sener et al.DiversityPoolDBALDiverse Mini-batch Sampling2019Fedor ZhdanovAdversarialPoolDFALDeepFool Active Learning2018M Ducoffe et al.CitationOur tech report of ALaaS is available onarxivandNeurIPS 2022. Please cite as:@article{huang2022active,title={Active-Learning-as-a-Service:AnEfficientMLOpsSystemforData-CentricAI},author={Huang,YizhengandZhang,HuaizhengandLi,YuanmingandLau,ChiewTongandYou,Yang},journal={arXivpreprintarXiv:2207.09109},year={2022}}Contributors ✨Thanks goes to these wonderful people (emoji key):Yizheng Huang🚇⚠️💻Huaizheng🖋⚠️📖Yuanming Li⚠️💻This project follows theall-contributorsspecification. Contributions of any kind welcome!AcknowledgementJina- Build cross-modal and multimodal applications on the cloud.Transformers- State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.LicenseThe theme is available as open source under the terms of theApache 2.0 License.