ludwig: output text generator failing at prediction time

Describe the bug Predictions are not produced for trained model

To Reproduce Steps to reproduce the behavior:

  1. run this code to reproduce:
import ludwig
import pandas as pd

model_definition = {
    'input_features':[{
        'name': 'l1',
        'type': 'text',
        'encoder': 'rnn',
        'cell_type': 'lstm',
        'reduce_output': 'None'}],
    'output_features':[{
        'name': 'l2',
        'type': 'text',
        'decoder': 'generator',
        'cell_type': 'lstm',
        'attention': 'bahdanau',
        'loss':{
            'type': 'sampled_softmax_cross_entropy'}}]}

model = ludwig.LudwigModel(model_definition=model_definition)

data_df = pd.DataFrame({
    'l1':['aa ab ac', 'ad ae af'],
    'l2':['za zb zc', 'zd ze zf']})

model_stats = model.train(data_df=data_df)

preds = model.predict(data_df=data_df)
  1. See error:

KeyError Traceback (most recent call last) <ipython-input-2-6af87045705b> in <module> 26 model_stats = model.train(data_df=data_df) 27 —> 28 preds = model.predict(data_df=data_df)

~/.local/lib/python3.5/site-packages/ludwig/api.py in predict(self, data_df, data_csv, data_dict, return_type, batch_size, gpus, gpu_fraction, logging_level) 929 gpus=gpus, 930 gpu_fraction=gpu_fraction, –> 931 logging_level=logging_level, 932 ) 933

~/.local/lib/python3.5/site-packages/ludwig/api.py in _predict(self, data_df, data_csv, data_dict, return_type, batch_size, gpus, gpu_fraction, only_predictions, logging_level) 799 self.model_definition[‘preprocessing’] 800 ) –> 801 replace_text_feature_level(self.model_definition, [preprocessed_data]) 802 dataset = Dataset( 803 preprocessed_data,

~/.local/lib/python3.5/site-packages/ludwig/data/preprocessing.py in replace_text_feature_level(model_definition, datasets) 706 ‘{}_{}’.format( 707 feature[‘name’], –> 708 feature[‘level’] 709 ) 710 ]

KeyError: ‘l2_word’

Expected behavior Predictions are produced

Environment (please complete the following information):

  • OS: Debian GNU/Linux
  • Version: 9
  • Python version: 3.5.3
  • Ludwig version: 0.1.0

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15

Commits related to this issue

Most upvoted comments

Thank you! @w4nderlust I was able to resolve the above issue after upgrading Ludwig to 0.1.1