Skip to content

Add LFM2.5-VL support and testing - #6737

Open
qgallouedec wants to merge 2 commits into
mainfrom
add-lfm2-5-vl
Open

Add LFM2.5-VL support and testing#6737
qgallouedec wants to merge 2 commits into
mainfrom
add-lfm2-5-vl

Conversation

@qgallouedec

@qgallouedec qgallouedec commented Aug 13, 2026

Copy link
Copy Markdown
Member

Released 2026-08-12: LiquidAI/LFM2.5-VL-3B — 3.1B on-device VLM (SigLIP2 vision tower + LFM2 conv/attention text backbone), open weights.

  • Tiny model script lfm2_vl_for_conditional_generation.py (Lfm2VlForConditionalGeneration), SmolVLM-style sub-config scale-down; pinned to transformers==5.0.0 (first release with lfm2_vl, and the TokenizersBackend floor the LFM2.5 tokenizer needs). Config diff vs the reference is 11 entries, all scale-downs.
  • Vendored lfm2_2_5_vl.jinja and aliased it onto the existing LFM2.5 branch of add_response_schema (same <|tool_call_start|>[...]<|tool_call_end|> format, so it reuses lfm2_2_5_template). No training variant: the template already ships {% generation %} markers.
  • Tests: VLM param lists in test_sft_trainer.py (3), test_dpo_trainer.py, test_kto_trainer.py, plus the response-schema-VLM, tool-calling and parse-response lists in test_chat_template_utils.py.
  • Tiny model pushed: trl-internal-testing/tiny-Lfm2VlForConditionalGeneration-2.5.

Note

Low Risk
Mostly new template, tiny-model generator, and test parametrization; no changes to core training logic beyond extending existing LFM2.5 response-schema branching.

Overview
Adds LFM2.5-VL (LiquidAI vision-language) to TRL’s supported model families and test matrix.

A new lfm2_2_5_vl.jinja chat template is vendored (multimodal <image> blocks, same tool/thinking/{% generation %} behavior as LFM2.5 text). add_response_schema treats it like LFM2.5 and reuses lfm2_2_5_template for response parsing. Docs list LFM2.5-VL among recognized families.

A scripts/generate_tiny_models/.../lfm2_vl_for_conditional_generation.py script builds trl-internal-testing/tiny-Lfm2VlForConditionalGeneration-2.5 (transformers ≥ 5.0). That tiny model is wired into VLM parametrized tests in SFT, DPO, KTO, and chat template suites (response schema, tool calling, parse-response with thinking field).

Reviewed by Cursor Bugbot for commit c65247c. Bugbot is set up for automated code reviews on this repo. Configure here.

@bot-ci-comment

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e1a3bc755

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

]:
schema, template = qwen3_5_schema, nemotron_3_template
elif chat_template == lfm2_2_5_chat_template:
elif chat_template in [lfm2_2_5_chat_template, lfm2_2_5_vl_chat_template]:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Handle escaped quotes before reusing the LFM parser

When an LFM2.5-VL tool-call string contains an apostrophe, such as O'Reilly, the new template renders it as 'O\'Reilly', but the reused _LFM2_2_5_ARG_VALUE parser only recognizes single-quoted strings with '[^']*'. It therefore truncates the value at the escaped apostrophe, so parse_response cannot reliably round-trip these tool calls; the response template needs an escape-aware value pattern and decoding for the VL format.

Useful? React with 👍 / 👎.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3e1a3bc. Configure here.

Comment thread tests/test_chat_template_utils.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant