src.wic#

Submodules#

Package Contents#

Classes#

ContextualEmbedder

DeepMistake

WICModel

Helper class that provides a standard way to create an ABC using

class src.wic.ContextualEmbedder(**data: Any)#

Bases: src.wic.model.WICModel

property device: torch.device#
property tokenizer: transformers.PreTrainedTokenizerBase#
property model: transformers.PreTrainedModel#
truncation_tokens_before_target: float#
similarity_metric: Callable[Ellipsis, float]#
normalization: None | Callable[[torch.Tensor], torch.Tensor]#
ckpt: str#
layers: conlist(item_type=conint(ge=0), unique_items=True)#
embedding_cache: EmbeddingCache | None#
gpu: int | None#
layer_aggregator: LayerAggregator#
subword_aggregator: SubwordAggregator#
encode_only: bool#
_embeddings: dict[src.use.Use, torch.Tensor]#
_device: torch.device#
_tokenizer: transformers.PreTrainedTokenizerBase#
_model: transformers.PreTrainedModel#
__enter__()#
__exit__(exc_type, exc_val, exc_tb)#
as_df() pandas.DataFrame#
truncation_indices(target_subword_indices: list[bool]) tuple[int, int]#
predict(use_pairs: Iterable[tuple[src.use.Use, src.use.Use]]) list[float]#
tokenize(use: src.use.Use) transformers.BatchEncoding#
aggregate(tensor: torch.Tensor, layers: list[int]) torch.Tensor#
encode_all(uses: list[src.use.Use], type: Type[T] = np.ndarray) list[T]#
encode(use: src.use.Use, type: Type[T] = np.ndarray) T#
class src.wic.DeepMistake#

Bases: src.wic.model.WICModel

property path: pathlib.Path#
property repo_dir: pathlib.Path#
property ckpt_dir: pathlib.Path#
ckpt: Model#
cache: Cache | None#
__enter__() None#
__exit__(exc_type, exc_val, exc_tb)#
as_df() pandas.DataFrame#
clone_repo() None#
__unzip_ckpt(zipped: pathlib.Path) None#
__download_ckpt() pathlib.Path#
predict(use_pairs: list[tuple[src.use.Use, src.use.Use]]) list[float]#
class src.wic.WICModel(**data: Any)#

Bases: pydantic.BaseModel, abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

class Config#
json_encoders#
_cache: pandas.DataFrame#
_cache_path: pathlib.Path#
scaler: Any#
predictions: dict[tuple[src.use.UseID, src.use.UseID], float]#
abstract as_df() pandas.DataFrame#
abstract predict(use_pairs: Iterable[tuple[src.use.Use, src.use.Use]], **kwargs) list[float]#
predict_all(use_pairs: list[tuple[src.use.Use, src.use.Use]]) list[float]#