MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / __init__

Method __init__

test/general/lm_eval/base.py:882–897  ·  view source on GitHub ↗

LM wrapper that returns cached results if they exist, and uses the underlying LM if not. :param lm: LM Underlying LM :param cache_db: str Path to cache db

(self, lm, cache_db)

Source from the content-addressed store, hash-verified

880
881class CachingLM:
882 def __init__(self, lm, cache_db):
883 """LM wrapper that returns cached results if they exist, and uses the underlying LM if not.
884
885 :param lm: LM
886 Underlying LM
887 :param cache_db: str
888 Path to cache db
889 """
890 self.lm = lm
891 self.cache_db = cache_db
892 if os.path.dirname(cache_db):
893 os.makedirs(os.path.dirname(cache_db), exist_ok=True)
894 self.dbdict = SqliteDict(cache_db, autocommit=True)
895
896 # add hook to lm
897 lm.set_cache_hook(self.get_cache_hook())
898
899 def __getattr__(self, attr):
900 lm_attr = getattr(self.lm, attr)

Callers

nothing calls this directly

Calls 2

get_cache_hookMethod · 0.95
set_cache_hookMethod · 0.80

Tested by

no test coverage detected