MCPcopy Create free account
hub / github.com/OpenSparseLLMs/MoM / __init__

Method __init__

lm-eval-harness/lm_eval/api/model.py:176–191  ·  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

174
175class CachingLM:
176 def __init__(self, lm, cache_db) -> None:
177 """LM wrapper that returns cached results if they exist, and uses the underlying LM if not.
178
179 :param lm: LM
180 Underlying LM
181 :param cache_db: str
182 Path to cache db
183 """
184 self.lm = lm
185 self.cache_db = cache_db
186 if os.path.dirname(cache_db):
187 os.makedirs(os.path.dirname(cache_db), exist_ok=True)
188 self.dbdict = SqliteDict(cache_db, autocommit=True)
189
190 # add hook to lm
191 lm.set_cache_hook(self.get_cache_hook())
192
193 def __getattr__(self, attr):
194 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