-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4d48fa
commit a9f0a4b
Showing
3 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
from .internlm2 import InternLM2 | ||
from .qwen2 import Qwen2 | ||
from .mixtral import Mixtral | ||
from .llava import Llava |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from .llama import Llama | ||
from llmc.utils.registry_factory import MODEL_REGISTRY | ||
from transformers import LlavaForConditionalGeneration, AutoConfig | ||
|
||
|
||
@MODEL_REGISTRY | ||
class Llava(Llama): | ||
def __init__(self, model_path, torch_dtype): | ||
super().__init__(model_path, torch_dtype) | ||
|
||
def build_model(self): | ||
self.model_config = AutoConfig.from_pretrained( | ||
self.model_path, trust_remote_code=True | ||
) | ||
self.model_config.text_config.use_cache = False | ||
self.llava_model = LlavaForConditionalGeneration.from_pretrained( | ||
self.model_path, | ||
config=self.model_config, | ||
torch_dtype=self.torch_dtype, | ||
low_cpu_mem_usage=True, | ||
) | ||
self.model = self.llava_model.language_model |