shon-otmazgin / fastcoref

MIT License
142 stars 25 forks source link

Finetuning with custom dataset #50

Closed znadrich-qf closed 8 months ago

znadrich-qf commented 8 months ago

Sorry if this has been asked before, but is there a way to fine tune the FCoref model on a custom dataset? If so, is there any documentation or code snippets I can look at? It would also be helpful to know what format my data needs to be in.

Awesome library and paper, by the way!

shon-otmazgin commented 8 months ago

Hi @znadrich-qf, Please try to read the README file, you will find there training section. Let me know if that helps

znadrich-qf commented 8 months ago

Thanks @shon-otmazgin for the quick response, I do see this code snippet from the README

from fastcoref import TrainingArgs, CorefTrainer

args = TrainingArgs(
    output_dir='test-trainer',
    overwrite_output_dir=True,
    model_name_or_path='distilroberta-base',
    device='cuda:2',
    epochs=129,
    logging_steps=100,
    eval_steps=100
)   # you can control other arguments such as learning head and others.

trainer = CorefTrainer(
    args=args,
    train_file='train_file_with_clusters.jsonlines', 
    dev_file='path-to-dev-file',    # optional
    test_file='path-to-test-file',   # optional
    nlp=nlp # optional, for custom nlp class from spacy
)
trainer.train()
trainer.evaluate(test=True)

trainer.push_to_hub('your-fast-coref-model-path')

it seems like this code snippet is focused on training a new model, if I wanted to use the existing FCoref model as a base would I just need to change some of the arguments? Such as model_name_or_path='distilroberta-base' to the path of the FCoref model

znadrich-qf commented 8 months ago

I think I've got it all figured out!