Skip to content
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d1dc553
Add Llama4 text model
yicycyc May 26, 2026
a3ede51
Merge upstream/develop into Llama4 support
yicycyc Jul 15, 2026
eac6aa9
Merge remote-tracking branch 'upstream/develop' into feat/llama4-migr…
yicycyc Jul 21, 2026
a5df5d6
Address Llama4 review feedback
yicycyc Jul 21, 2026
b4292e0
fix Llama4 chunked attention padding mask
yicycyc Jul 21, 2026
009a292
Merge branch 'develop' into feat/llama4-migration
yicycyc Jul 23, 2026
66640ad
Add Llama4 CE template and LoRA support
yicycyc Jul 24, 2026
b725dbc
Apply Llama4 pre-commit formatting
yicycyc Jul 24, 2026
ab2a155
Merge branch 'develop' into feat/llama4-migration
yicycyc Aug 3, 2026
de595fe
fix(llama4): preserve auto model mapping
yicycyc Aug 3, 2026
9c37e08
Merge branch 'develop' into feat/llama4-migration
yicycyc Aug 11, 2026
713abde
feat(llama4): add multimodal conditional generation model
yicycyc Aug 10, 2026
363949b
fix(llama4): support guard checkpoint loading and cache
yicycyc Aug 10, 2026
2030b3b
style(llama4): apply pre-commit formatting
yicycyc Aug 11, 2026
16fe9a6
docs(llama4): document Llama Guard 4 support
yicycyc Aug 11, 2026
b04f92b
fix(llama4): support cached multimodal generation
yicycyc Aug 11, 2026
54e7d32
fix(llama4): preserve auto loading and generation inputs
yicycyc Aug 11, 2026
73eadc2
Merge branch 'develop' into feat/llama4-migration
yicycyc Aug 27, 2026
d35d737
fix(auto): restore path fallback after develop merge
yicycyc Aug 27, 2026
f428ebe
fix(llama4): honor hidden-state config defaults
yicycyc Sep 3, 2026
eb450bb
fix(llama4): propagate multimodal hidden-state default
yicycyc Sep 3, 2026
3a1e36b
fix(llama4): limit recompute to training
yicycyc Sep 8, 2026
14109a9
fix(llama4): address latest model review
yicycyc Sep 8, 2026
ef04699
fix(llama4): honor multimodal projector bias
yicycyc Sep 8, 2026
8cf54f5
refactor(llama4): remove unused attention wrapper
yicycyc Sep 8, 2026
2ecbe2a
Merge remote-tracking branch 'upstream/develop' into merge/llama4
yicycyc Sep 8, 2026
f1fd861
[Model] Add Llama4 multimodal processors
yicycyc Sep 9, 2026
198afa3
Merge remote-tracking branch 'upstream/develop' into merge/llama4
yicycyc Sep 15, 2026
c36290e
fix(llama4): accept visual token masks during template registration
yicycyc Sep 15, 2026
dc3e0a4
fix(llama4): disable cache during training recompute
yicycyc Sep 15, 2026
37661f1
Fix Llama4 text and vision templates, LoRA registration and attention…
yicycyc Sep 17, 2026
362a8ae
Merge develop and reconcile llama4 model registrations
yicycyc Sep 30, 2026
bd4d1ee
Merge develop and preserve Llama4 and MiniMax registrations
yicycyc Oct 3, 2026
7890e20
Merge branch 'develop' into feat/llama4-migration
yicycyc Oct 13, 2026
9eb4c1d
style: separate Llama4 and Molmo plugin classes
yicycyc Oct 13, 2026
cc08161
fix: restore independent Llama4 and Molmo image plugins
yicycyc Oct 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ PaddleFormers 是基于百度深度学习框架 PaddlePaddle 搭建的 Transform
<tbody>
<!-- LLM 分类 - 跨行合并开始 -->
<tr>
<td rowspan="15" style="vertical-align: top;">LLM</td>
<td rowspan="16" style="vertical-align: top;">LLM</td>
<td>DeepSeekv3</td>
<td>deepseek-ai/DeepSeek-V3-Base、deepseek-ai/DeepSeek-V3、deepseek-ai/DeepSeek-V3-0324</td>
<td>deepseek3</td>
Expand Down Expand Up @@ -100,6 +100,11 @@ PaddleFormers 是基于百度深度学习框架 PaddlePaddle 搭建的 Transform
<td>meta-llama/Meta-Llama-3-8B、meta-llama/Meta-Llama-3-8B-Instruct、meta-llama/Meta-Llama-3-70B、meta-llama/Meta-Llama-3-70B-Instruct、meta-llama/Llama-3.1-8B、meta-llama/Llama-3.1-8B-Instruct、meta-llama/Llama-3.1-70B、meta-llama/Llama-3.1-70B-Instruct、meta-llama/Llama-3.1-405B、meta-llama/Llama-3.1-405B-Instruct、meta-llama/Llama-3.2-1B、meta-llama/Llama-3.2-1B-Instruct、meta-llama/Llama-3.2-3B、meta-llama/Llama-3.2-3B-Instruct、meta-llama/Llama-3.3-70B-Instruct</td>
<td>llama3</td>
</tr>
<tr>
<td>Llama-4-Text</td>
<td>meta-llama/Llama-4-Scout-17B-16E、meta-llama/Llama-4-Maverick-17B-128E</td>
<td>llama4</td>
</tr>
<tr>
<td>OLMo2</td>
<td>allenai/OLMo-2-0425-1B、allenai/OLMo-2-0425-1B-SFT、allenai/OLMo-2-0425-1B-DPO、allenai/OLMo-2-0425-1B-Instruct、allenai/OLMo-2-1124-7B、allenai/OLMo-2-1124-7B-SFT、allenai/OLMo-2-1124-7B-DPO、allenai/OLMo-2-1124-7B-Instruct、allenai/OLMo-2-1124-13B、allenai/OLMo-2-1124-13B-SFT、allenai/OLMo-2-1124-13B-DPO、allenai/OLMo-2-1124-13B-Instruct、allenai/OLMo-2-0325-32B、allenai/OLMo-2-0325-32B-SFT、allenai/OLMo-2-0325-32B-DPO、allenai/OLMo-2-0325-32B-Instruct</td>
Expand Down Expand Up @@ -132,7 +137,12 @@ PaddleFormers 是基于百度深度学习框架 PaddlePaddle 搭建的 Transform
</tr>
<!-- VLM 分类 - 跨行合并开始 -->
<tr>
<td rowspan="4" style="vertical-align: top;">VLM</td>
<td rowspan="5" style="vertical-align: top;">VLM</td>
<td>Llama Guard 4</td>
<td>meta-llama/Llama-Guard-4-12B</td>
<td>llama4</td>
</tr>
<tr>
<td>🏛️ERNIE-4.5-VL</td>
<td>baidu/ERNIE-4.5-VL-28B-A3B-Base-PT、baidu/ERNIE-4.5-VL-28B-A3B-PT、baidu/ERNIE-4.5-VL-424B-A47B-Base-PT、baidu/ERNIE-4.5-VL-424B-A47B-PT、baidu/ERNIE-4.5-VL-28B-A3B-Thinking</td>
<td>ernie_vl、ernie_vl_nothink</td>
Expand Down
4 changes: 4 additions & 0 deletions docs/zh/model_capability.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
|GPT-OSS|✓|✓|✓|x|x|
|Granite|✓|✓|✓|✓|✓|
|LLaMA3|✓|✓|✓|✓|✓|
|LLaMA4-Text|✓|✓|✓|x|x|
|OLMo2|✓|✓|✓|✓|✓|
|Phi4|✓|✓|✓|✓|✓|
|Qwen2|✓|✓|✓|✓|✓|
|Qwen3|✓|✓|✓|✓|✓|
|Qwen3-Next|✓|✓|✓|✓|✓|
|Llama Guard 4|x|✓|✓|x|x|

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Llama Guard 4 的lora没注册

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已在 37661f1 补齐并推送。CLI 默认 LoRA target 注册加入多模态 model_type=llama4,复用 Llama4 文本投影目标,并新增注册回归测试。同步检查 FastVLM、LFM2-VL、DeepSeek-OCR2、Phi-4、Mistral3 的对应注册,均已有分支。Llama4 整组测试 51 passed、5 skipped;本轮未重跑完整 LoRA 训练。

