/
githubmirror
/
ColossalAI
Обзор
Документация
Войти
/
githubmirror
/
ColossalAI
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
applications/ColossalChat/coati/experience_buffer/base.py
43 строки
1 KB
YeAnbang
[ColossalChat] Update RLHF V2 (#5286)
29 мар 2024, 09:12
Не верифицирован
29 мар 2024, 09:12
df5e9c5
Код
Авторство
О чём код?
from abc import ABC, abstractmethod from typing import Any from coati.experience_maker.base import Experience class ExperienceBuffer(ABC): """Experience buffer base class. It stores experience. Args: sample_batch_size (int): Batch size when sampling. limit (int, optional): Limit of number of experience samples. A number <= 0 means unlimited. Defaults to 0. """ def __init__(self, sample_batch_size: int, limit: int = 0) -> None: super().__init__() self.sample_batch_size = sample_batch_size # limit <= 0 means unlimited self.limit = limit @abstractmethod def append(self, experience: Experience) -> None: pass @abstractmethod def clear(self) -> None: pass @abstractmethod def sample(self) -> Experience: pass @abstractmethod def __len__(self) -> int: pass @abstractmethod def __getitem__(self, idx: int) -> Any: pass @abstractmethod def collate_fn(self, batch: Any) -> Experience: pass