Coder Social home page Coder Social logo

bharat123rox / detext Goto Github PK

View Code? Open in Web Editor NEW

This project forked from linkedin/detext

0.0 1.0 0.0 7.13 MB

DeText: A Deep Neural Text Understanding Framework for Ranking and Classification Tasks

License: BSD 2-Clause "Simplified" License

Python 99.72% Shell 0.28%

detext's Introduction

Python 3.6 application Python 3.7 application tensorflow License

DeText: A Deep Neural Text Understanding Framework

Relax like a sloth, let DeText do the understanding for you

What is it

DeText is a Deep Text understanding framework for NLP related ranking, classification, and language generation tasks. It leverages semantic matching using deep neural networks to understand member intents in search and recommender systems. As a general NLP framework, currently DeText can be applied to many tasks, including search & recommendation ranking, multi-class classification and query understanding tasks.

Highlight

Design principles for DeText framework:

  • Natural language understanding powered by state-of-the-art deep neural networks

    • Automatic feature extraction with deep models
    • End-to-end training
    • Interaction modeling between ranking sources and targets
  • A general framework with great flexibility to meet requirement of different production applications.

    • Flexible deep model types
    • Multiple loss function choices
    • User defined source/target fields
    • Configurable network structure (layer sizes and #layers)
    • Tunable hyperparameters ...
  • Reaching a good balance between effectiveness and efficiency to meet the industry requirements.

The framework

The DeText framework contains multiple components:

Word embedding layer. It converts the sequence of words into a d by n matrix.

CNN/BERT/LSTM for text encoding layer. It takes into the word embedding matrix as input, and maps the text data into a fixed length embedding. It is worth noting that we adopt the representation based methods over the interaction based methods. The main reason is the computational complexity: The time complexity of interaction based methods is at least O(mnd), which is one order higher than the representation based methods max(O(md), O(nd).

Interaction layer. It generates deep features based on the text embeddings. Many options are provided, such as concatenation, cosine similarity, etc.

Wide & Deep Feature Processing. We combine the traditional features with the interaction features (deep features) in a wide & deep fashion.

MLP layer. The MLP layer is to combine wide features and deep features.

It is an end-to-end model where all the parameters are jointly updated to optimize the click probability.

Model Flexibility

DeText is a general ranking framework that offers great flexibility for clients to build customized networks for their own use cases:

LTR/classification layer: in-house LTR loss implementation, or tf-ranking LTR loss, multi-class classification support.

MLP layer: customizable number of layers and number of dimensions.

Interaction layer: support Cosine Similarity, Outer Product, Hadamard Product, and Concatenation.

Text embedding layer: support CNN, BERT, LSTM-Language-Model with customized parameters on filters, layers, dimensions, etc.

Continuous feature normalization: element-wise scaling, value normalization.

Categorical feature processing: modeled as entity embedding.

All these can be customized via hyper-parameters in the DeText template. Note that tf-ranking is supported in the DeText framework, i.e., users can choose the LTR loss and metrics defined in DeText.

How to use it

Setup dev environment

  1. Create & source your virtualenv
  2. Run setup for DeText:
python setup.py develop

Run tests

Run all tests:

pytest 

Running DeText model training toy example

The main script for running DeText model training is through src/detext/run_detext.py. Users could customize the hyperparmeters based on different requirements for specific tasks. Please refer to TRAINING.md for more details on the training data format and hyperparameter description. For a test run on a small sample dataset, please checkout the following script.

cd test/resources
bash run_detext.sh

DeText training manual

Users have full control for custom designing DeText models. In the training manual (TRAINING.md), users can find information about the following:

  • Training data format and preparation
  • Key parameters to customize and train DeText models
  • Detailed information about all DeText training parameters for full customization

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

License

This project is licensed under the BSD 2-CLAUSE LICENSE - see the LICENSE.md file for details

detext's People

Contributors

xwli-chelsea avatar starwang avatar zhoutong-fu avatar jakiejj avatar guoweiwei avatar yazhigao avatar cyzhao2013 avatar

Watchers

James Cloos avatar

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.