Skip to content

Conversation

@husaynirfan1
Copy link
Contributor

This PR refactors colpali_embedding_model.py to support dynamic loading of different ColPali architectures. Previously, the model class was hardcoded to ColQwen2_5, which prevented the use of lightweight models like SmolVLM or the standard PaliGemma checkpoints.

The system now detects the architecture type based on the COLPALI_MODEL_NAME environment variable and instantiates the correct class from colpali_engine.

Key Changes

  • Dynamic Imports: Added ColIdefics3 (for SmolVLM) and ColPali (for PaliGemma) to imports.

  • Model Selector: Implemented logic in init to route model loading:

  • Contains "smol" or "idefics" → Loads ColIdefics3 (with optimized batch sizes).

  • Contains "qwen" → Loads ColQwen2_5.

  • Default/Else → Loads ColPali (Standard v1.2/v1.3 behavior).

Environment Config: Now utilizes os.getenv("COLPALI_MODEL_NAME") to allow hot-swapping models without code changes.

How to Test

Update .env with a specific model:

COLPALI_MODEL_NAME="vidore/colSmol-256M"

Start the service.

Verify logs show: INFO: Detected SmolVLM/Idefics3 architecture.

Performance Impact

  • SmolVLM (256M/500M): significantly faster ingestion due to increased batch size (up to 32x) and smaller parameter count. (and give options to low-end users.)

  • Standard/Qwen: No change in performance; maintains previous batch settings.

Updated ColpaliEmbeddingModel to support dynamic model loading based on environment variable. Added support for ColIdefics3 architecture and adjusted batch sizes accordingly.
Enhance ColpaliEmbeddingModel with dynamic model loading
Added support for COLPALI model configuration.
Updated PDF DPI setting for ColPali processing.
Updated COLPALI_MODEL_NAME to use ColSmolVLM 256/500M architecture.
Added guide comment for colpali model setup.
Updated comments for ColPali model selection and clarified default model name.
@Adityav369
Copy link
Collaborator

Thanks @husaynirfan1, could you pls restore the metrics collection, seems to be removed. Additionally, for non-secrets, it's preferred to have it be morphik.toml driven. Currently, you're reading model from .env. Could we make that toml riven pls?

Changes from .env loading method to morphik.toml global config.
Added options for ColPali model selection in configuration.
Removed comments and default model name from .env.example
Updated ColPali model selection options with descriptions.
@husaynirfan1
Copy link
Contributor Author

The final commit had corrected the processors for ColPali model, added metrics collection and utilize morphik.toml instead of .env file for ColPali model configuration.

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.

2 participants