ludwig-ai / ludwig

Low-code framework for building custom LLMs, neural networks, and other AI models
http://ludwig.ai
Apache License 2.0
11.13k stars 1.19k forks source link

training a simple chatbot model #1036

Open grigo210 opened 3 years ago

grigo210 commented 3 years ago

Hi! I tried to create a model for a chatbot based on a data set created by me and I got an error:

Eu,Chatbot salut,salut ce faci?,bine

input_features:

    name: Eu
    type: text
    level: word
    encoder: rnn
    cell_type: lstm
    reduce_output: null

output_features:

    name: Chatbot
    type: text
    level: word
    decoder: generator
    cell_type: lstm
    attention: bahdanau
    loss:
        type: sampled_softmax_cross_entropy

training: batch_size: 96

Error: raceback (most recent call last): File "D:\Ludwig\venv\Scripts\ludwig-script.py", line 33, in sys.exit(load_entry_point('ludwig==0.3.1', 'console_scripts', 'ludwig')()) File "d:\ludwig\venv\lib\site-packages\ludwig\cli.py", line 146, in main CLI() File "d:\ludwig\venv\lib\site-packages\ludwig\cli.py", line 72, in init getattr(self, args.command)() File "d:\ludwig\venv\lib\site-packages\ludwig\cli.py", line 92, in experiment experiment.cli(sys.argv[2:]) File "d:\ludwig\venv\lib\site-packages\ludwig\experiment.py", line 571, in cli experiment_cli(vars(args)) File "d:\ludwig\venv\lib\site-packages\ludwig\experiment.py", line 239, in experiment_cli debug=debug, File "d:\ludwig\venv\lib\site-packages\ludwig\api.py", line 1036, in experiment debug=debug, File "d:\ludwig\venv\lib\site-packages\ludwig\api.py", line 469, in train save_path=model_dir, File "d:\ludwig\venv\lib\site-packages\ludwig\models\trainer.py", line 552, in train self.regularization_lambda File "d:\ludwig\venv\lib\site-packages\tensorflow\python\eager\def_function.py", line 780, in call result = self._call(*args, *kwds) File "d:\ludwig\venv\lib\site-packages\tensorflow\python\eager\def_function.py", line 823, in _call self._initialize(args, kwds, add_initializers_to=initializers) File "d:\ludwig\venv\lib\site-packages\tensorflow\python\eager\def_function.py", line 697, in _initialize args, kwds)) File "d:\ludwig\venv\lib\site-packages\tensorflow\python\eager\function.py", line 2855, in _get_concrete_function_internal_garbage_collected graphfunction, , _ = self._maybe_define_function(args, kwargs) File "d:\ludwig\venv\lib\site-packages\tensorflow\python\eager\function.py", line 3213, in _maybe_define_function graph_function = self._create_graph_function(args, kwargs) File "d:\ludwig\venv\lib\site-packages\tensorflow\python\eager\function.py", line 3075, in _create_graph_function capture_by_value=self._capture_by_value), File "d:\ludwig\venv\lib\site-packages\tensorflow\python\framework\func_graph.py", line 986, in func_graph_from_py_func func_outputs = python_func(*func_args, func_kwargs) File "d:\ludwig\venv\lib\site-packages\tensorflow\python\eager\def_function.py", line 600, in wrapped_fn return weak_wrapped_fn().wrapped(*args, *kwds) File "d:\ludwig\venv\lib\site-packages\tensorflow\python\eager\function.py", line 3735, in bound_method_wrapper return wrapped_fn(args, kwargs) File "d:\ludwig\venv\lib\site-packages\tensorflow\python\framework\func_graph.py", line 973, in wrapper raise e.ag_error_metadata.to_exception(e) ValueError: in user code:

d:\ludwig\venv\lib\site-packages\ludwig\models\ecd.py:176 train_step  *
    model_outputs = self((inputs, targets), training=True)
d:\ludwig\venv\lib\site-packages\ludwig\models\ecd.py:118 call  *
    decoder_outputs = decoder(
d:\ludwig\venv\lib\site-packages\ludwig\features\base_feature.py:260 call  *
    logits = self.logits(logits_input, target=target, training=training)
d:\ludwig\venv\lib\site-packages\ludwig\features\sequence_feature.py:252 logits  *
    inputs,
d:\ludwig\venv\lib\site-packages\ludwig\decoders\sequence_decoders.py:150 _logits_training  *
    logits = self.decoder_teacher_forcing(
d:\ludwig\venv\lib\site-packages\ludwig\decoders\sequence_decoders.py:310 decoder_teacher_forcing  *
    encoder_sequence_length = sequence_length_3D(encoder_output)
d:\ludwig\venv\lib\site-packages\ludwig\utils\tf_utils.py:26 sequence_length_3D  *
    used = tf.sign(tf.reduce_max(tf.abs(sequence), 2))
d:\ludwig\venv\lib\site-packages\tensorflow\python\util\dispatch.py:201 wrapper  **
    return target(*args, **kwargs)
d:\ludwig\venv\lib\site-packages\tensorflow\python\ops\math_ops.py:2685 reduce_max
    _ReductionDims(input_tensor, axis))
d:\ludwig\venv\lib\site-packages\tensorflow\python\ops\math_ops.py:2696 reduce_max_with_dims
    gen_math_ops._max(input_tensor, dims, keepdims, name=name))
d:\ludwig\venv\lib\site-packages\tensorflow\python\ops\gen_math_ops.py:5721 _max
    name=name)
d:\ludwig\venv\lib\site-packages\tensorflow\python\framework\op_def_library.py:744 _apply_op_helper
    attrs=attr_protos, op_def=op_def)
d:\ludwig\venv\lib\site-packages\tensorflow\python\framework\func_graph.py:593 _create_op_internal
    compute_device)
d:\ludwig\venv\lib\site-packages\tensorflow\python\framework\ops.py:3485 _create_op_internal
    op_def=op_def)
d:\ludwig\venv\lib\site-packages\tensorflow\python\framework\ops.py:1975 __init__
    control_input_ops, op_def)
d:\ludwig\venv\lib\site-packages\tensorflow\python\framework\ops.py:1815 _create_c_op
    raise ValueError(str(e))

ValueError: Invalid reduction dimension 2 for input with 2 dimensions. for '{{node ecd/text_output_feature/Max}} = Max[T=DT_FLOAT, Tidx=DT_INT32, keep_dims=false](ecd/text_output_feature/Abs_1, ecd/text_output_feature/Max/reduction

_indices)' with input shapes: [1,256], [] and with computed input tensors: input[1] = <2>.

''' How can I solve this problem?

Thank you!

w4nderlust commented 3 years ago

Thank you for posting ths issue. Your model should work on the provided data. Let me look into it. Also @jimthompson5802 who previously helped on sequence decoding may have insights.

farazk86 commented 3 years ago

Hi, were you able to solve this?

I am getting this same error after updating ludwig. Previously using the pre tensroflow2 update the same dataset and model_definition worked. But after update the same code and data gives the error:

 ValueError: Invalid reduction dimension 2 for input with 2 dimensions. for '{{node ecd/text_output_feature/Max}} = Max[T=DT_FLOAT, Tidx=DT_INT32, keep_dims=false](ecd/text_output_featu
re/Abs_1, ecd/text_output_feature/Max/reduction_indices)' with input shapes: [128,512], [] and with computed input tensors: input[1] = <2>.