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

Add Japanese language dependencies #1511

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4e49666
Added Japanese dependencies to mlserver-huggingface
jbauer2718 Dec 12, 2023
e6562e1
Added unit test for Japanese server
jbauer2718 Dec 12, 2023
4414ccf
linted
jbauer2718 Dec 12, 2023
399d83b
Addressed style comments; made dependencies optional
jbauer2718 Dec 14, 2023
854784f
Updated README.md and unit test
jbauer2718 Dec 15, 2023
c6f1a4f
Updated docs
jbauer2718 Dec 15, 2023
f75ee9e
Working test in docs
jbauer2718 Dec 15, 2023
936fadf
Generalized test to a list of cases
jbauer2718 Dec 16, 2023
5b3a258
updated docs
jbauer2718 Dec 16, 2023
c30f2ad
Fixed notebook cell outputs
jbauer2718 Dec 16, 2023
339527f
Fixed notebook cell outputs
jbauer2718 Dec 16, 2023
f44656d
Refactored test with pytest.pymark.parameterize. Used a smaller test …
jbauer2718 Dec 26, 2023
73c60a7
Finished an inline comment I forgot to fully type out
jbauer2718 Dec 26, 2023
2715c2b
Updated lock and docs
jbauer2718 Jan 16, 2024
2a9652b
Removed .bak.ipynb
jbauer2718 Jan 16, 2024
8992881
Updated README.ipynb to match README.md
jbauer2718 Jan 16, 2024
d1ae9b2
Synced with main branch and resolved conflicts
jbauer2718 Apr 12, 2024
e4596e0
rebuilt lock files with same version of poetry
jbauer2718 Apr 12, 2024
aa3ea7b
build(deps-dev): bump pytest-cases from 3.8.4 to 3.8.5 (#1691)
dependabot[bot] Apr 16, 2024
ed6ef38
build(deps): bump scikit-learn in /runtimes/sklearn (#1693)
dependabot[bot] Apr 16, 2024
40fcaf5
build(deps-dev): bump pytorch-lightning in /runtimes/mlflow (#1694)
dependabot[bot] Apr 16, 2024
6639484
build(deps): bump sqlparse from 0.4.4 to 0.5.0 in /runtimes/mlflow (#…
dependabot[bot] Apr 16, 2024
dc93eba
build(deps-dev): bump sqlparse from 0.4.4 to 0.5.0 (#1697)
dependabot[bot] Apr 16, 2024
c6a9c5d
build(deps): bump optimum from 1.17.1 to 1.18.1 in /runtimes/huggingf…
dependabot[bot] Apr 16, 2024
28e4e75
build(deps): bump joblib from 1.3.2 to 1.4.0 in /runtimes/sklearn (#1…
dependabot[bot] Apr 16, 2024
c9ed9ba
build(deps): bump pandas from 2.2.1 to 2.2.2 in /runtimes/lightgbm (#…
dependabot[bot] Apr 16, 2024
b1e7c14
Fixed merge conflict in README
jbauer2718 Apr 16, 2024
7f21db5
Fixed merge conflict in lock
jbauer2718 Apr 16, 2024
6df3dbe
Rebased and fixed lock
jbauer2718 Apr 16, 2024
32d16e8
Added unit test for Japanese server
jbauer2718 Dec 12, 2023
f6a3901
linted
jbauer2718 Dec 12, 2023
47bd2da
Addressed style comments; made dependencies optional
jbauer2718 Dec 14, 2023
188b369
Updated README.md and unit test
jbauer2718 Dec 15, 2023
7fa5d0c
Updated docs
jbauer2718 Dec 15, 2023
d755990
Working test in docs
jbauer2718 Dec 15, 2023
bf4d412
Generalized test to a list of cases
jbauer2718 Dec 16, 2023
6174e00
updated docs
jbauer2718 Dec 16, 2023
5f8c8e3
Fixed notebook cell outputs
jbauer2718 Dec 16, 2023
3fa63e0
Fixed notebook cell outputs
jbauer2718 Dec 16, 2023
aafa4d1
Refactored test with pytest.pymark.parameterize. Used a smaller test …
jbauer2718 Dec 26, 2023
549f244
Finished an inline comment I forgot to fully type out
jbauer2718 Dec 26, 2023
0d61961
Updated lock and docs
jbauer2718 Jan 16, 2024
827329f
Removed .bak.ipynb
jbauer2718 Jan 16, 2024
c9372a5
Updated README.ipynb to match README.md
jbauer2718 Jan 16, 2024
e137c05
rebuilt lock files with same version of poetry
jbauer2718 Apr 12, 2024
d9211bf
Fixed merge conflict in README
jbauer2718 Apr 16, 2024
4a9c1c6
Fixed merge conflict in lock
jbauer2718 Apr 16, 2024
4c63c86
Fixed merge conflicts
jbauer2718 Apr 16, 2024
85bddf1
Update README.md
jbauer2718 Apr 16, 2024
616d3a9
removed files for bert-japanese
jbauer2718 Apr 16, 2024
cf4ec15
Removed model setting
jbauer2718 Apr 16, 2024
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
108 changes: 106 additions & 2 deletions runtimes/huggingface/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions runtimes/huggingface/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ mlserver = "*"
tensorflow = "*"
pillow = "*"
optimum = {extras = ["onnxruntime"], version = ">=1.4,<2.0"}
fugashi = "^1.3.0"
unidic = "^1.1.0"
unidic-lite = "^1.0.8"
ipadic = "^1.0.0"
jbauer2718 marked this conversation as resolved.
Show resolved Hide resolved

[tool.poetry.group.dev.dependencies]
mlserver = {path = "../..", develop = true}
Expand Down
48 changes: 48 additions & 0 deletions runtimes/huggingface/tests/test_tasks/test_japanese_mask_fill.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import pytest
from mlserver.settings import ModelSettings, ModelParameters
from mlserver_huggingface import HuggingFaceRuntime
from mlserver_huggingface.codecs import HuggingfaceRequestCodec


test_sentence = "実際に空が[MASK]のか?"
jbauer2718 marked this conversation as resolved.
Show resolved Hide resolved


@pytest.fixture
def current_model_settings(request) -> ModelSettings:
jbauer2718 marked this conversation as resolved.
Show resolved Hide resolved
if not request.config.option.test_hg_tasks:
pytest.skip()
return ModelSettings(
name="model",
implementation=HuggingFaceRuntime,
parameters=ModelParameters(
extra={
"task": "fill-mask",
"pretrained_model": "cl-tohoku/bert-base-japanese",
sakoush marked this conversation as resolved.
Show resolved Hide resolved
"pretrained_tokenizer": "cl-tohoku/bert-base-japanese",
}
),
)


@pytest.fixture
async def current_runtime(current_model_settings: ModelSettings) -> HuggingFaceRuntime:
runtime = HuggingFaceRuntime(current_model_settings)
await runtime.load()
return runtime


@pytest.fixture
def japanese_text_request():
inputs = [test_sentence]
req = HuggingfaceRequestCodec.encode_request(
{"inputs": inputs},
use_bytes=False,
)
return req


async def test_infer(current_runtime, japanese_text_request):
jbauer2718 marked this conversation as resolved.
Show resolved Hide resolved
sakoush marked this conversation as resolved.
Show resolved Hide resolved
resp = await current_runtime.predict(japanese_text_request)
decoded = HuggingfaceRequestCodec.decode_response(resp)
top_result = list(decoded.items())[0][1][0]
assert top_result["token_str"] == "見える", "Inference is incorrect!"
jbauer2718 marked this conversation as resolved.
Show resolved Hide resolved