PALCrossEncoder
- class hana_ai.vectorstore.pal_cross_encoder.PALCrossEncoder(connection_context)
PAL embeddings base class.
- Attributes:
fit_hdbprocedureReturns the generated hdbprocedure for fit.
predict_hdbprocedureReturns the generated hdbprocedure for predict.
Methods
add_attribute(attr_key, attr_val)Function to add attribute.
apply_with_hint(with_hint[, ...])Apply with hint.
consume_fit_hdbprocedure(proc_name[, ...])Return the generated consume hdbprocedure for fit.
consume_predict_hdbprocedure(proc_name[, ...])Return the generated consume hdbprocedure for predict.
create_apply_func(func_name, data[, key, ...])Create HANA TUDF SQL code.
Disable argument check.
Disable the bigint conversion.
HANA execution will be disabled and only SQL script will be generated.
Disable with hint.
Enable argument check.
Allows the conversion from bigint to double.
HANA execution will be enabled.
enable_no_inline([apply_to_anonymous_block])Enable no inline.
Enable parallel by parameter partitions.
enable_workload_class(workload_class_name)HANA WORKLOAD CLASS is applied for the statement execution.
Returns the execute_statement for training.
Get the generated result table names in fit function.
Get PAL fit parameters.
Get the model metrics.
Extract the specific function call of the SAP HANA PAL function from the sql code.
Parse sql lines containing the parameter definitions.
Returns the execute_statement for predicting.
Get the generated result table names in predict function.
Get PAL predict parameters.
Returns the execute_statement for scoring.
Get the score metrics.
Get the generated result table names in score function.
Get SAP HANA PAL score parameters.
Checks if the model can be saved.
load_model(model)Function to load the fitted model.
predict(data[, thread_number, batch_size, ...])Reranking with Cross Encoder
set_scale_out([route_to, no_route_to, ...])SAP HANA statement routing.
- predict(data, thread_number=None, batch_size=None, max_token_num=None, model_version=None, return_table=False)
Reranking with Cross Encoder
- add_attribute(attr_key, attr_val)
Function to add attribute.
- Parameters:
- attr_keystr
The key.
- attr_valstr
The value.
- apply_with_hint(with_hint, apply_to_anonymous_block=True)
Apply with hint.
- Parameters:
- with_hintstr
The hint clauses.
- apply_to_anonymous_blockbool, optional
If True, it will be applied to the anonymous block.
Defaults to True.
- consume_fit_hdbprocedure(proc_name, in_tables=None, out_tables=None)
Return the generated consume hdbprocedure for fit.
- Parameters:
- proc_namestr
The procedure name.
- in_tableslist, optional
The list of input table names.
- out_tableslist, optional
The list of output table names.
- consume_predict_hdbprocedure(proc_name, in_tables=None, out_tables=None)
Return the generated consume hdbprocedure for predict.
- Parameters:
- proc_namestr
The procedure name.
- in_tableslist, optional
The list of input table names.
- out_tableslist, optional
The list of output table names.
- create_apply_func(func_name, data, key=None, model=None, output_table_structure=None, execute=True, force=True)
Create HANA TUDF SQL code.
- Parameters:
- func_namestr
The function name of TUDF.
- dataDataFrame
The data to be predicted.
- keystr, optional
The key column name in the predict dataframe.
- modelDataFrame, optional
The model dataframe for prediction. If not specified, it will use model_.
- output_table_structuredict, optional
The return table structure.
- executebool, optional
Execute the creation SQL.
Defaults to True.
- forcebool, optional
If True, it will drop the existing TUDF.
- Returns:
- str
The generated TUDF SQL code.
- disable_arg_check()
Disable argument check.
- disable_convert_bigint()
Disable the bigint conversion.
Defaults to False.
- disable_hana_execution()
HANA execution will be disabled and only SQL script will be generated.
- disable_with_hint()
Disable with hint.
- enable_arg_check()
Enable argument check.
- enable_convert_bigint()
Allows the conversion from bigint to double.
Defaults to True.
- enable_hana_execution()
HANA execution will be enabled.
- enable_no_inline(apply_to_anonymous_block=True)
Enable no inline.
- Parameters:
- apply_to_anonymous_blockbool, optional
If True, it will be applied to the anonymous block.
Defaults to True.
- enable_parallel_by_parameter_partitions(apply_to_anonymous_block=False)
Enable parallel by parameter partitions.
- Parameters:
- apply_to_anonymous_blockbool, optional
If True, it will be applied to the anonymous block.
Defaults to False.
- enable_workload_class(workload_class_name)
HANA WORKLOAD CLASS is applied for the statement execution.
- Parameters:
- workload_class_namestr
The name of HANA WORKLOAD CLASS.
- property fit_hdbprocedure
Returns the generated hdbprocedure for fit.
- get_fit_execute_statement()
Returns the execute_statement for training.
- get_fit_output_table_names()
Get the generated result table names in fit function.
- Returns:
- list
List of table names.
- get_fit_parameters()
Get PAL fit parameters.
- Returns:
- list
List of tuples, where each tuple describes a parameter like (name, value, type)
- get_model_metrics()
Get the model metrics.
- Returns:
- DataFrame
The model metrics.
- get_pal_function()
Extract the specific function call of the SAP HANA PAL function from the sql code. Nevertheless it only detects the synonyms that have to be resolved afterwards.
- Returns:
- dict
The procedure name synonym: CALL "SYS_AFL.PAL_RANDOM_FORREST" (...) -> SYS_AFL.PAL_RANDOM_FORREST"
- get_parameters()
Parse sql lines containing the parameter definitions. In the sql code all the parameters are defined by four arrays, where the first one contains the parameter name, and one of the other three contains the value fitting to the parameter, while the other two are NULL. This format should be changed into a simple key-value based storage.
- Returns:
- dict
Dict of list of tuples, where each tuple describes a parameter like (name, value, type)
- get_predict_execute_statement()
Returns the execute_statement for predicting.
- get_predict_output_table_names()
Get the generated result table names in predict function.
- Returns:
- list
List of table names.
- get_predict_parameters()
Get PAL predict parameters.
- Returns:
- list
List of tuples, where each tuple describes a parameter like (name, value, type)
- get_score_execute_statement()
Returns the execute_statement for scoring.
- get_score_metrics()
Get the score metrics.
- Returns:
- DataFrame
The score metrics.
- get_score_output_table_names()
Get the generated result table names in score function.
- Returns:
- list
List of table names.
- get_score_parameters()
Get SAP HANA PAL score parameters.
- Returns:
- list
List of tuples, where each tuple describes a parameter like (name, value, type)
- is_fitted()
Checks if the model can be saved. To be overridden if the model is not stored in model_ attribute.
- Returns:
- bool
True if the model is ready to be saved.
- load_model(model)
Function to load the fitted model.
- Parameters:
- modelDataFrame
SAP HANA DataFrame for fitted model.
- property predict_hdbprocedure
Returns the generated hdbprocedure for predict.
- set_scale_out(route_to=None, no_route_to=None, route_by=None, route_by_cardinality=None, data_transfer_cost=None, route_optimization_level=None, workload_class=None, apply_to_anonymous_block=True)
SAP HANA statement routing.
- Parameters:
- route_tostr, optional
Routes the query to the specified volume ID or service type.
Defaults to None.
- no_route_tostr or a list of str, optional
Avoids query routing to a specified volume ID or service type.
Defaults to None.
- route_bystr, optional
Routes the query to the hosts related to the base table(s) of the specified projection view(s).
Defaults to None.
- route_by_cardinalitystr or a list of str, optional
Routes the query to the hosts related to the base table(s) of the specified projection view(s) with the highest cardinality from the input list.
- data_transfer_costint, optional
Guides the optimizer to use the weighting factor for the data transfer cost. The value 0 ignores the data transfer cost.
Defaults to None.
- route_optimization_level{'minimal', 'all'}, optional
Guides the optimizer to compile with
route_optimization_level'minimal' or to default toroute_optimization_level. If the 'minimal' compiled plan is cached, then it compiles once more using the default optimization level during the first execution. This hint is primarily used to shorten statement routing decisions during the initial compilation.- workload_classstr, optional
Routes the query via workload class.
route_tostatement hint has higher precedence thanworkload_classstatement hint.Defaults to None.
- apply_to_anonymous_blockbool, optional
If True it will be applied to the anonymous block.
Defaults to True.