linkedin / detext

DeText: A Deep Neural Text Understanding Framework for Ranking and Classification Tasks
BSD 2-Clause "Simplified" License
1.26k stars 133 forks source link

add option to add dimension to query/usr placeholders for online serving #31

Closed xwli-chelsea closed 4 years ago

xwli-chelsea commented 4 years ago

Description

In the model serving (internal), we require the features to have at least 1 dimension (batch size) if used as document features. Currently we have multiple use cases of such and have to manually add a dimension to query and usr fields. This RB expose two params to control whether to add dimension to these placeholders.

Fixes # (issue)

Please delete options that are not relevant.

List all changes

Testing

Tested with run_detext.sh and inspected the output: With add_first_dim_for_query_placeholder=True and add_first_dim_for_usr_placeholder=True, the signatures are:

The given SavedModel SignatureDef contains the following input(s):
  inputs['doc_title'] tensor_info:
      dtype: DT_STRING
      shape: (-1)
      name: doc_title_placeholder:0
  inputs['label'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1)
      name: label_placeholder:0
  inputs['query'] tensor_info:
      dtype: DT_STRING
      shape: (-1)
      name: query_placeholder:0
  inputs['uid'] tensor_info:
      dtype: DT_INT64
      shape: ()
      name: uid_placeholder:0
  inputs['usr_headline'] tensor_info:
      dtype: DT_STRING
      shape: (-1)
      name: usr_headline_placeholder:0
  inputs['weight'] tensor_info:
      dtype: DT_FLOAT
      shape: ()
      name: weight_placeholder:0
  inputs['wide_ftrs'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 2)
      name: wide_ftr_placeholder:0
  inputs['wide_ftrs_sp_idx'] tensor_info:
      dtype: DT_INT32
      shape: (-1, -1)
      name: wide_ftr_sp_idx_placeholder:0
  inputs['wide_ftrs_sp_val'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, -1)
      name: wide_ftr_sp_val_placeholder:0
The given SavedModel SignatureDef contains the following output(s):
  outputs['label'] tensor_info:
      dtype: DT_FLOAT
      shape: (1, -1)
      name: ExpandDims_6:0
  outputs['scores'] tensor_info:
      dtype: DT_FLOAT
      shape: (1, -1)
      name: Squeeze_2:0
  outputs['uid'] tensor_info:
      dtype: DT_INT64
      shape: (1)
      name: Const_9:0
  outputs['weight'] tensor_info:
      dtype: DT_FLOAT
      shape: (1)
      name: Const_10:0

With add_first_dim_for_query_placeholder=False and add_first_dim_for_usr_placeholder=False (this is the default, and same as before), the signatures are:

The given SavedModel SignatureDef contains the following input(s):
  inputs['doc_title'] tensor_info:
      dtype: DT_STRING
      shape: (-1)
      name: doc_title_placeholder:0
  inputs['label'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1)
      name: label_placeholder:0
  inputs['query'] tensor_info:
      dtype: DT_STRING
      shape: ()
      name: query_placeholder:0
  inputs['uid'] tensor_info:
      dtype: DT_INT64
      shape: ()
      name: uid_placeholder:0
  inputs['usr_headline'] tensor_info:
      dtype: DT_STRING
      shape: ()
      name: usr_headline_placeholder:0
  inputs['weight'] tensor_info:
      dtype: DT_FLOAT
      shape: ()
      name: weight_placeholder:0
  inputs['wide_ftrs'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 2)
      name: wide_ftr_placeholder:0
  inputs['wide_ftrs_sp_idx'] tensor_info:
      dtype: DT_INT32
      shape: (-1, -1)
      name: wide_ftr_sp_idx_placeholder:0
  inputs['wide_ftrs_sp_val'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, -1)
      name: wide_ftr_sp_val_placeholder:0
The given SavedModel SignatureDef contains the following output(s):
  outputs['label'] tensor_info:
      dtype: DT_FLOAT
      shape: (1, -1)
      name: ExpandDims_6:0
  outputs['scores'] tensor_info:
      dtype: DT_FLOAT
      shape: (1, -1)
      name: Squeeze:0
  outputs['uid'] tensor_info:
      dtype: DT_INT64
      shape: (1)
      name: Const_9:0
  outputs['weight'] tensor_info:
      dtype: DT_FLOAT
      shape: (1)
      name: Const_10:0
Method name is: tensorflow/serving/predict

Test Configuration:

Checklist