Find answers from the community

Updated 5 months ago

Hi guys

Hi guys
How can I make my Text to SQL pipeline more faster

Currently I am using the llama-index Text-to-SQL query pipeline following the guide here https://docs.llamaindex.ai/en/stable/examples/pipeline/query_pipeline_sql/

I retrieve only the SQL query then execute it myself. Then the result is pass to an llm that synthesis a response.

This takes about 7 seconds to run and return the result to a front end.

The bulk of the time were consumed on the text-to-sql pipeline and the response synthesizer.

Is there a tip on how to make the system more faster
L
o
5 comments
the speed is largely limited by the speed of the LLM
Use a faster LLM, or somehow condensing the inputs, are both valid options
Ok thanks I thought so too.

On another hand
How can I stream the output to give a better user experience.

I have tried a few options I read in the discussion as well the official docs but it doesn't work in my case.
Plain Text
synthesizer = get_response_synthesizer(llm=llm, response_mode="compact", streaming=True)
synth = get_response_synthesizer(streaming=True)
query_engine = SQLTableRetrieverQueryEngine(
    sql_database, obj_index.as_retriever(streaming=True, similarity_top_k = 3),
    llm=llm,
    #synthesize_response=False,
    response_synthesizer = synthesizer,
    #sql_only=True
)
response = query_engine.query("How many farmers do we have?")

for token in response.response_gen:
  print(token, end="", flush=True)

I get this output
Plain Text
AttributeError                            Traceback (most recent call last)
Cell In[24], line 1
----> 1 for token in response.response_gen:
      2   print(token, end="", flush=True)

AttributeError: 'Response' object has no attribute 'response_gen'


I tried another option from the official docs

Plain Text
response.print_response_stream()

Another error output:

Plain Text
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[25], line 1
----> 1 response.print_response_stream()

AttributeError: 'Response' object has no attribute 'print_response_stream'

I am using llama_index version
Plain Text
lama-index==0.10.50
I think its actually just SQLTableRetrieverQueryEngine(..., streaming=True) ?
Not sure, just reading source code lol
Add a reply
Sign up and join the conversation on Discord