|🏛️ERNIE-4.5-VL|x|✓|✓|x|x|
|🏛️PaddleOCR-VL|x|✓|✓|x|x|
|Qwen2.5-VL|x|✓|✓|x|x|
Expand All @@ -28,11 +30,13 @@
|GPT-OSS|✓|✓|x|x|✓|✓|
|Granite|✓|✓|-|x|✓|✓|
|LLaMA3|✓|✓|-|x|✓|✓|
|LLaMA4-Text|x|x|x|x|✓|✓|
|OLMo2|✓|✓|-|x|✓|✓|
|Phi4|✓|✓|-|x|✓|✓|
|Qwen2|✓|✓|x|x|✓|✓|
|Qwen3|✓|✓|✓|✓|✓|✓|
|Qwen3-Next|✓|✓|✓|x|✓|✓|
|Llama Guard 4|x|x|-|x|x|x|
|🏛️ERNIE-4.5-VL|✓|✓|✓|x|✓|✓|
|🏛️PaddleOCR-VL|x|x|-|x|✓|✓|
|Qwen2.5-VL|✓|x|-|x|✓|✓|
Expand Down
2 changes: 1 addition & 1 deletion paddleformers/cli/utils/llm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_lora_target_modules(model):
]
elif model.config.model_type == "bloom":
target_modules = [".*query_key_value.*", ".*dense.*", ".*dense_h_to_4h.*", ".*dense_4h_to_h.*"]
elif model.config.model_type in ["llama", "jamba", "olmo2"]:
elif model.config.model_type in ["llama", "llama4_text", "jamba", "olmo2"]:
target_modules = [
".*q_proj.*",
".*v_proj.*",
Expand Down
1 change: 1 addition & 0 deletions paddleformers/datasets/template/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"Qwen3VLPlugin",
"GLM4VPlugin",
"Gemma3Plugin",
"Llama4Plugin",
"register_mm_plugin",
"get_mm_plugin",
],
Expand Down
39 changes: 39 additions & 0 deletions paddleformers/datasets/template/mm_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,44 @@ def get_mm_inputs(
return mm_inputs


@dataclass
class Llama4Plugin(BasePlugin):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

纯文本和带图都会用到这个plugin,纯文数据在_validate_input的判断里面会因为没有image processor而raise(136-137L)
建议纯文和多模拆成两个模版名,参考qwen3/qwen3_vl,glm4_moe/glm4v等

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已在 37661f1 修复并推送。拆分为 llama4(纯文本 BasePlugin)和 llama4_vl(图文 Llama4Plugin),保留相同对话格式;纯文本不再要求 image processor。新增无 processor 的文本模板回归测试,README 中 Guard4 模板同步改为 llama4_vl。图文配置需使用新模板名。Llama4 整组测试 51 passed、5 skipped,pre-commit 通过。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Llama4Plugin和MolmoPlugin互相冲突有问题,需要解决。
直接跑测试用例tests/transformers/llama4/test_processor.py也能发现同一个问题,辛苦确保后续commit自测通过测试用例后再提交

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已在 cc08161 修复并完成自测后推送。上一次仅修格式,没有核查合并后的类结构,确实漏掉了逻辑错误,抱歉。

本次将 aspect_ratios / tile 占位符展开的 process_messages 恢复到 Llama4Plugin;MolmoPlugin 恢复独立 @DataClass 和 Molmo 自身的 User 前缀逻辑。AST 核对:Llama4Plugin 与合并前一致,MolmoPlugin 与当前 develop 一致。

新增3项回归,连同现有 placeholder 展开测试做修复前后对照:旧代码4项失败,修复后4项通过。最终复跑 tests/transformers/llama4、tests/transformers/molmo、共享 template/tool_utils 测试:145 passed、9 skipped、4 subtests passed;包含您指出的 test_processor.py。AutoModel 架构优先级另行验证通过。PR全部Python文件 pre-commit通过。

9个skip属于既有未实现/不适用测试及缺少torch的跨框架测试,未宣称执行。未修改模型计算公式;当前develop已包含,无Git合并冲突。

masked_tokens: Optional[list[str]] = None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里沿用了基类 image_max_pixels 预缩放,但是llama4不是动态分辨率不需要这步吧?HF上也没有这步,实测1200×900出的tile数量不一致。建议覆写 _get_mm_inputs,绕过 _preprocess_image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已在 37661f1 修复并推送。覆写 Llama4Plugin._get_mm_inputs,只读取图像、转换 RGB、按 imglens 分组,绕过基类像素预算预缩放,由 Llama4ImageProcessor 根据原图尺寸选择 tiles。新增 1200×900 图像回归测试,确认 plugin 与直接 image processor 的 aspect_ratios、pixel_values 完全一致。Llama4 整组测试 51 passed、5 skipped,pre-commit 通过。

@override
def process_messages(
self,
messages,
images,
videos,
audios,
mm_inputs,
processor,
):
self._validate_input(processor, images, videos, audios)
self._validate_messages(messages, images, videos, audios)
if not images:
return messages

aspect_ratios = mm_inputs.get("aspect_ratios")
if aspect_ratios is None or len(aspect_ratios) != len(images):
raise ValueError("Llama 4 requires one aspect ratio for each input image.")

messages = deepcopy(messages)
image_index = 0
num_patches_per_chunk = processor._num_patches_per_chunk()
for message in messages:
content = message["content"]
while IMAGE_PLACEHOLDER in content:
image_string = processor._prompt_split_image(aspect_ratios[image_index], num_patches_per_chunk)
if not self.expand_mm_tokens:
image_string = self.image_token
content = content.replace(IMAGE_PLACEHOLDER, image_string, 1)
image_index += 1
message["content"] = content
return messages


@dataclass
class GlmOcrPlugin(BasePlugin):
"""
Expand Down Expand Up @@ -1608,6 +1646,7 @@ def _get_mm_inputs(
"qwen3_vl": Qwen3VLPlugin,
"glm4v": GLM4VPlugin,
"gemma3": Gemma3Plugin,
"llama4": Llama4Plugin,
"qwen2_omni": Qwen2OmniPlugin,
"glm_ocr": GlmOcrPlugin,
"kimi_k3": KimiK3Plugin,
Expand Down
36 changes: 36 additions & 0 deletions paddleformers/datasets/template/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,42 @@ def _get_gpt_oss_prefix():
chat_sep="<|eot_id|>",
)

register_template(
name="llama4",
format_user=StringFormatter(
slots=[
("<|header_start|>user<|header_end|>\n\n{{content}}<|eot|>" "<|header_start|>assistant<|header_end|>\n\n")
]
),
format_assistant=StringFormatter(slots=["{{content}}"]),
format_system=StringFormatter(slots=["<|header_start|>system<|header_end|>\n\n{{content}}<|eot|>"]),
format_function=FunctionFormatter(slots=["{{content}}"], tool_format="llama4"),
format_observation=StringFormatter(
slots=[
(
"<|header_start|>ipython<|header_end|>\n\n{{content}}<|eot|>"
"<|header_start|>assistant<|header_end|>\n\n"
)
]
),
format_tools=ToolFormatter(tool_format="llama4"),
format_prefix=EmptyFormatter(slots=[{"bos_token"}]),
suffix=["<|eot|>"],
chat_sep="<|eot|>",
mm_plugin=get_mm_plugin(
name="llama4",
image_token="<|image|>",
masked_tokens=[
"<|image|>",
"<|image_start|>",
"<|image_end|>",
"<|patch|>",
"<|tile_x_separator|>",
"<|tile_y_separator|>",
],
),
)


# copied from gemma template
register_template(
Expand Down
37 changes: 37 additions & 0 deletions paddleformers/datasets/template/tool_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ class FunctionCall(NamedTuple):
"Do not use variables.\n\n{tool_text}"
)

LLAMA4_TOOL_PROMPT = (
"You are a helpful assistant and an expert in function composition. You can answer general questions using your "
"internal knowledge OR invoke functions when necessary.\n"
"Here is a list of functions in JSON format that you can invoke:\n{tool_text}\n"
"Should you decide to return the function call(s), put them in the format of "
"[func1(param_name=param_value, ...), func2(...)].\n"
"Do not include any other text in the response when returning function calls."
)


@dataclass
class ToolUtils(ABC):
Expand Down Expand Up @@ -288,6 +297,33 @@ def function_formatter(functions: list["FunctionCall"]) -> str:
return json.dumps(function_objects[0] if len(function_objects) == 1 else function_objects, ensure_ascii=False)


class Llama4ToolUtils(ToolUtils):
r"""Llama 4 zero-shot tool calling format.

Reference: https://github.com/meta-llama/llama-models/blob/main/models/llama4/prompt_format.md
"""

@override
@staticmethod
def tool_formatter(tools: list[dict[str, Any]]) -> str:
normalized_tools = [tool.get("function", {}) if tool.get("type") == "function" else tool for tool in tools]
tool_text = json.dumps(normalized_tools, indent=4, ensure_ascii=False)
return LLAMA4_TOOL_PROMPT.format(tool_text=tool_text)

@override
@staticmethod
def function_formatter(functions: list["FunctionCall"]) -> str:
function_texts = []
for name, arguments in functions:
parsed_arguments = json.loads(arguments)
argument_text = ", ".join(
f"{key}={json.dumps(value, ensure_ascii=False)}" for key, value in parsed_arguments.items()
)
function_texts.append(f"{name}({argument_text})")

return "[" + ", ".join(function_texts) + "]"


class ERNIEToolUtils(ToolUtils):
r"""ERNIE 4.5 tool using template."""

Expand Down Expand Up @@ -346,6 +382,7 @@ def function_formatter(functions: list["FunctionCall"]) -> str:
"glm4_moe": GLM4MOEToolUtils(),
"glm_moe_dsa": GLM_5ToolUtils(),
"llama3": Llama3ToolUtils(),
"llama4": Llama4ToolUtils(),
}


Expand Down
12 changes: 12 additions & 0 deletions paddleformers/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@
"llama.modeling": ["LlamaForCausalLM", "LlamaModel", "LlamaForCausalLMPipe", "LlamaRotaryEmbedding"],
"llama.tokenizer": ["LlamaTokenizer", "Llama3Tokenizer"],
"llama.tokenizer_fast": ["LlamaTokenizerFast"],
"llama4.configuration": ["Llama4Config", "Llama4TextConfig", "Llama4VisionConfig"],
"llama4.image_processor": ["Llama4ImageProcessor", "Llama4ImageProcessorKwargs"],
"llama4.image_processor_fast": ["Llama4ImageProcessorFast"],
"llama4.modeling": [
"Llama4ForCausalLM",
"Llama4TextDecoderLayer",
"Llama4TextModel",
"Llama4TextPretrainedModel",
],
"llama4.multimodal": ["Llama4ForConditionalGeneration", "Llama4VisionEncoderLayer", "Llama4VisionModel"],
"llama4.processor": ["Llama4Processor", "Llama4ProcessorKwargs"],
"optimization": [
"LinearDecayWithWarmup",
"ConstScheduleWithWarmup",
Expand Down Expand Up @@ -351,6 +362,7 @@
"Qwen3NextPretrainingCriterion",
],
"llama": [],
"llama4": [],
"qwen2": [],
"glm_ocr": [],
"qwen3": [],
Expand Down
5 changes: 5 additions & 0 deletions paddleformers/transformers/auto/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
("ernie4_5_moe_vl", "Ernie4_5_VLConfig"),
("paddleocr_vl", "PaddleOCRVLConfig"),
("llama", "LlamaConfig"),
("llama4", "Llama4Config"),
("llama4_text", "Llama4TextConfig"),
("kimi_k2", "KimiK2Config"),
("kimi_k3", "KimiK3Config"),
("qwen2", "Qwen2Config"),
Expand Down Expand Up @@ -99,6 +101,8 @@
("ernie4_5_moe_vl", "Ernie4_5_VLMoeForConditionalGeneration"),
("paddleocr_vl", "PaddleOCRVLForConditionalGeneration"),
("llama", "Llama"),
("llama4", "Llama4ForConditionalGeneration"),
("llama4_text", "Llama4TextModel"),
("kimi_k3", "KimiK3"),
("qwen2", "Qwen2"),
("qwen2_5_vl", "Qwen2_5_VL"),
Expand Down Expand Up @@ -140,6 +144,7 @@

SPECIAL_MODEL_TYPE_TO_MODULE_NAME = OrderedDict(
[
("llama4_text", "llama4"),
("paligemma", "paligemma2"),
("gemma3", "gemma3"),
("qwen2_5_vl_text", "qwen2_5_vl"),
Expand Down
1 change: 1 addition & 0 deletions paddleformers/transformers/auto/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"kimi_k3": ("KimiK3VisionProcessor"),
"paddleocr_vl": ("PaddleOCRVLImageProcessor"),
"gemma3": ("Gemma3ImageProcessor", "Gemma3ImageProcessorFast"),
"llama4": ("Llama4ImageProcessor", "Llama4ImageProcessorFast"),
"qwen2_5_vl": ("Qwen2VLImageProcessor", "Qwen2VLImageProcessorFast"),
"qwen2_vl": ("Qwen2VLImageProcessor", "Qwen2VLImageProcessorFast"),
"qwen3_vl": ("Qwen3VLImageProcessor", "Qwen3VLImageProcessorFast"),
Expand Down
18 changes: 14 additions & 4 deletions paddleformers/transformers/auto/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
("Ernie4_5_VLMoe", "ernie4_5_moe_vl"),
("PaddleOCRVL", "paddleocr_vl"),
("Llama", "llama"),
("Llama4", "llama4"),
("KimiK2", "kimi_k2"),
("KimiK3", "kimi_k3"),
("Qwen2", "qwen2"),
Expand Down Expand Up @@ -97,7 +98,13 @@
]
)

MAPPING_SPACIAL_KEY = OrderedDict([("Gemma3", "Gemma3"), ("Ernie4_5_VLMoe", "Ernie4_5_VLMoeForConditionalGeneration")])
MAPPING_SPACIAL_KEY = OrderedDict(
[
("Gemma3", "Gemma3"),
("Ernie4_5_VLMoe", "Ernie4_5_VLMoeForConditionalGeneration"),
("Llama4", "Llama4Text"),
Comment thread
yicycyc marked this conversation as resolved.
]
)
CONFIGURATION_MODEL_MAPPING = OrderedDict([((), "Gemma3ForConditionalGeneration")])

MAPPING_TASKS = OrderedDict(
Expand Down Expand Up @@ -203,9 +210,9 @@ def _get_model_class_from_config(
if model_flag in init_class:
model_name = model_flag + "Model"
break
if model_name is None and init_class == "PaliGemmaForConditionalGeneration":
model_name = "PaliGemma2ForConditionalGenerationModel"
elif model_name is None:
if model_name is None and init_class == "PaliGemmaForConditionalGeneration":
model_name = "PaliGemma2ForConditionalGenerationModel"
if model_name is None and init_class is None:
# From pretrained_model_name_or_path
for model_flag, name in SORTED_MAPPING_NAMES.items():
if type(pretrained_model_name_or_path) is str and name in pretrained_model_name_or_path.lower():
Expand All @@ -214,6 +221,9 @@ def _get_model_class_from_config(
if init_class == "PaliGemmaForConditionalGeneration":
import_class = importlib.import_module("paddleformers.transformers.paligemma2.modeling")
return getattr(import_class, "PaliGemma2ForConditionalGeneration")
if init_class == "Llama4ForConditionalGeneration":
import_class = importlib.import_module("paddleformers.transformers.llama4.multimodal")
return getattr(import_class, "Llama4ForConditionalGeneration")
if model_name is None:
# Try to get model class from config class
if not isinstance(config, PretrainedConfig) and pretrained_model_name_or_path is not None:
Expand Down
1 change: 1 addition & 0 deletions paddleformers/transformers/auto/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
("paddleocr_vl", "PaddleOCRVLProcessor"),
("ernie4_5_moe_vl", "Ernie4_5_VLProcessor"),
("gemma3", "Gemma3Processor"),
("llama4", "Llama4Processor"),
("shieldgemma2", "ShieldGemma2Processor"),
("glm4v_moe", "Glm4vProcessor"),
("glm_ocr", "Glm46VProcessor"),
Expand Down
Loading
Loading