Skip to content

Commit

Permalink
hf support load gguf file
Browse files Browse the repository at this point in the history
  • Loading branch information
CL-ModelCloud committed Dec 25, 2024
1 parent 932e8f9 commit 58348a2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lm_eval/models/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def __init__(
delta: Optional[str] = None,
autogptq: Optional[Union[bool, str]] = False,
gptqmodel: Optional[bool] = False,
gguf_file: Optional[str] = None,
**kwargs,
) -> None:
super().__init__()
Expand Down Expand Up @@ -164,6 +165,7 @@ def __init__(
pretrained,
revision=revision,
trust_remote_code=trust_remote_code,
gguf_file=gguf_file,
)

# determine which of 'causal' and 'seq2seq' backends to use for HF models
Expand All @@ -178,6 +180,7 @@ def __init__(
revision=revision,
trust_remote_code=trust_remote_code,
use_fast_tokenizer=use_fast_tokenizer,
gguf_file=gguf_file,
)

# if we passed `pretrained` as a string, initialize our model now
Expand All @@ -196,6 +199,7 @@ def __init__(
delta=delta,
autogptq=autogptq,
gptqmodel=gptqmodel,
gguf_file=gguf_file,
**kwargs,
)

Expand Down Expand Up @@ -508,12 +512,14 @@ def _get_config(
pretrained: str,
revision: str = "main",
trust_remote_code: bool = False,
gguf_file: Optional[str] = None,
) -> None:
"""Return the model config for HuggingFace models"""
self._config = transformers.AutoConfig.from_pretrained(
pretrained,
revision=revision,
trust_remote_code=trust_remote_code,
gguf_file=gguf_file,
)

def _create_model(
Expand All @@ -535,6 +541,7 @@ def _create_model(
delta: Optional[str] = None,
autogptq: Optional[Union[bool, str]] = False,
gptqmodel: Optional[bool] = False,
gguf_file: Optional[str] = None,
**kwargs,
) -> None:
"""
Expand Down Expand Up @@ -579,6 +586,7 @@ def _create_model(
revision=revision,
torch_dtype=get_dtype(dtype),
trust_remote_code=trust_remote_code,
gguf_file=gguf_file,
**model_kwargs,
)
else:
Expand Down Expand Up @@ -676,6 +684,7 @@ def _create_tokenizer(
revision: Optional[str] = "main",
trust_remote_code: Optional[bool] = False,
use_fast_tokenizer: Optional[bool] = True,
gguf_file: Optional[str] = None,
) -> None:
"""
Helper method during initialization.
Expand All @@ -691,6 +700,7 @@ def _create_tokenizer(
revision=revision,
trust_remote_code=trust_remote_code,
use_fast=use_fast_tokenizer,
gguf_file=gguf_file,
)
else:
assert isinstance(
Expand All @@ -709,6 +719,7 @@ def _create_tokenizer(
revision=revision,
trust_remote_code=trust_remote_code,
use_fast=use_fast_tokenizer,
gguf_file=gguf_file,
)
return None

Expand Down

0 comments on commit 58348a2

Please sign in to comment.