mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
@@ -332,10 +332,13 @@ class HFTorchInferenceModel(HFInferenceModel):
|
||||
raise
|
||||
|
||||
logger.warning(f"Fell back to GPT2LMHeadModel due to {e}")
|
||||
logger.debug(traceback.format_exc())
|
||||
|
||||
try:
|
||||
return GPT2LMHeadModel.from_pretrained(location, **tf_kwargs)
|
||||
except Exception as e:
|
||||
logger.warning(f"Fell back to GPTNeoForCausalLM due to {e}")
|
||||
logger.debug(traceback.format_exc())
|
||||
return GPTNeoForCausalLM.from_pretrained(location, **tf_kwargs)
|
||||
|
||||
def get_hidden_size(self) -> int:
|
||||
@@ -462,19 +465,25 @@ class HFTorchInferenceModel(HFInferenceModel):
|
||||
device_map: Dict[str, Union[str, int]] = {}
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
def get_original_key(key):
|
||||
return max(
|
||||
(
|
||||
original_key
|
||||
for original_key in utils.module_names
|
||||
if original_key.endswith(key)
|
||||
),
|
||||
key=len,
|
||||
)
|
||||
def get_original_key(key) -> Optional[str]:
|
||||
key_candidates = [
|
||||
original_key
|
||||
for original_key in utils.module_names
|
||||
if original_key.endswith(key)
|
||||
]
|
||||
|
||||
if not key_candidates:
|
||||
logger.debug(f"!!! No key candidates for {key}")
|
||||
return None
|
||||
|
||||
return max(key_candidates, key=len)
|
||||
|
||||
for key, value in model_dict.items():
|
||||
original_key = get_original_key(key)
|
||||
|
||||
if not original_key:
|
||||
continue
|
||||
|
||||
if isinstance(value, lazy_loader.LazyTensor) and not any(
|
||||
original_key.startswith(n) for n in utils.layers_module_names
|
||||
):
|
||||
|
@@ -4006,7 +4006,7 @@ function update_context(data) {
|
||||
document.getElementById('world_info_'+entry.uid).classList.add("used_in_game");
|
||||
}
|
||||
break;
|
||||
case 'memory':
|
||||
case 'genre':
|
||||
genre_length += entry.tokens.length;
|
||||
break;
|
||||
case 'memory':
|
||||
|
Reference in New Issue
Block a user