current position:Home>Study summary of pytext: a search path from NLP research to production
Study summary of pytext: a search path from NLP research to production
2022-04-29 04:41:03【Southern Chu Lich】
Abstract
Explain the work content
Wrote a base pytorch Model deployment file framework , The framework can reconcile the contradiction between the rapid experiment of Algorithm Engineers and the deployment of large-scale service model
Innovation points
1. Provide simple and extensible interfaces for model components
2. utilize pytorch Export the model for import caff2 Model to infer
3. Build multiple single task models at the same time , Through the above modules , Determine the shared model parameters , Conduct joint research , The joint training model can be represented by one or more inputs for multiple tasks
Introduction
Working background
(1) When building the framework of machine learning model , Especially in the framework of deep learning model , There is a big contradiction between experiment and deployment
(2) During the experiment , Usually use pytorch and tensorflow, The advantage is fast modeling , Establish dynamic graph model , The disadvantage is that the inference process is delayed , Deployment is challenging ( In fact, I don't know much about inference , What is deployment )
When the model is deployed , Use a declarative framework , use caffe2 and tensorflow frame , Establish static graph model , The advantage is that the production scenario is highly optimized , But it is difficult to use and the experimental life cycle is longer .
(3) The current contradiction is because most NLP The model is a dynamic model , It is not easy to represent... In a static diagram , It increases the challenge of opening various services on the basis of industrial scale .
Innovation points
1. Fast modeling
2. It becomes easy to use models on new data , Reduce additional workload
3. Researchers and workers on the same production line , Create with minimal cost 、 assessment 、 The whole process from model delivery to deployment .
4. Ensure high performance when deploying the model ( Low latency and high throughput )
Related work
Introduction to related research algorithms , Analyze the advantages and disadvantages .
Different model frameworks advantage shortcoming
CoreNLP Support research and production Deep learning neural networks are not supported
FLAIR Support research and deep learning models Production is not supported
AllenNLP Support research and deep learning models Production is not supported
Spacy 2.0 Support deep learning model and production Modeling is not supported
Discussion
Paper introduction
PyText It is a framework to help researchers or engineers quickly deploy machine learning systems , With custom processing raw data model 、 Reporting indicators 、 Training methods 、 Output training model method and other functions .
At this point, you can study the building blocks of various models , Conduct in-depth research .
Source structure
All components need to be maintained in the global registry , Defined by the parameters required to configure it
Component structure = Training (Data Handler/Model/Optimizer/Metric Reporter/Trainer)+ forecast (Predictor)+ export (Exporter), All models are exported as ONXX Format
Model structure
Single task training model
Token Embedding+Representation+Decoder+Output Layer
Multi task training model
Build multiple single task models at the same time , Through the above modules , Determine the shared model parameters , Conduct joint research , The joint training model can be represented by one or more inputs for multiple tasks
Related preconditions of multitasking training model
- Set up different data sources , Different data sources correspond to different tasks
- A single task scenario must be implemented , Make sure you reuse it in your multitasking setup .
An example of multitasking training model
Variables can be represented by shared words , Realization (1) Text classification and word marking model ,(2) Two text categories + Text matching model
The model can support tasks
- Text classification
- Word marker
- Semantic analysis
- Language model
- Joint model
Experiments
The experimental steps
PyText Deployment tasks
- Implementation model
- Bound to the pytorch Reasoning services for , Real time Small-Scale Evaluation of real-time traffic samples
- Export to caffe2 Model , But it does not necessarily support overly complex versions
- If 3 Step no , Then use pytorch Of C++ API, Rewrite the model and encapsulate it into Caffe2 Format
- Publish to Caffe2 In our forecasting service , Perform training operations
experimental condition
The experiment is on a computer with only cpu On your machine , There's... On the machine 48 individual 2.5GHz Of Intel Xeon E5-2680 processor ,251 GB RAM and CentOS 7.5.c++ Code using gcc -O3 compile
Model deployment
The model studies pytext Export to C++ and caffe2 in , Export as an attempt to identify the delay in the task
Result analysis
Challenges of model deployment
Text preprocessing :
- Text tokenization
- Character conversion ID
- string alignment
Vocabulary management methods
- Maintain vocabulary in remote services
- Export to Caffe2 after , Add vocabulary to the network
The second option is to synchronize / Control different versions of use cases and language models
Future research direction
1. Add tasks
(1) Add multilingual task modeling research
(2) Add question and answer system 、 Summarize the system 、 Research on reading comprehension tasks
2. Performance benchmarks and corresponding improvements
In order to improve high throughput , Reduce delay time
(1) Training : Add distributed training
(2) forecast : Benchmark your training , Tune the model deployment according to the predicted load pattern .
3. Model interpretability
Monitoring indicators , Debug the inside of the model , Add more tool support
(1) tensorboard+visdom
(2) Explore different model interpretation methods
4. Model robustness
In order to resist the antagonistic input of disturbance 、 noise 、 The influence of grammatical differences on the accuracy of the model , Add countermeasure training and data enhancement technology .
5. Mobile model deployment
Training lightweight models , Deploy models on mobile devices
copyright notice
author[Southern Chu Lich],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/117/202204270546071048.html
The sidebar is recommended
- Units that can be used by the rotate method of transform in CSS
- Why CSS3 sticky doesn't work?
- [bug resolution] webpack error: module not found Did you mean xxx
- Vue insert iframe
- About database data response to HTML page, Chinese appears? Solution to garbled code (multiple question marks)
- Ask a question about CSS selector
- When Vue jumps the route, the timer cannot be cleared in time
- Document is not defined
- Vuepress packaging deployment stepping on the road of the pit
- Vue quill editor stepping on pit record -- the echo style of rich text content is wrong
guess what you like
The multi selection box of table in element is combined with paging to echo the bug step hole
Vue project optimizes the loading speed of the first screen
Use / deep / to report an error CSS (CSS selected expected)
Nginx configuration
Vue cli reverse proxy
Vuex persistedstate plug-in - vuex persistent storage
Automatic import of less
Understanding and summary of CSS
vue2. Implementation of X data response
JavaScript content understanding
Random recommended
- Props in react
- JavaScript stack“
- Bootstrap blazor table component (III) intelligent generation
- Based on centos7 + nginx + Daphne + uwsgi + django3 2 + supervisor + mysql8 single architecture server production environment deployment (I)
- Differences between vue2 and vue3 named slots
- Vue3: Axios cross domain request problem
- The difference between vue2 and vue3: keep alive
- Configure nginx and SSL certificate for Django project under Windows Environment
- Ant Design Vue: a-table custom column
- Using jQuery in Vue
- Vue dynamic loading picture problem
- Icons using Alibaba vector icon library in Vue
- Java Android mobile phone automatic basic learning element positioning
- Rancher configuring HTTPS domain name to access graphic tutorial
- Building a blog with GitHub pages + hexo (7) how to delete a published article successfully solved: delete it at the same time deploy_ Git folder
- Eight blog views / hexubs
- Build a blog with GitHub pages + hexo (9) set the next theme of hexo blog, and only part of the home page is displayed (not the full text)
- Building a blog with GitHub pages + hexo (10) the next theme of hexo blog mathjax mathematical formula rendering problem
- Hexo/Github. IO configure Tencent cloud CDN
- Rich text editor: ckeditor (using ckeditor4 Vue)
- The get request of nginx agent only returns part of the data. The problem is solved
- JavaScript traverses the irregularly nested multi-layer objects, returns the map with "index", and realizes the rapid positioning of sub attributes
- HTTP keep alive details
- [technical update] http / 3 quic Foundation
- Vue to react ----- can the constructor be omitted when using ES6?
- Use of nested HTML
- Vue to react to realize slot function
- When to use react PureComponent
- Details of Vue to react useeffect
- React 16.6 memo()
- Deep understanding of children https://segmentfault.com/a/1190000011527160
- This paper solves the cross domain problem Vue + springboot caused by the separation of front and back ends
- The difference between shallow copy and deep copy is to use native JavaScript to realize deep copy
- Definition of Vue slot
- Sorting algorithm in JavaScript
- JavaScript implements search algorithm, sequential search and binary search
- leetcode20. Valid parentheses, implemented using JavaScript
- 496 next element larger JavaScript implementation leetcode
- Source code analysis, Vue What happens when using (), take initializing vuex as an example
- Vue bidirectional binding principle