[New Model] Add Lance (ByteDance) (#3710)
Signed-off-by: lishunyang <lishunyang03@gmail.com> Signed-off-by: lishunyang12 <lishunyang12@163.com> Signed-off-by: WeiQing Chen <david6666666@users.noreply.github.com> Co-authored-by: lishunyang <lishunyang03@gmail.com> Co-authored-by: Haco <923390377@qq.com>
This commit is contained in:
24 files changed
+7082
-114
No files matched your search
@@ -847,6 +847,21 @@ class OmniDiffusionConfig:
|
||||
self.supports_multimodal_inputs = metadata.supports_multimodal_inputs
|
||||
self.max_multimodal_image_inputs = metadata.max_multimodal_image_inputs
|
||||
|
||||
@staticmethod
|
||||
def _looks_like_lance_subfolder(model: str | None) -> bool:
|
||||
"""Return True when ``--model`` points at a Lance per-component subfolder.
|
||||
|
||||
Lance's HF repo bundles ``Lance_3B/``, ``Lance_3B_Video/`` and
|
||||
``Qwen2.5-VL-ViT/`` under a single top-level ``config.json``; users may
|
||||
reasonably hand the AR-style sub-checkpoint path directly. The
|
||||
``LancePipeline`` constructor knows to walk up to the repo root from
|
||||
either subfolder name.
|
||||
"""
|
||||
if not model:
|
||||
return False
|
||||
base = os.path.basename(str(model).rstrip("/"))
|
||||
return base in {"Lance_3B", "Lance_3B_Video"}
|
||||
|
||||
def enrich_config(self) -> None:
|
||||
"""Load model metadata from HuggingFace and populate config fields.
|
||||
|
||||
@@ -900,6 +915,15 @@ class OmniDiffusionConfig:
|
||||
else:
|
||||
cfg = get_hf_file_to_dict("config.json", self.model)
|
||||
if cfg is None:
|
||||
# Lance ships its top-level config.json one directory above
|
||||
# the per-checkpoint subfolders (``Lance_3B/`` or
|
||||
# ``Lance_3B_Video/``). Try to recover that case before
|
||||
# raising.
|
||||
if self._looks_like_lance_subfolder(self.model):
|
||||
self.model_class_name = "LancePipeline"
|
||||
self.set_tf_model_config(TransformerConfig())
|
||||
self.update_multimodal_support()
|
||||
return
|
||||
raise ValueError(f"Could not find config.json or model_index.json for model {self.model}")
|
||||
|
||||
self.set_tf_model_config(TransformerConfig.from_dict(cfg))
|
||||
@@ -910,6 +934,19 @@ class OmniDiffusionConfig:
|
||||
self.model_class_name = "BagelPipeline"
|
||||
self.set_tf_model_config(TransformerConfig())
|
||||
self.update_multimodal_support()
|
||||
elif (
|
||||
model_type == "lance"
|
||||
or "LancePipeline" in architectures
|
||||
or cfg.get("model_name") == "Lance"
|
||||
or self._looks_like_lance_subfolder(self.model)
|
||||
):
|
||||
# Lance ships a non-HF top-level config.json (model_name only)
|
||||
# plus per-component subfolders; resolve to the Lance pipeline.
|
||||
# Also accept --model pointing directly at the ``Lance_3B`` or
|
||||
# ``Lance_3B_Video`` subfolder by walking up to the repo root.
|
||||
self.model_class_name = "LancePipeline"
|
||||
self.set_tf_model_config(TransformerConfig())
|
||||
self.update_multimodal_support()
|
||||
elif model_type == "neo_chat":
|
||||
self.model_class_name = "SenseNovaU1Pipeline"
|
||||
self.tf_model_config = TransformerConfig()
|
||||
|
||||
Reference in new issue
Block a user