guillaumegenthial / tf_ner

Simple and Efficient Tensorflow implementations of NER models with tf.estimator and tf.data
Apache License 2.0
923 stars 275 forks source link

Why must use "nwords"? It makes the models harder to serve for inputs from database #42

Open ishrar opened 5 years ago

ishrar commented 5 years ago

Currently, the learnt models require the nwords parameter, along with the main words input, when serving the models with tensorflow server.

It would be very helpful if this requirement of nwords parameter can be omitted, so that only the words array can be streamed directly from database sources to the tensorflow server running the learnt models.

guillaumegenthial commented 5 years ago

If you're making batchted predictions, sentences can be of different lengths and thus need to be padded before being fed to tensorflow, and as the CRF is a sequence model, you need the length to be exact, so it won't be possible to omit the length.

It might be possible to slightly modify the code to not use the length at inference time if you're always giving one sentence at a time (batches of size 1) but I would really not recommend it.