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(docs): [SCv1] Automatically create and upload a custom HF model to seldon-models in GCS on every version release #5104

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/upgrade-to-rclone/global-rclone-upgrade.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"In this documentation page we provide an example upgrade path from kfserving-based to rclone-based storage initializer. This is required due to the fact that secret format expected by these two storage initializers is different. \n",
"\n",
"Storage initializers are used by Seldon's pre-packaged model servers to download models binaries. \n",
"As it is explained in the [SC 1.8 upgrading notes](https://docs.seldon.io/projects/seldon-core/en/latest/reference/upgrading.html#upgrading-to-1-8) the [seldonio/rclone-storage-initializer](https://github.com/SeldonIO/seldon-core/tree/master/components/rclone-storage-initializer) became default storage initializer in v1.8.0. However, it is still possible to run with kfserving-based Storage Initializer as documented [here](https://docs.seldon.io/projects/seldon-core/en/latest/servers/kfserving-storage-initializer.html).\n",
"As it is explained in the [SC 1.8 upgrading notes](https://docs.seldon.io/projects/seldon-core/en/latest/reference/upgrading.html#upgrading-to-1-8) the [seldonio/rclone-storage-initializer](https://github.com/SeldonIO/seldon-core/tree/master/components/rclone-storage-initializer) became default storage initializer in v1.8.0.\n",
"\n",
"In this tutorial we aim to provide an intuition of the steps you will have to carry to migrate to the new rclone-based Storage Initializer with the context that every cluster configuration will be different, so you should be able to see this as something you can build from.\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/upgrade-to-rclone/rclone-upgrade.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"In this documentation page we provide an example upgrade path from kfserving-based to rclone-based storage initializer. This is required due to the fact that secret format expected by these two storage initializers is different. \n",
"\n",
"Storage initializers are used by Seldon's pre-packaged model servers to download models binaries. \n",
"As it is explained in the [SC 1.8 upgrading notes](https://docs.seldon.io/projects/seldon-core/en/latest/reference/upgrading.html#upgrading-to-1-8) the [seldonio/rclone-storage-initializer](https://github.com/SeldonIO/seldon-core/tree/master/components/rclone-storage-initializer) became default storage initializer in v1.8.0. However, it is still possible to run with kfserving-based Storage Initializer as documented [here](https://docs.seldon.io/projects/seldon-core/en/latest/servers/kfserving-storage-initializer.html).\n",
"As it is explained in the [SC 1.8 upgrading notes](https://docs.seldon.io/projects/seldon-core/en/latest/reference/upgrading.html#upgrading-to-1-8) the [seldonio/rclone-storage-initializer](https://github.com/SeldonIO/seldon-core/tree/master/components/rclone-storage-initializer) became default storage initializer in v1.8.0.\n",
"\n",
"In this tutorial we will show how to upgrade your configuration to new Storage Initializer with focus on getting the new format of a required secret right.\n",
"\n",
Expand Down
6 changes: 5 additions & 1 deletion servers/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
models: mlflowserver-models sklearnserver-models
models: mlflowserver-models sklearnserver-models huggingface-models


mlflowserver-models:
Expand All @@ -8,3 +8,7 @@ mlflowserver-models:
sklearnserver-models:
make -C sklearnserver/models/iris
make -C sklearnserver/models/moviesentiment


huggingface-models:
make -C huggingface/models/text-generation
2 changes: 2 additions & 0 deletions servers/huggingface/models/text-generation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env/
text-generation-model-artefacts/
16 changes: 16 additions & 0 deletions servers/huggingface/models/text-generation/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
VERSION := $(shell cat ../../../../version.txt)

all: env train upload

model: env train

env:
python3 -m venv .env
./.env/bin/pip install --upgrade pip setuptools
./.env/bin/pip install -r requirements.txt

train:
.env/bin/python train.py

upload:
gsutil cp -r text-generation-model-artefacts/* gs://seldon-models/v${VERSION}/huggingface/custom-text-generation/
3 changes: 3 additions & 0 deletions servers/huggingface/models/text-generation/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
seldon_core
transformers >=4.30,<4.32
tensorflow == 2.12.0
19 changes: 19 additions & 0 deletions servers/huggingface/models/text-generation/train.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from transformers import (
GPT2Tokenizer,
TFGPT2LMHeadModel,
pipeline,
)


def main() -> None:
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
model = TFGPT2LMHeadModel.from_pretrained("gpt2")

p = pipeline(task="text-generation", model=model, tokenizer=tokenizer)

p.save_pretrained("text-generation-model-artefacts")


if __name__ == "__main__":
print("Building a custom HuggingFace model...")
main()
Loading