Skip to main content
Through two methods, ToolCall and PipelineCall, you can directly call UltraRAG’s capabilities in your local code.

ToolCall

When you only need a specific function of UltraRAG (such as data loading, encoding, retrieval, etc.) and do not need to run the full Pipeline, you can call it as a function via ToolCall.
ToolCall requires using initialize to specify the Servers to be enabled first.
server_root recommends using an absolute path, e.g., /home/user/project/UltraRAG/servers.
script/api_usage_example.py
from ultrarag.api import initialize, ToolCall


initialize(["benchmark"], server_root="servers") 

benchmark_param_dict = {
    "key_map":{
      "gt_ls": "golden_answers",
      "q_ls": "question"
    },
    "limit": -1,
    "seed": 42,
    "name": "nq",
    "path": "data/sample_nq_10.jsonl",
    
}
benchmark = ToolCall.benchmark.get_data(benchmark_param_dict)

The usage method is consistent with ordinary Python functions; just pass in the corresponding parameters as needed.
script/api_usage_example.py
from ultrarag.api import initialize, ToolCall


initialize(["benchmark", "retriever"], server_root="servers") 

benchmark_param_dict = {
    "key_map":{
      "gt_ls": "golden_answers",
      "q_ls": "question"
    },
    "limit": -1,
    "seed": 42,
    "name": "nq",
    "path": "data/sample_nq_10.jsonl",
    
}
benchmark = ToolCall.benchmark.get_data(benchmark_param_dict)

query_list = benchmark['q_ls']


retriever_init_param_dict = {
    "model_name_or_path": "Qwen/Qwen3-Embedding-0.6B",
}

ToolCall.retriever.retriever_init(
    **retriever_init_param_dict
)

result = ToolCall.retriever.retriever_search(
    query_list=query_list,
    top_k=5,
)

retrieve_passages = result['ret_psg']

Only pass the parameters you wish to modify; other parameters will be automatically completed from the Server’s default parameter file.

PipelineCall

If you wish to run an entire UltraRAG Pipeline directly locally and obtain the execution results of all steps, you can use PipelineCall.
You need to first generate the pipeline_parameter.yaml and parameter files for the corresponding Pipeline via UltraRAG’s build function.
script/api_usage_example.py
from ultrarag.api import PipelineCall

result = PipelineCall(
    pipeline_file="examples/rag_deploy.yaml",
    parameter_file="examples/parameter/rag_deploy_parameter.yaml",
)

final_step_result = result['final_result']
all_steps_result = result['all_results']

final_result is the running result of the last step of the Pipeline, and all_steps_result contains the running results of all steps.