Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing pre-trained sub-modules #14

Closed
Tracked by #9
bpiwowar opened this issue May 15, 2023 · 2 comments
Closed
Tracked by #9

Accessing pre-trained sub-modules #14

bpiwowar opened this issue May 15, 2023 · 2 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request
Milestone

Comments

@bpiwowar
Copy link
Collaborator

bpiwowar commented May 15, 2023

When a model is trained, one might want to access one of its submodules in another task, e.g.

model = output["validation"]["best"]
faiss_index = FaissIndexBuilder(encoder=model.encoder).submit()

In that case, the encoder is random... and this is quite unexpected.

Potential solutions:

  1. Add a mechanism in experimaestro that allows linking the sub-models to the main one - when initialized, the encoder will require the model to be loaded from the checkpoint. Caveats: as with any implicit process, this makes xpmir more complex and might have other side effects.

  2. Add a mechanism to have several tasks to be run (and in that case, the output will be just the path), instead of just one, i.e.

    load_model = LoadModel(model=model, checkpoint=output["validation"]["best"])
    
    index = FaissIndexBuilder(encoder=model.encoder).submit(pre_tasks=[load_model])

    Important caveat: it breaks the current HuggingFace uploading/downloading mechanism and we need to include load_model each time we want to use the pre-trained model (which can begin to be cumbersome when various models are combined since we need to track down this). For HF, the solution would be to have this when loading

    model, load_model = AutoModel.load_from_hf_hub("xpmir/SPLADE_DistilMSE")
  3. Third solution, do something a bit in between

     best_model = model_loader(model=model, checkpoint=output["validation"]["best"])
     index = FaissIndexBuilder(encoder=best_model.encoder).submit()

    where model_loader is a special experimaestro object (ConfigFactory) that does whatever is needed and returns the "encoder" submodel.

@bpiwowar bpiwowar added bug Something isn't working enhancement New feature or request labels May 15, 2023
@bpiwowar bpiwowar added this to the Version 1.0 milestone May 15, 2023
@bpiwowar bpiwowar self-assigned this May 15, 2023
@bpiwowar bpiwowar mentioned this issue May 15, 2023
16 tasks
@bpiwowar
Copy link
Collaborator Author

bpiwowar commented Jun 8, 2023

Re-opening: the current solution is not optimal, so it is better to switch to solution 2 (Add a mechanism to have several tasks to be run)

@bpiwowar bpiwowar reopened this Jun 8, 2023
@bpiwowar
Copy link
Collaborator Author

Fixed in bcaa1ef with experimaestro 0.28 that includes initialization tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant