Skip to content

Add inference example notebooks for LFM2 models#50

Merged
alay2shah merged 16 commits intomainfrom
notebook-examples
Feb 5, 2026
Merged

Add inference example notebooks for LFM2 models#50
alay2shah merged 16 commits intomainfrom
notebook-examples

Conversation

@alay2shah
Copy link
Contributor

  • Transformers: text generation, streaming, vision
  • vLLM: text generation, batching, vision
  • llama.cpp: CLI and server API, vision
  • MLX: text generation, streaming, vision (Apple Silicon note)
  • Ollama: Python/curl API examples, vision

- Transformers: text generation, streaming, vision
- vLLM: text generation, batching, vision
- llama.cpp: CLI and server API, vision
- MLX: text generation, streaming, vision (Apple Silicon note)
- Ollama: Python/curl API examples, vision

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use return_dict=True with apply_chat_template and access
input_ids properly to avoid AttributeError on shape access.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use dtype="bfloat16" (not torch_dtype)
- Use batch_decode as in docs
- Keep tokenize=True as per docs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
IMPORTANT: tie lm_head to input embeddings to fix missing
weights issue in transformers v5.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Pin torch==2.9.0 to prevent errors
- Use dtype instead of torch_dtype (deprecated)
- Remove fallback note

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use pip with --extra-index-url for CUDA support
  (--torch-backend is a uv flag, not pip)
- Fix chat() API to use message format instead of raw strings

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Combined changes: kept updated PR number (#14069) from main and
preserved Colab notebook link from notebook-examples branch.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@alay2shah alay2shah merged commit 6750536 into main Feb 5, 2026
6 checks passed
@alay2shah alay2shah deleted the notebook-examples branch February 5, 2026 19:43
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