Comments (11)
Hi,
i made an workaround by adding
model.model.save_pretrained('')
at the end of train.py
from rebel.
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.
If I remember correctly such errors have to do with the Pytorch Lightning version. Could you share your installed version?
from rebel.
Hi I am using 1.1.7.
Thanks for the quick reply.
What version would you recommend?
from rebel.
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.
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.
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.
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.
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.
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.
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)
- DocRED dataset HOT 1
- Replicating REBEL from BART and some issues HOT 2
- Role of shift_tokens_left HOT 1
- Guide to Fine-tuning on Spacy HOT 2
- is it possible to specify which word i want to generate relations for? HOT 1
- Can't find factory for 'rebel' for language English (en). HOT 1
- Explainability of REBEL HOT 1
- Fine tuning for person to person entity relationship extraction HOT 1
- Problem with negative samples HOT 3
- Extraction of non-existant relation HOT 1
- Issue while running the default_model on training with conl dataset HOT 2
- Error while executing conl dataset HOT 1
- Dataset generation error HOT 1
- Pred file and gold file issues
- version incompatible HOT 2
- Financial relations
- Evaluation details of REBEL on DocRED
- SREDFM Chinese dataset
- Embedding of entity
- surfaceform of the REDFM predicate HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rebel.