From 5d677dae08c37278d349b1db13e5f269d6252f9b Mon Sep 17 00:00:00 2001 From: Pawel Rzepecki Date: Tue, 8 Sep 2026 13:16:11 +0200 Subject: [PATCH] adding max_length additional validation --- src/embeddings/embeddings_servable.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/embeddings/embeddings_servable.cpp b/src/embeddings/embeddings_servable.cpp index fac2eca433..69cbd1bb5f 100644 --- a/src/embeddings/embeddings_servable.cpp +++ b/src/embeddings/embeddings_servable.cpp @@ -371,8 +371,13 @@ void reshapeModel(std::shared_ptr& model, std::shared_ptr EmbeddingsServable::applyPrePostProcessing(ov::Core& core, std::shared_ptr model, ov::AnyMap& properties) { if (this->configuredMaxLength.has_value()) { - SPDLOG_DEBUG("Overriding detected max model length {} with configured value {}", this->maxModelLength.value_or(0), this->configuredMaxLength.value()); - this->maxModelLength = this->configuredMaxLength; + if (this->maxModelLength.has_value() && this->configuredMaxLength.value() > this->maxModelLength.value()) { + SPDLOG_ERROR("Configured max length {} is greater than detected max model length {}", this->configuredMaxLength.value(), this->maxModelLength.value()); + OPENVINO_THROW("Configured max length is greater than detected max model length"); + } else { + SPDLOG_DEBUG("Overriding detected max model length {} with configured value {}", this->maxModelLength.value_or(0), this->configuredMaxLength.value()); + this->maxModelLength = this->configuredMaxLength; + } } if (this->targetDevice == "NPU" && model->is_dynamic()) { TextEmbeddingPipeline::Config config;