Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

[1/2] Use any task as an embedder for any layer #1396

Merged
merged 11 commits into from
Jul 18, 2022

Conversation

ethanwharris
Copy link
Collaborator

@ethanwharris ethanwharris commented Jul 15, 2022

What does this PR do?

This PR adds support for calling as_embedder on any task to convert it to an embedder. The embeddings retain gradient information so they could be used for training the model weights.

This approach uses an exception to break out of the forward in intermediate layers to avoid excess computation.

Still to come in follow-up: docs

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? - Coming in 2/2
  • Did you write any new necessary tests? [not needed for typos/docs]
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

  • Is this pull request ready for review? (if not, please submit in draft mode)

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@ethanwharris ethanwharris added the enhancement New feature or request label Jul 15, 2022
@ethanwharris ethanwharris added this to the 0.8.0 milestone Jul 15, 2022
@ethanwharris ethanwharris changed the title [POC] Use any task as an embedder for any layer [PoC] Use any task as an embedder for any layer Jul 15, 2022
@codecov
Copy link

codecov bot commented Jul 15, 2022

Codecov Report

Merging #1396 (a280e7e) into master (3e4c8bb) will decrease coverage by 0.01%.
The diff coverage is 93.10%.

@@            Coverage Diff             @@
##           master    #1396      +/-   ##
==========================================
- Coverage   92.91%   92.90%   -0.02%     
==========================================
  Files         285      286       +1     
  Lines       12778    12836      +58     
==========================================
+ Hits        11873    11925      +52     
- Misses        905      911       +6     
Flag Coverage Δ
unittests 92.90% <93.10%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
flash/core/utilities/embedder.py 91.48% <91.48%> (ø)
flash/core/model.py 91.42% <100.00%> (+0.23%) ⬆️
flash/text/question_answering/model.py 93.19% <0.00%> (-1.37%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e4c8bb...a280e7e. Read the comment docs.

Copy link
Member

@justusschock justusschock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

tests/core/test_model.py Outdated Show resolved Hide resolved
tests/core/test_model.py Outdated Show resolved Hide resolved
Copy link

@otaj otaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

flash/core/utilities/embedder.py Show resolved Hide resolved
@ethanwharris ethanwharris changed the title [PoC] Use any task as an embedder for any layer [1/2] Use any task as an embedder for any layer Jul 18, 2022
@ethanwharris ethanwharris merged commit 140c5f6 into master Jul 18, 2022
@ethanwharris ethanwharris deleted the feature/as_embedder branch July 18, 2022 11:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants