-
Notifications
You must be signed in to change notification settings - Fork 67
refactor: user experience improvement after fine-tuning #522
Conversation
related PR in core: https://github.com/jina-ai/finetuner-core/pull/307 |
For the clip models the stubs used here before are quite different from the stubs in finetuner-core (and finetuner-commons), i.e., there was only one stub instead of two for clip-text and clip-vision. This should be taken care of, when the code is refactored, e.g., in the get_row method: finetuner/finetuner/model/__init__.py Lines 9 to 17 in 5b904f2
|
waiting for PR https://github.com/jina-ai/finetuner-core/pull/308 |
@@ -6,6 +6,6 @@ version = 0.5.2 | |||
# E203 is whitespace before ':' - which occurs in numpy slicing, e.g. in | |||
# dists[2 * i : 2 * i + 2, :] | |||
# W503 is line break before binary operator - happens when black splits up lines | |||
ignore = E203, W503 | |||
ignore = E203, W503, F405, F403 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do these ignore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import * from stubs and commons
setup.py
Outdated
install_requires=_main_deps, | ||
install_requires=[ | ||
'docarray[common]>=0.13.31', | ||
'finetuner-stubs==0.0.1b1', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we dont have an official version yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
until we release and trigger core CD
finetuner/callback/__init__.py
Outdated
@@ -0,0 +1 @@ | |||
from stubs.callback import * # noqa F401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you create a directory here? why not a callback.py
module?
finetuner/model/__init__.py
Outdated
@@ -0,0 +1,17 @@ | |||
from stubs.model import * # noqa F401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, why not a model.py
module?
@@ -74,12 +75,22 @@ def logs(self) -> str: | |||
experiment_name=self._experiment_name, run_name=self._name | |||
) | |||
|
|||
def stream_logs(self) -> Iterator[str]: | |||
def stream_logs(self, interval: int = 5) -> Iterator[str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's document the interval argument here
finetuner/__init__.py
Outdated
) | ||
} | ||
def _list_models() -> Dict[str, model.ModelStubType]: | ||
from stubs import model as model_stub |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not import at the top? I think this importing inside the function can become a bad habit
finetuner/__init__.py
Outdated
@@ -161,7 +172,7 @@ def fit( | |||
:param learning_rate: learning rate for the optimizer. | |||
:param epochs: Number of epochs for fine-tuning. | |||
:param batch_size: Number of items to include in a batch. | |||
:param callbacks: List of callback stub objects. See the `finetuner.callback` | |||
:param callbacks: List of callback stub objects.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
` char in the end
select_model: Optional[str] = None, | ||
gpu: bool = False, | ||
logging_level: str = 'WARNING', | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add type hint
@@ -296,3 +307,82 @@ def get_token() -> str: | |||
:return: user token as string object. | |||
""" | |||
return ft.get_token() | |||
|
|||
|
|||
def get_model( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont like the get_model name, maybe build_engine
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, think about when we support pytorch, it's not ort engine anymore
:param select_model: Finetuner run artifacts might contain multiple models. In | ||
such cases you can select which model to deploy using this argument. For CLIP | ||
fine-tuning, you can choose either `clip-vision` or `clip-text`. | ||
:param gpu: if specified to True, use cuda device for inference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logging level is missing from the docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some minor comments
finetuner/__init__.py
Outdated
"""Re-build the model based on the model inference session with ONNX. | ||
|
||
:param artifact: Specify a finetuner run artifact. Can be a path to a local | ||
directory, a path to a local zip file or a Hubble artifact ID. Individual |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directory, a path to a local zip file or a Hubble artifact ID. Individual | |
directory, a path to a local zip file, or a Hubble artifact ID. Individual |
finetuner/__init__.py
Outdated
data: DocumentArray, | ||
batch_size: int = 32, | ||
): | ||
"""Process, collate and encode the `DocumentArray` with embeddings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is "[Pre-]process"
finetuner/__init__.py
Outdated
..Note:: | ||
please install finetuner[full] to include all the dependencies. | ||
""" | ||
for i, batch in enumerate(data.batch(batch_size)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where do you need the i
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Closes #511 #514
finetuner-stubs
. DONEfinetuner-stubs
. DONEfinetuner-commons
as a soft dependency:pip install "finetuner[full]"
DONEfinetuner-commons
, includsget_model
andpreprocess_and_collate
DONE: