You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current prompt_builder.cpp implementation in src/core/functions requires several optimizations and refactoring steps to improve efficiency and memory usage when processing DataChunks. Below are the main issues identified:
Function Naming and Parameter Handling:
RenameGetMaxLengthValues to GetMaxTokenLengthPerAttribute for better clarity.
Optimization: Update this function to find max token length directly over the DataChunk vectors, bypassing JSON-related overhead.
Concatenation and String Allocation:
In CombineValues, while += concatenation is currently manageable, the approach could be improved by allocating the full string size upfront to prevent reallocation overhead. This is especially relevant as the code is likely to be reused in scenarios with aggregate data handling.
Loop Optimization: Remove pop_back usage for trimming the last space after concatenation. Instead, concatenate up to N-1 times and handle the last item separately, reducing unnecessary operations.
DataChunk to JSON Transformation:
Avoid mapping entire DataChunks to JSON before chunking. Although JSON is currently used as a temporary solution, the goal is to remove this dependency.
For efficient memory handling, calculate and set the maximum number of tuples per LLM request based on token size limits, allocating memory in advance on the stack.
Prompt Rendering and Inja Removal:
In the long term, replace Inja for prompt rendering. Implement a custom rendering solution directly with DataChunks to avoid intermediary JSON representations and reduce memory usage.
The current
prompt_builder.cpp
implementation insrc/core/functions
requires several optimizations and refactoring steps to improve efficiency and memory usage when processing DataChunks. Below are the main issues identified:Function Naming and Parameter Handling:
GetMaxLengthValues
toGetMaxTokenLengthPerAttribute
for better clarity.Concatenation and String Allocation:
CombineValues
, while+=
concatenation is currently manageable, the approach could be improved by allocating the full string size upfront to prevent reallocation overhead. This is especially relevant as the code is likely to be reused in scenarios with aggregate data handling.pop_back
usage for trimming the last space after concatenation. Instead, concatenate up toN-1
times and handle the last item separately, reducing unnecessary operations.DataChunk to JSON Transformation:
Prompt Rendering and Inja Removal:
The text was updated successfully, but these errors were encountered: