Update _utils.py
This commit is contained in:
parent
0ee78d455c
commit
5da313d883
1 changed files with 4 additions and 4 deletions
|
|
@ -151,10 +151,10 @@ if hasattr(transformers.cache_utils, "DynamicCache") and \
|
|||
source = source.split("\n")
|
||||
source = "\n".join(x[start:] for x in source)
|
||||
where = source.find("raise KeyError")
|
||||
# source = source[:where] + \
|
||||
# f"if len(self) == 0:\n{spaces}{spaces}"\
|
||||
# " raise RuntimeError('Unsloth: You must call `FastLanguageModel.for_inference(model)` before doing inference for Unsloth models.')\n" + \
|
||||
# f"{spaces}{spaces}else:\n{spaces}{spaces}{spaces}" + source[where:]
|
||||
source = source[:where] + \
|
||||
f"if len(self) == 0:\n{spaces}{spaces}"\
|
||||
" raise RuntimeError('Unsloth: You must call `FastLanguageModel.for_inference(model)` before doing inference for Unsloth models.')\n" + \
|
||||
f"{spaces}{spaces}else:\n{spaces}{spaces}{spaces}" + source[where:]
|
||||
source = source.replace("__getitem__", "__cache_utils_getitem__", 1)
|
||||
exec(source)
|
||||
transformers.cache_utils.DynamicCache.__getitem__ = __cache_utils_getitem__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue