Add LFM2.5-VL support and testing - #6737
Conversation
|
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. |
There was a problem hiding this comment.
💡 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]: |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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.

Released 2026-08-12: LiquidAI/LFM2.5-VL-3B — 3.1B on-device VLM (SigLIP2 vision tower + LFM2 conv/attention text backbone), open weights.
lfm2_vl_for_conditional_generation.py(Lfm2VlForConditionalGeneration), SmolVLM-style sub-config scale-down; pinned totransformers==5.0.0(first release withlfm2_vl, and theTokenizersBackendfloor the LFM2.5 tokenizer needs). Config diff vs the reference is 11 entries, all scale-downs.lfm2_2_5_vl.jinjaand aliased it onto the existing LFM2.5 branch ofadd_response_schema(same<|tool_call_start|>[...]<|tool_call_end|>format, so it reuseslfm2_2_5_template). No training variant: the template already ships{% generation %}markers.test_sft_trainer.py(3),test_dpo_trainer.py,test_kto_trainer.py, plus the response-schema-VLM, tool-calling and parse-response lists intest_chat_template_utils.py.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.jinjachat template is vendored (multimodal<image>blocks, same tool/thinking/{% generation %}behavior as LFM2.5 text).add_response_schematreats it like LFM2.5 and reuseslfm2_2_5_templatefor response parsing. Docs list LFM2.5-VL among recognized families.A
scripts/generate_tiny_models/.../lfm2_vl_for_conditional_generation.pyscript buildstrl-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 withthinkingfield).Reviewed by Cursor Bugbot for commit c65247c. Bugbot is set up for automated code reviews on this repo. Configure here.