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

feat: add build_model function #584

Merged
merged 13 commits into from
Oct 27, 2022
Merged

feat: add build_model function #584

merged 13 commits into from
Oct 27, 2022

Conversation

LMMilliken
Copy link
Contributor

@LMMilliken LMMilliken commented Oct 20, 2022

This PR adds a build_model using features added in pr 336.


  • This PR references an open issue
  • I have added a line about this change to CHANGELOG

Copy link
Member

@bwanglzu bwanglzu left a comment

Choose a reason for hiding this comment

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

minor comments

finetuner/__init__.py Outdated Show resolved Hide resolved
finetuner/__init__.py Outdated Show resolved Hide resolved
Copy link
Member

@gmastrapas gmastrapas left a comment

Choose a reason for hiding this comment

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

  1. Also update changelog
  2. Include a unit test for this method

finetuner/__init__.py Outdated Show resolved Hide resolved
finetuner/__init__.py Outdated Show resolved Hide resolved
finetuner/__init__.py Outdated Show resolved Hide resolved
finetuner/__init__.py Outdated Show resolved Hide resolved
@bwanglzu bwanglzu marked this pull request as ready for review October 20, 2022 11:29
@github-actions github-actions bot added size/m area/testing This issue/PR affects testing and removed size/s labels Oct 20, 2022
Copy link
Member

@guenthermi guenthermi left a comment

Choose a reason for hiding this comment

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

added some comments

finetuner/__init__.py Outdated Show resolved Hide resolved
tests/unit/test___init__.py Outdated Show resolved Hide resolved
Comment on lines +8 to +18
@pytest.mark.parametrize(
'descriptor, select_model, is_onnx, expect_error',
[
('bert-base-cased', None, False, None),
('bert-base-cased', None, True, None),
('openai/clip-vit-base-patch16', 'clip-text', False, None),
('openai/clip-vit-base-patch16', 'clip-vision', False, None),
('openai/clip-vit-base-patch16', None, False, SelectModelRequired),
('MADE UP MODEL', None, False, ValueError),
],
)
Copy link
Member

@bwanglzu bwanglzu Oct 26, 2022

Choose a reason for hiding this comment

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

no need to change, but a better way is

Suggested change
@pytest.mark.parametrize(
'descriptor, select_model, is_onnx, expect_error',
[
('bert-base-cased', None, False, None),
('bert-base-cased', None, True, None),
('openai/clip-vit-base-patch16', 'clip-text', False, None),
('openai/clip-vit-base-patch16', 'clip-vision', False, None),
('openai/clip-vit-base-patch16', None, False, SelectModelRequired),
('MADE UP MODEL', None, False, ValueError),
],
)
@pytest.mark.parameterize('is_onnx', [True, False])
@pytest.mark.parametrize(
'descriptor, select_model, expect_error',
[
('bert-base-cased', None, None),
('openai/clip-vit-base-patch16', 'clip-text', None),
('openai/clip-vit-base-patch16', 'clip-vision', None),
('openai/clip-vit-base-patch16', None, SelectModelRequired),
('MADE UP MODEL', None, ValueError),
],
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The more you know!

Copy link
Member

@bwanglzu bwanglzu left a comment

Choose a reason for hiding this comment

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

LGTM!

CHANGELOG.md Outdated Show resolved Hide resolved
finetuner/__init__.py Outdated Show resolved Hide resolved
finetuner/__init__.py Outdated Show resolved Hide resolved
finetuner/__init__.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
Copy link
Member

@gmastrapas gmastrapas left a comment

Choose a reason for hiding this comment

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

One minor thing

finetuner/__init__.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@LMMilliken LMMilliken left a comment

Choose a reason for hiding this comment

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

.

Copy link
Member

@gmastrapas gmastrapas left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@guenthermi guenthermi left a comment

Choose a reason for hiding this comment

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

I added too comments, rather minor

select_model: Optional[str] = None,
device: Optional[str] = None,
is_onnx: bool = False,
):
Copy link
Member

Choose a reason for hiding this comment

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

Here is an annotation of the return type missing

else:
model = finetuner.build_model(
name=descriptor, select_model=select_model, is_onnx=is_onnx
)
Copy link
Member

Choose a reason for hiding this comment

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

if build_model returns nothing it would actually pass. Testing something with the model would be better. Maybe you can just check if you can pass an input and the result is a vector of the expected shape. If this is too much, you could at least check if the type of model is correct and not None

Copy link
Member

@guenthermi guenthermi left a comment

Choose a reason for hiding this comment

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

LGTM, but I think documentation for it is still missing, but you can do this in a separate PR.

@LMMilliken LMMilliken merged commit 01fa333 into main Oct 27, 2022
@LMMilliken LMMilliken deleted the feat-build-zero-shot-model branch October 27, 2022 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants