All Projects → lynnna-xu → bert_sa

lynnna-xu / bert_sa

Licence: other
bert sentiment analysis tensorflow serving with RESTful API

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to bert sa

Openapi Generator
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
Stars: ✭ 10,634 (+30282.86%)
Mutual labels:  restful-api, rest-client
Spark Nlp
State of the Art Natural Language Processing
Stars: ✭ 2,518 (+7094.29%)
Mutual labels:  sentiment-analysis, bert
Python Ilorest Library Old
Python library for iLO RESTful API
Stars: ✭ 85 (+142.86%)
Mutual labels:  restful-api, rest-client
NSP-BERT
The code for our paper "NSP-BERT: A Prompt-based Zero-Shot Learner Through an Original Pre-training Task —— Next Sentence Prediction"
Stars: ✭ 166 (+374.29%)
Mutual labels:  sentiment-analysis, bert
ChineseNER
中文NER的那些事儿
Stars: ✭ 241 (+588.57%)
Mutual labels:  bert, tensorflow-serving
Ngx Restangular
Restangular for Angular 2 and higher versions
Stars: ✭ 787 (+2148.57%)
Mutual labels:  restful-api, rest-client
FinBERT
A Pretrained BERT Model for Financial Communications. https://arxiv.org/abs/2006.08097
Stars: ✭ 193 (+451.43%)
Mutual labels:  sentiment-analysis, bert
Python Simple Rest Client
Simple REST client for python 3.6+
Stars: ✭ 143 (+308.57%)
Mutual labels:  restful-api, rest-client
Text Classification TF
用tf实现各种文本分类模型,并且封装restful接口,可以直接工程化
Stars: ✭ 32 (-8.57%)
Mutual labels:  restful-api, bert
bert-sentiment
Fine-grained Sentiment Classification Using BERT
Stars: ✭ 49 (+40%)
Mutual labels:  sentiment-analysis, bert
Datafire
A framework for building integrations and APIs
Stars: ✭ 487 (+1291.43%)
Mutual labels:  restful-api, rest-client
COVID-19-Tweet-Classification-using-Roberta-and-Bert-Simple-Transformers
Rank 1 / 216
Stars: ✭ 24 (-31.43%)
Mutual labels:  sentiment-analysis, bert
RestSharpFramework
Framework for testing RESTful Services with RestSharp and C# HTTP Client
Stars: ✭ 18 (-48.57%)
Mutual labels:  restful-api, rest-client
Farwest
Framework for building RESTful HATEOAS-driven applications.
Stars: ✭ 18 (-48.57%)
Mutual labels:  restful-api, rest-client
Pytorch Sentiment Analysis
Tutorials on getting started with PyTorch and TorchText for sentiment analysis.
Stars: ✭ 3,209 (+9068.57%)
Mutual labels:  sentiment-analysis, bert
YuiAPI
一个浏览器API测试客户端,API文档生成器,支持chrome/firefox/新版edge
Stars: ✭ 25 (-28.57%)
Mutual labels:  restful-api, rest-client
Rhythm-CB-Scripts
Collection of scripts for use with Carbon Black Cb Response API
Stars: ✭ 14 (-60%)
Mutual labels:  restful-api, rest-client
NewsMTSC
Target-dependent sentiment classification in news articles reporting on political events. Includes a high-quality data set of over 11k sentences and a state-of-the-art classification model.
Stars: ✭ 54 (+54.29%)
Mutual labels:  sentiment-analysis
textgo
Text preprocessing, representation, similarity calculation, text search and classification. Let's go and play with text!
Stars: ✭ 33 (-5.71%)
Mutual labels:  bert
textlytics
Text processing library for sentiment analysis and related tasks
Stars: ✭ 25 (-28.57%)
Mutual labels:  sentiment-analysis

bert_sa (bert sentiment analysis tensorflow serving with RESTful API)

based on bert including training, online predicting and serving with REST

Fine tune a sentiment analysis model based on BERT

  1. Add a SAProcessor and include it within main function in run_classifier.py
  2. Prepare train, dev and test files; adapat _create_examples method in SAProcessor based on your own datasets (pandas may not be required)
  3. Specify BERT_BASE_DIR, SA_DIR and output_dir in run_sa.sh and run

Test

  1. For file based test, change output_predict_file in run_classifier.py, specify TRAINED_CLASSIFIER and output_dir path, run predict_sa.sh
  2. For online prediction, refer to run_classifier_predict_online (modified based on bert_language_understanding)

Export your model

Refer to sa_predict_saved_model.py

KIND NOTICE: some graph definition and input placeholder is imported from run_classifier_predict_online.py

Serve the model with TensorFlow Serving

  1. See TensorFlow Serving for details about installing docker and pulling a serving image
  2. Running a serving image
docker run -p 8501:8501 --name 'bert_sa_serving' --mount type=bind,source=/data/notebooks/xff/bert/output/sa_output/saved_model,target=/models/bert_sa -e MODEL_NAME=bert_sa -t tensorflow/serving:latest-devel-gpu &

docker exec -it bert_sa_serving bash

tensorflow_model_server --port=8500 --rest_api_port=8501 \
  --model_name=bert_sa --model_base_path=/models/bert_sa
  1. Sample request
line=u'建立了完善的质量体系并持续有效运行'
# preprocess is defined in run_classifier_predict_online.py
dict_data = preprocess(line)
resp = requests.post('http://172.17.0.1:8501/v1/models/bert_sa:predict', json=dict_data)
print(resp.json())

Results look like this: {'outputs': {'label_predict': 1, 'possibility': [0.00738544, 0.992615]}}

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].