Skip to content

[Data][LLM] Add support for classification and scoring models in Ray Data LLM#59499

Merged
kouroshHakha merged 6 commits intoray-project:masterfrom
kouroshHakha:kh/add-score-data-llm
Dec 18, 2025
Merged

[Data][LLM] Add support for classification and scoring models in Ray Data LLM#59499
kouroshHakha merged 6 commits intoray-project:masterfrom
kouroshHakha:kh/add-score-data-llm

Conversation

@kouroshHakha
Copy link
Contributor

Summary

This PR adds support for sequence classification and scoring models in Ray Data LLM batch inference. Previously, only generate and embed task types were supported. This change enables users to run batch inference with models like nvidia/nemocurator-fineweb-nemotron-4-edu-classifier for educational content classification.

Motivation

vLLM supports multiple task types for different model architectures:

  • generate - Text generation (LLMs)
  • embed - Embedding models
  • classify - Sequence classification models
  • score - Cross-encoder scoring models

Ray Data LLM only supported generate and embed. This PR adds classify and score to enable batch inference with classification models.

Usage

from ray.data.llm import vLLMEngineProcessorConfig, build_processor

config = vLLMEngineProcessorConfig(
    model_source="nvidia/nemocurator-fineweb-nemotron-4-edu-classifier",
    task_type="classify",  # NEW: use 'classify' for classification models
    engine_kwargs={"max_model_len": 512},
    apply_chat_template=False,
    detokenize=False,
)

processor = build_processor(
    config,
    preprocess=lambda row: dict(prompt=row["text"]),
    postprocess=lambda row: {"score": float(row["embeddings"][0])},
)

ds = ray.data.from_items([{"text": "Sample text to classify"}])
result = processor(ds)

Testing

  • New classification_example.py is automatically picked up by CI via the existing glob pattern in BUILD.bazel
  • Tested locally with nvidia/nemocurator-fineweb-nemotron-4-edu-classifier

…ata LLM

Add CLASSIFY and SCORE task types to vLLMTaskType enum to enable batch
inference with sequence classification models (e.g., educational content
classifiers, sentiment analyzers) and cross-encoder scoring models.

- Add CLASSIFY and SCORE to vLLMTaskType enum
- Route classify/score tasks to engine.encode() with PoolingParams
- Add classification_example.py documentation example
- Update working-with-llms.rst with classification section
- Add classification config example to basic_llm_example.py

Signed-off-by: Kourosh Hakhamaneshi <kourosh@anyscale.com>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for classification and scoring models to Ray Data's LLM batch inference capabilities, which previously only supported generation and embedding tasks. The changes are well-implemented, introducing classify and score task types and updating the vLLM engine stage to handle them. The documentation and examples have also been updated accordingly. I've provided a few suggestions to improve the robustness of the example code and enhance the maintainability of the core logic.

kouroshHakha and others added 3 commits December 16, 2025 20:58
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: kourosh hakhamaneshi <31483498+kouroshHakha@users.noreply.github.com>
Signed-off-by: Kourosh Hakhamaneshi <kourosh@anyscale.com>
…ha/ray into kh/add-score-data-llm

Signed-off-by: Kourosh Hakhamaneshi <kourosh@anyscale.com>
@kouroshHakha kouroshHakha added the go add ONLY when ready to merge, run all tests label Dec 17, 2025
@kouroshHakha kouroshHakha marked this pull request as ready for review December 17, 2025 05:03
@kouroshHakha kouroshHakha requested review from a team as code owners December 17, 2025 05:03
Signed-off-by: Kourosh Hakhamaneshi <kourosh@anyscale.com>
Copy link
Contributor

@jeffreywang-anyscale jeffreywang-anyscale left a comment

Choose a reason for hiding this comment

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

Looks like you addressed Gemini comments in the latest revision. LGTM.

@ray-gardener ray-gardener bot added data Ray Data-related issues llm labels Dec 17, 2025
Signed-off-by: Kourosh Hakhamaneshi <kourosh@anyscale.com>
@kouroshHakha kouroshHakha merged commit d3a9d8c into ray-project:master Dec 18, 2025
6 checks passed
Yicheng-Lu-llll pushed a commit to Yicheng-Lu-llll/ray that referenced this pull request Dec 22, 2025
…Data LLM (ray-project#59499)

Signed-off-by: Kourosh Hakhamaneshi <kourosh@anyscale.com>
Signed-off-by: kourosh hakhamaneshi <31483498+kouroshHakha@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
peterxcli pushed a commit to peterxcli/ray that referenced this pull request Feb 25, 2026
…Data LLM (ray-project#59499)

Signed-off-by: Kourosh Hakhamaneshi <kourosh@anyscale.com>
Signed-off-by: kourosh hakhamaneshi <31483498+kouroshHakha@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: peterxcli <peterxcli@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues go add ONLY when ready to merge, run all tests llm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants