Shortcuts

lightrft.datasets.hpdv3

class lightrft.datasets.hpdv3.HPDv3GRMHandler[source]

Bases: HPDv3Handler

Data Handler for HPDv3 dataset with Generative Reward Model (GRM) training. Inherits from HPDv3Handler but overrides parse_item to suit GRM needs.

Paper: https://huggingface.co/MizzenAI/HPSv3 Dataset Repo: https://huggingface.co/datasets/MizzenAI/HPDv3

parse_item(item: Dict[str, Any], media_content: Dict[str, Any], config: Dict[str, Any]) Tuple[List[Dict], List[Dict], Dict][source]

Parse a single HPDv3 item for GRM training.

Parameters:
  • item (Dict[str, Any]) – The raw data item

  • media_content (Dict[str, Any]) – Loaded visual content

  • config (Dict[str, Any]) – Configuration for task instructions and max_pixels

Returns:

A tuple of (messages, metadata)

Return type:

Tuple[List[Dict], Dict]

Example:

messages, other = handler.parse_item(item, media_content, config)
class lightrft.datasets.hpdv3.HPDv3Handler[source]

Bases: BaseDataHandler

Data Handler for HPDv3 dataset. Image-to-Text human preferences dataset.

Paper: https://huggingface.co/MizzenAI/HPSv3 Dataset Repo: https://huggingface.co/datasets/MizzenAI/HPDv3

get_media_info(item: Dict[str, Any]) Dict[str, Dict[str, str]][source]

Extract path info for the preferred and rejected images.

Parameters:

item (Dict[str, Any]) – A data item from load_data

Returns:

Dict containing local paths for ‘preferred_image’ and ‘rejected_image’, or None if files missing

Return type:

Dict[str, Dict[str, str]]

Example:

info = handler.get_media_info(item)
load_data(path: str) List[Dict[str, Any]][source]

Load and validate HPDv3 data from JSON or JSONL file.

Parameters:

path (str) – Path to the JSON/JSONL file

Returns:

List of valid samples with ‘data_root’ attached

Return type:

List[Dict[str, Any]]

Example:

handler = HPDv3Handler()
data = handler.load_data("path/to/HPDv3/data.json")
parse_item(item: Dict[str, Any], media_content: Dict[str, Any], config: Dict[str, Any]) Tuple[List[Dict], List[Dict], Dict][source]

Parse a single HPDv3 item into message pairs and metadata for ranking.

Randomly shuffles preferred/rejected images to avoid positional bias.

Parameters:
  • item (Dict[str, Any]) – The raw data item

  • media_content (Dict[str, Any]) – Loaded visual content

  • config (Dict[str, Any]) – Configuration for task instructions and max_pixels

Returns:

A tuple of (messages0, messages1, metadata)

Return type:

Tuple[List[Dict], List[Dict], Dict]

Raises:

ValueError – If required visual content or prompt is missing.

Example:

msg0, msg1, other = handler.parse_item(item, media_content, config)
task_type = 'text-to-image'
class lightrft.datasets.hpdv3.HPDv3PairHandler[source]

Bases: HPDv3Handler

Data Handler for HPDv3 dataset in pairwise format. Inherits from HPDv3Handler but overrides parse_item to suit pairwise training.

Paper: https://huggingface.co/MizzenAI/HPSv3 Dataset Repo: https://huggingface.co/datasets/MizzenAI/HPDv3

parse_item(item: Dict[str, Any], visual_content: Dict[str, Any], config: Dict[str, Any]) Tuple[List[Dict], Dict][source]

Parse a data item into pairwise messages and metadata.

Parameters:
  • item (Dict[str, Any]) – The raw data item

  • visual_content (Dict[str, Any]) – Loaded visual content

  • config (Dict[str, Any]) – Configuration for task instructions and max_pixels

Returns:

A tuple of (messages, metadata)

Return type:

Tuple[List[Dict], Dict]

Example:

messages, other = handler.parse_item(item, media_content, config)