linrrzqqq commented on code in PR #71438:
URL: https://github.com/apache/doris/pull/71438#discussion_r4811360600
##########
be/src/exprs/function/ai/embed.h:
##########
@@ -210,36 +245,65 @@ class FunctionEmbed : public AIFunction<FunctionEmbed> {
const int32_t max_batch_size = _get_embed_max_batch_size(context);
+ const ColumnArray* col_array = nullptr;
+ const ColumnArray::Offsets64* offsets = nullptr;
+ const ColumnNullable* nested_nullable = nullptr;
+ const IColumn* fused_json_column = nullptr;
+ bool is_array_const = false;
+ if (is_fused) {
+ const auto& [unpacked_col, is_const] =
unpack_if_const(input_column);
+ is_array_const = is_const;
+ col_array = &assert_cast<const ColumnArray&>(*unpacked_col);
+ offsets = &col_array->get_offsets();
+ const IColumn& nested_col = col_array->get_data();
+ nested_nullable = check_and_get_column<ColumnNullable>(nested_col);
+ fused_json_column =
+ nested_nullable ? &nested_nullable->get_nested_column() :
&nested_col;
+ }
+
for (size_t i = 0; i < input_rows_count; ++i) {
if (null_map && (*null_map)[i]) {
continue;
}
- rapidjson::Document file_input;
- RETURN_IF_ERROR(_parse_file_input(*input_column, i, file_input));
-
- std::string content_type;
- MultimodalType media_type;
- RETURN_IF_ERROR(_infer_media_type(file_input, content_type,
media_type));
-
- std::string media_url;
- RETURN_IF_ERROR(_resolve_media_url(file_input, ttl_seconds,
media_url));
+ std::vector<MultimodalInputItem> row_items;
+ if (!is_fused) {
+ MultimodalInputItem item;
+ RETURN_IF_ERROR(_parse_multimodal_item(*input_column, i,
ttl_seconds, item));
+ row_items.emplace_back(std::move(item));
+ } else {
+ const size_t array_idx = index_check_const(i, is_array_const);
+ const size_t start = array_idx == 0 ? 0 : (*offsets)[array_idx
- 1];
+ const size_t end = (*offsets)[array_idx];
+ if (start == end) {
+ return Status::InvalidArgument(
+ "Function EMBED fused multimodal array can not be
empty");
+ }
+ row_items.reserve(end - start);
+ for (size_t j = start; j < end; ++j) {
+ if (nested_nullable && nested_nullable->is_null_at(j)) {
+ return Status::InvalidArgument(
+ "Function EMBED fused multimodal array can not
contain NULL "
+ "element");
+ }
+ MultimodalInputItem item;
+ RETURN_IF_ERROR(
+ _parse_multimodal_item(*fused_json_column, j,
ttl_seconds, item));
+ row_items.emplace_back(std::move(item));
+ }
+ }
- if (!batch_media_urls.empty() &&
- batch_media_urls.size() >=
static_cast<size_t>(max_batch_size)) {
+ if (!batch_inputs.empty() &&
+ batch_inputs.size() >= static_cast<size_t>(max_batch_size)) {
Review Comment:
多模态的限制比较复杂,这里还是保持仅限制条数,上下文大小限制不动
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]