Giter VIP home page Giter VIP logo

Comments (11)

l0renor avatar l0renor commented on June 15, 2024 1

Hi,
i made an workaround by adding
model.model.save_pretrained('')
at the end of train.py

from rebel.

l0renor avatar l0renor commented on June 15, 2024

I debugged so far:
in the pl saving.py file two dictionarys are merged
checkpoint[cls.CHECKPOINT_HYPER_PARAMS_KEY].update(kwargs)
Here the error occurs in the _utils.py file of omegaconf in line 365:

value = _get_value(value)
if value == "???": #Here the error gets thrown because of the comparison
return ret(ValueKind.MANDATORY_MISSING)```

Can someone tell me how to fix this so i can save the model?

from rebel.

LittlePea13 avatar LittlePea13 commented on June 15, 2024

If I remember correctly such errors have to do with the Pytorch Lightning version. Could you share your installed version?

from rebel.

l0renor avatar l0renor commented on June 15, 2024

Hi I am using 1.1.7.
Thanks for the quick reply.
What version would you recommend?

from rebel.

LittlePea13 avatar LittlePea13 commented on June 15, 2024

That's the recommended version. I am not sure what could be wrong. Can you try directly calling load_from_checkpoint from the module:

model = BasePLModule.load_from_checkpoint(checkpoint_path = 'path_to_checkpoint.ckpt')

from rebel.

l0renor avatar l0renor commented on June 15, 2024

I tried different approaches but didn't get it to work. I am event more confused than before.

Errors in different trys

1

#module =  BasePLModule(conf, config, tokenizer, model)
module = pl.LightningModule()

model = module.load_from_checkpoint(checkpoint_path = 'model_convert/rebel_fintune_doc_red.ckpt')

error

(base) (rebelenv) PS C:\Users\leon.lukas\Documents\X-Next\Code\Rebel_Experiments\rebel-main\src> python .\model_saving.py
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
Traceback (most recent call last):
File ".\model_saving.py", line 35, in
model = module.load_from_checkpoint(checkpoint_path = 'model_convert/rebel_fintune_doc_red.ckpt')
File "C:\Users\leon.lukas\Documents\X-Next\Code\Rebel_Experiments\rebel-main\rebelenv\lib\site-packages\pytorch_lightning\core\saving.py", line 159, in load_from_checkpoint
model = cls._load_model_state(checkpoint, strict=strict, kwargs)
File "C:\Users\leon.lukas\Documents\X-Next\Code\Rebel_Experiments\rebel-main\rebelenv\lib\site-packages\pytorch_lightning\core\saving.py", line 199, in _load_model_state
model = cls(
_cls_kwargs)
File "C:\Users\leon.lukas\Documents\X-Next\Code\Rebel_Experiments\rebel-main\rebelenv\lib\site-packages\pytorch_lightning\core\lightning.py", line 73, in init
super().init(*args, **kwargs)
TypeError: init() got an unexpected keyword argument 'train_batch_size'

2

this Version used to give me the error from my initial comment. Now config, tokenizer, mode don't seem to be passed through to pytorch_lightning\core\saving.py", line 199, in _load_model_state

because of this the error when updating the dict doesn't occour.

module =  BasePLModule(conf, config, tokenizer, model)
#module = pl.LightningModule()

model = module.load_from_checkpoint(checkpoint_path = 'model_convert/rebel_fintune_doc_red.ckpt')

model.model.save_pretrained('rebel_doc_red')
model.tokenizer.save_pretrained('rebel_doc_red')

error

Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
Traceback (most recent call last):
File "C:\Users\leon.lukas\Documents\X-Next\Code\Rebel_Experiments\rebel-main\src\model_saving.py", line 36, in
model = module.load_from_checkpoint(checkpoint_path = 'model_convert/rebel_fintune_doc_red.ckpt')
File "C:\Users\leon.lukas\Documents\X-Next\Code\Rebel_Experiments\rebel-main\rebelenv\lib\site-packages\pytorch_lightning\core\saving.py", line 159, in load_from_checkpoint
model = cls._load_model_state(checkpoint, strict=strict, kwargs)
File "C:\Users\leon.lukas\Documents\X-Next\Code\Rebel_Experiments\rebel-main\rebelenv\lib\site-packages\pytorch_lightning\core\saving.py", line 199, in _load_model_state
model = cls(
_cls_kwargs)
TypeError: init() missing 3 required positional arguments: 'config', 'tokenizer', and 'model'

from rebel.

LittlePea13 avatar LittlePea13 commented on June 15, 2024

And which error do you get by trying the first suggestion:
model = BasePLModule.load_from_checkpoint(checkpoint_path = 'path_to_checkpoint.ckpt')

Do not initialize the BasePLModule.

from rebel.

l0renor avatar l0renor commented on June 15, 2024

When I use

model = BasePLModule.load_from_checkpoint(checkpoint_path = 'model_convert/rebel_fintune_doc_red.ckpt',config = config, tokenizer = tokenizer, model = model)
i get the initial error

 omegaconf.errors.ConfigKeyError: 'str' object has no attribute '__dict__'
	full_key: config
	reference_type=Optional[Dict[Union[str, Enum], Any]]
	object_type=dict

from the update of the dict

and if I use it like you suggest even without the ,config = config, tokenizer = tokenizer, model = model)

model = BasePLModule.load_from_checkpoint(checkpoint_path = 'model_convert/rebel_fintune_doc_red.ckpt')
i get

File "C:\Users\leon.lukas\Documents\X-Next\Code\Rebel_Experiments\rebel-main\rebelenv\lib\site-packages\pytorch_lightning\core\saving.py", line 199, in _load_model_state model = cls(**_cls_kwargs) TypeError: __init__() missing 3 required positional arguments: 'config', 'tokenizer', and 'model'

from rebel.

LittlePea13 avatar LittlePea13 commented on June 15, 2024

I am glad you could solve it for your use case. I am sorry I could not provide an answer on how to use the PL checkpoint to do so, whenever I get some time I'll look into it and try to replicate your issue, see if I can find the problem.

from rebel.

SaraBtt avatar SaraBtt commented on June 15, 2024

Hi, i made an workaround by adding model.model.save_pretrained('') at the end of train.py

Hi, I have the exact same issue you had with the saving.
Did you train the model from scratch when you added model.model.save_pretrained('') so that the new checkpoint could be loaded? Or did you manage to salvage the "original" checkpoint?

from rebel.

l0renor avatar l0renor commented on June 15, 2024

Hi,

I loaded the rebel large model, trained it on a dateset and saved the fin-tuned model.

trainer.fit(pl_module, datamodule=pl_data_module)
model.save_pretrained("rebel_nyt_cti")
print("model_saved")```

from rebel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.