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;