zhao-zilong / Tabula

Official git for "TabuLa: Harnessing Language Models for Tabular Data Synthesis"
31 stars 11 forks source link

[Bug] Error when saving model #6

Closed iamamiramine closed 3 months ago

iamamiramine commented 6 months ago

I get the following error when saving the model using model.save:

Traceback (most recent call last):
  File "/Tabula/run.py", line 18, in <module>
    model.save("output/")
  File "/Tabula/tabula_middle_padding/tabula.py", line 265, in save
    json.dump(attributes, f)
  File "/miniconda3/envs/tabula/lib/python3.10/json/__init__.py", line 179, in dump
    for chunk in iterable:
  File "/miniconda3/envs/tabula/lib/python3.10/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/miniconda3/envs/tabula/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/miniconda3/envs/tabula/lib/python3.10/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/miniconda3/envs/tabula/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type GPT2Config is not JSON serializable

Any idea how to solve it?

iamamiramine commented 6 months ago

I solved it by adding the following to the model.save method before the json.dump(attribute, f) function:

attributes["config"] = attributes["config"].get_config_dict(self.llm)[0]

get_config_dict is available in the base class of GPT2Config class PretrainedConfig

It would be great if any of Tabula contributors can confirm.