-
Notifications
You must be signed in to change notification settings - Fork 291
[wwb] Add text reranking pipeline #2786
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| import subprocess # nosec B404 | ||
| import pytest | ||
| import logging | ||
| from test_cli_image import run_wwb | ||
|
|
||
|
|
||
| logging.basicConfig(level=logging.INFO) | ||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("model_id", "model_type"), | ||
| [ | ||
| ("cross-encoder/ms-marco-TinyBERT-L2-v2", "text-reranking"), | ||
| ], | ||
| ) | ||
| def test_reranking_basic(model_id, model_type, tmp_path): | ||
| GT_FILE = tmp_path / "gt.csv" | ||
| MODEL_PATH = tmp_path / model_id.replace("/", "--") | ||
|
|
||
| result = subprocess.run(["optimum-cli", "export", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @apaniukov please give us more details |
||
| "openvino", "-m", model_id, | ||
| MODEL_PATH, "--task", | ||
| "text-classification", | ||
| "--trust-remote-code"], | ||
| capture_output=True, | ||
| text=True, | ||
| ) | ||
| assert result.returncode == 0 | ||
|
|
||
| # Collect reference with HF model | ||
| run_wwb([ | ||
| "--base-model", | ||
| model_id, | ||
| "--num-samples", | ||
| "1", | ||
| "--gt-data", | ||
| GT_FILE, | ||
| "--device", | ||
| "CPU", | ||
| "--model-type", | ||
| model_type, | ||
| "--hf", | ||
| ]) | ||
|
|
||
| # test Optimum | ||
| run_wwb([ | ||
| "--target-model", | ||
| MODEL_PATH, | ||
| "--num-samples", | ||
| "1", | ||
| "--gt-data", | ||
| GT_FILE, | ||
| "--device", | ||
| "CPU", | ||
| "--model-type", | ||
| model_type, | ||
| ]) | ||
|
|
||
| # test GenAI | ||
| run_wwb([ | ||
| "--target-model", | ||
| MODEL_PATH, | ||
| "--num-samples", | ||
| "1", | ||
| "--gt-data", | ||
| GT_FILE, | ||
| "--device", | ||
| "CPU", | ||
| "--model-type", | ||
| model_type, | ||
| "--genai", | ||
| "--output", | ||
| tmp_path, | ||
| ]) | ||
|
|
||
| # test w/o models | ||
| run_wwb([ | ||
| "--target-data", | ||
| tmp_path / "target.csv", | ||
| "--num-samples", | ||
| "1", | ||
| "--gt-data", | ||
| GT_FILE, | ||
| "--device", | ||
| "CPU", | ||
| "--model-type", | ||
| model_type, | ||
| "--genai", | ||
| ]) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("model_id", "model_type"), | ||
| [ | ||
| ("Qwen/Qwen3-Reranker-0.6B", "text-reranking"), | ||
| ], | ||
| ) | ||
| def test_reranking_qwen(model_id, model_type, tmp_path): | ||
| GT_FILE = tmp_path / "gt.csv" | ||
| MODEL_PATH = tmp_path / model_id.replace("/", "--") | ||
|
|
||
| result = subprocess.run(["optimum-cli", "export", | ||
| "openvino", "-m", model_id, | ||
| MODEL_PATH, "--task", | ||
| "text-generation", | ||
| "--trust-remote-code"], | ||
| capture_output=True, | ||
| text=True, | ||
| ) | ||
| assert result.returncode == 0 | ||
|
|
||
| # Collect reference with HF model | ||
| run_wwb([ | ||
| "--base-model", | ||
| model_id, | ||
| "--num-samples", | ||
| "1", | ||
| "--gt-data", | ||
| GT_FILE, | ||
| "--device", | ||
| "CPU", | ||
| "--model-type", | ||
| model_type, | ||
| "--hf", | ||
| ]) | ||
|
|
||
| # test Optimum | ||
| run_wwb([ | ||
| "--target-model", | ||
| MODEL_PATH, | ||
| "--num-samples", | ||
| "1", | ||
| "--gt-data", | ||
| GT_FILE, | ||
| "--device", | ||
| "CPU", | ||
| "--model-type", | ||
| model_type, | ||
| ]) | ||

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.
It seems that WWB and GenAI tests use different replacement strategies.
.replace("/", "_")in GenAIThere 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.
@sbalandi let's align in a separate PR