trinity.buffer.selector package#

Submodules#

Module contents#

class trinity.buffer.selector.BaseSelector(data_source: _HFBatchReader, config: TaskSelectorConfig)[源代码]#

基类:object

Abstract base class defining the interface for custom data selection strategies.

A selector determines which samples (by index) are selected from the dataset during training. It enables flexible sampling beyond simple sequential or random access, supporting active learning, curriculum learning, or difficulty-based sampling in the future.

Subclasses must implement:
  • get_indices: returns list of indices for next batch

  • update: updates internal state using feedback (e.g., loss values, mean rewards, etc.)

  • state_dict / load_state_dict: for saving/loading selector state (checkpointing)

__init__(data_source: _HFBatchReader, config: TaskSelectorConfig)[源代码]#
get_indices(batch_size: int, return_extra_info: bool = False) List[int][源代码]#

Select a batch of sample indices from the dataset.

参数:
  • batch_size (int) -- Number of indices to return

  • return_extra_info (bool) -- If True, may return additional metadata (future use)

返回:

Selected indices into the dataset

返回类型:

List[int]

load_state_dict(state_dict: Dict) None[源代码]#

Restore selector state from a saved dictionary.

参数:

state_dict (Dict) -- Output from state_dict()

state_dict() Dict[源代码]#

Return serializable state of the selector for checkpointing.

返回:

State information (e.g., current position, etc.)

返回类型:

Dict

update(indices: List[int], values: List[float]) None[源代码]#

Update internal state based on feedback (e.g., model loss, accuracy).

This allows adaptive selectors (like hard example mining) to learn over time.

参数:
  • indices (List[int]) -- Previously selected indices

  • values (List[float]) -- Feedback values corresponding to those indices