09a3d3ab17
Check Pre-Tokenizer Hashes / pre-tokenizer-hashes (push) Waiting to run
Python check requirements.txt / check-requirements (push) Waiting to run
Python Type-Check / python type-check (push) Waiting to run
Update Operations Documentation / update-ops-docs (push) Waiting to run
Copilot Setup Steps / copilot-setup-steps (push) Failing after 2s
30 lines
882 B
Python
30 lines
882 B
Python
from __future__ import annotations
|
|
|
|
from typing import Callable, TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from torch import Tensor
|
|
|
|
from .base import ModelBase, gguf
|
|
|
|
from .llava import LlavaVisionModel
|
|
|
|
|
|
@ModelBase.register("LightOnOCRForConditionalGeneration")
|
|
class LightOnOCRVisionModel(LlavaVisionModel):
|
|
is_mistral_format = False
|
|
use_break_tok = False
|
|
|
|
def set_gguf_parameters(self):
|
|
super().set_gguf_parameters()
|
|
self.gguf_writer.add_clip_projector_type(gguf.VisionProjectorType.LIGHTONOCR)
|
|
|
|
@classmethod
|
|
def filter_tensors(cls, item: tuple[str, Callable[[], Tensor]]) -> tuple[str, Callable[[], Tensor]] | None:
|
|
name, gen = item
|
|
|
|
name = name.replace("model.vision_encoder.", "vision_tower.")
|
|
name = name.replace("model.vision_projection.", "multi_modal_projector.")
|
|
|
|
return super().filter_tensors((name, gen))
|