Giter VIP home page Giter VIP logo

openue's Introduction

中文说明 | English

OpenUE is an open-source toolkit that provides a off-the-shelf framework to implement lots of NLP extraction tasks.

OpenUE allows users ranging from beginner python coders to experienced machine learning engineers to leverage lots of NLP extraction tasks in one easy-to-use python package.

Key Features

  • Full Guides and API Documentation

  • Unified API for NLP Tasks with SOTA Pretrained Models (Adaptable with BERT, XLNet, etc.)

    • Entity and Realation Extraction
    • Intent and Slot Filling
    • Opinion and Apspect Extraction
    • More in development
  • Training and Inference Interface

  • Rapid NLP Model Deployment

  • Dockerizing OpenUE with GPUs

    • Easily build and run OpenUE containers leveraging NVIDIA GPUs with Docker

Environment

Quick Start

Requirements and Installation

Anaconda Environment
conda create -n openue python=3.6
conda activate openue
conda install  --file requirements.txt 

Examples and General Use

Once you have installed OpenUE, here are a few examples of what you can run with OpenUE modules:

Entity and Relation Extraction Example
  1. Data Preprocessing. Put the pretrined language model (e.g., BERT) in the pretrained_model folder and put all raw data (run script download_ske.sh in the benchmark folder) in the raw_data folder, run
sh download_ske_dataset.sh
sh download_pretrain_cn_bert.sh
sh preprocess.sh  ske
  1. Train Sequence Labeling & Classification Model. Set all parameters in the file config.py and run
sh train_seq.sh ske
sh train_class.sh ske

You can download the checkpoint here, extract and put them in the output folder.

  1. Test & Evaluation. Run
python predict.sh ske
  1. Export & Serving. Run
sh export_seq.sh ske
sh serving_cls.sh ske
sh serving.sh
  1. Interactive Prediction. Run
python  predict_online.py
  1. Demo.Run
python app.py  ske

Tools

>>> import openuee
>>> model = openue.get_model('ske_bert_entity_relation')
>>> res = model.infer('《上海滩》是刘德华的音乐作品,黄沾作曲,收录在《【歌单】酷我热门单曲合辑》专辑中')
>>> print(res)
"spo_list": [{"object_type": "人物", "predicate": "作曲", "object": "黄沾", "subject_type": "歌曲", "subject": "上海滩"}, {"object_type": "音乐专辑", "predicate": "所属专辑", "object": "【歌单】酷我热门单曲合辑", "subject_type": "歌曲", "subject": "上海滩"}, {"object_type": "人物", "predicate": "歌手", "object": "刘德华", "subject_type": "歌曲", "subject": "上海滩"}]

Note that it may take a few minutes to download checkpoint and data for the first time. Then use infer to do sentence-level entity and relation extraction

How to Cite

If you use or extend our work, please cite the following paper:

@inproceedings{zhang-2020-opennue,
    title = "{O}pe{UE}: An Open Toolkit for Universal  Extraction in Text",
    author = "Ningyu Zhang, Shumin Deng, Huajun Chen",
    year = "2020",
}

openue's People

Contributors

zxlzr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

openue's Issues

你好,在对模型进行训练以后出现了这个错误,希望得到解决

_INFO:tensorflow: name = predicate_output_weights:0, shape = (49, 768) INFO:tensorflow: name = predicate_output_bias:0, shape = (49,) INFO:tensorflow: name = token_label_output_weights:0, shape = (10, 768) INFO:tensorflow: name = token_label_output_bias:0, shape = (10,) INFO:tensorflow:Error recorded from evaluation_loop: Values of eval_metric_ops must be (metric_value, update_op) tuples, given: Tensor("ArgMax:0", shape=(?,), dtype=int32) for key: predicate_prediction INFO:tensorflow:evaluation_loop marked as finished WARNING:tensorflow:Reraising captured error Traceback (most recent call last): File "run_sequnce_labeling.py", line 883, in <module> tf.app.run() File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "run_sequnce_labeling.py", line 814, in main result = estimator.evaluate(input_fn=eval_input_fn, steps=eval_steps) File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2424, in evaluate rendezvous.raise_errors() File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/error_handling.py", line 128, in raise_errors six.reraise(typ, value, traceback) File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/six.py", line 703, in reraise raise value File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2418, in evaluate name=name File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 478, in evaluate return _evaluate() File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 460, in _evaluate self._evaluate_build_graph(input_fn, hooks, checkpoint_path)) File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1484, in _evaluate_build_graph self._call_model_fn_eval(input_fn, self.config)) File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1520, in _call_model_fn_eval features, labels, model_fn_lib.ModeKeys.EVAL, config) File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2195, in _call_model_fn features, labels, mode, config) File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1195, in _call_model_fn model_fn_results = self._model_fn(features=features, **kwargs) File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2479, in _model_fn features, labels, is_export_mode=is_export_mode) File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 1259, in call_without_tpu return self._call_model_fn(features, labels, is_export_mode=is_export_mode) File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 1538, in _call_model_fn return estimator_spec.as_estimator_spec() File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 330, in as_estimator_spec prediction_hooks=self.prediction_hooks + hooks) File "/home/fanyongfeng/.conda/envs/ner-rc/lib/python3.6/site-packages/tensorflow/python/estimator/model_fn.py", line 236, in __new__ 'tuples, given: {} for key: {}'.format(value, key)) TypeError: Values of eval_metric_ops must be (metric_value, update_op) tuples, given: Tensor("ArgMax:0", shape=(?,), dtype=int32) for key: predicate_prediction _

使用的命令是sh train_seq.sh ske
环境问题全部解决,但是在运行训练命令后出现这个问题。
如果有调试好的代码可以发邮件给我:[email protected] 谢谢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.