linkedin / detext

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

fix text preprocessing for inference model #40

Closed xwli-chelsea closed 4 years ago

xwli-chelsea commented 4 years ago

Description

In https://github.com/linkedin/detext/pull/28 the filter_window_sizes override was removed. The param passing to process_text is inconsistent for none-CNN models:

This inconsistency causes problems with the inference savedmodel models.

This pr fixes the logic for filter_window_sizes in the serving_input_fn.

Fixes # (issue) 474: internal issue reported for inference model

Type of change

Please delete options that are not relevant.

List all changes

Update logic in train_helper, where the helper functions are used in serving_input_fn. This sets the filter_window_sizes for cnn only. Code search on this logic

Testing

pytest local training run, and tested inference model.

Test Configuration:

Checklist

StarWang commented 4 years ago

Thanks for spotting this. Nice finding! To prevent this from happening in the future, it'd be better that we put filter_window_sizes as 0 in the source, e.g., in method extend_hparams. Otherwise, we'll need to exhaustively find all the end point of filter_window_sizes and fix cases like this.

xwli-chelsea commented 4 years ago

Thanks for spotting this. Nice finding! To prevent this from happening in the future, it'd be better that we put filter_window_sizes as 0 in the source, e.g., in method extend_hparams. Otherwise, we'll need to exhaustively find all the end point of filter_window_sizes and fix cases like this.

Not sure why it was removed but it seems we can just keep the logic in extend_hparams. Let me add it back.

xwli-chelsea commented 4 years ago

Thanks for fixing this :)

Is there any chance that we can put a test case for inference to test it?

I thought about what tests we can add. In the case of this issue, what we need is to make sure the params passed to process_text should be the same as during training. So it's not suitable for a unit test.

But you brought a good point😊. We could probably add (maybe in another pr) some comprehensive integration tests to check if training input_fn and serving_input_fn have the same expected behaviors. I'll create an issue to track. Thanks for the comment!

xwli-chelsea commented 4 years ago

Thanks for fixing this :)

Is there any chance that we can put a test case for inference to test it?

I thought about what tests we can add. In the case of this issue, what we need is to make sure the params passed to process_text should be the same as during training. So it's not suitable for a unit test.

But you brought a good point😊. We could probably add (maybe in another pr) some comprehensive integration tests to check if training input_fn and serving_input_fn have the same expected behaviors. I'll create an issue to track. Thanks for the comment!