Spaces:
Running
on
Zero
Running
on
Zero
from typing import Dict, List, Optional, Any | |
from abc import ABC, abstractmethod | |
from functools import cached_property | |
import torch.nn as nn | |
import torch | |
class Modality(ABC): | |
def build_projector(self, lm_hidden_size: int) -> nn.Module: | |
pass | |
def name(self) -> str: | |
pass | |
def token(self) -> str: | |
pass | |
def data_key(self) -> str: | |
pass | |
def token_width(self) -> int: | |
pass | |
def token_idx(self) -> int: | |
hash_ = sum(ord(c) ** i for i, c in enumerate(self.token)) | |
return -abs(hash_ % 10_000) | |
def preprocess_rows(self, rows: List[Dict]) -> List[Optional[Any]]: | |
pass | |
def forward(self, encoded_values: List[Any]) -> List[torch.Tensor]: | |
pass | |
def to(self, dtype: torch.dtype, device: torch.device) -> "Modality": | |
return self | |