Find answers from the community

Updated 6 months ago

I am trying to build my RAG sytem with

At a glance
I am trying to build my RAG sytem with llamaindex , the task is i want to encode json file contain financial values into the database to enable the model to answer the question based on this information for example the following data
{
"Income": {
"400001 Revenues - Products": {
"Dec 2023": 9754683.44,
"Nov 2023": 33849669.09,
"Oct 2023": 24489340.36,
"Sep 2023": 27025747.55,
"Aug 2023": 27505599.78,
"Jul 2023": 29823205.97,
"Jun 2023": 23540372.56,
"May 2023": 40383899.47,
"Apr 2023": 24138790.16,
"Mar 2023": 24317821.88,
"Feb 2023": 21949108.25,
"Jan 2023": 18908510.7
},
"400002 Revenues - shipping services": {
"Dec 2023": 3590100,
"Nov 2023": 3681115,
"Oct 2023": 2421820,
"Sep 2023": 2657217.02,
"Aug 2023": 2919300,
"Jul 2023": 3347480,
"Jun 2023": 2889679,
"May 2023": 5214415,
"Apr 2023": 3065017,
"Mar 2023": 3253907,
"Feb 2023": 2627777.53,
"Jan 2023": 2582750
},}
but in bigger scale
Is there an suggestions to build this
L
k
7 comments
Seems like you should put your data into a SQL database and do text to SQL
what do you mean by text to SQL, please
Like, inserting your data into a database, and then prompting an LLM to write SQL to answer user questions
SQL queries make a lot more sense for this type of data
@Logan M
The solution you point to i think is better than extracting json file .
I am working on the exmple at the llama_inde x document text to sql
i want to use huggingface, gemini and multiple models other than openai.
but i am stuck at the following section :
Plain Text
py 
from llama_index.core.query_engine import NLSQLTableQueryEngine

query_engine = NLSQLTableQueryEngine(
    sql_database=sql_database, tables=["city_stats"], llm=llm
)
query_str = "Which city has the highest population?"
response = query_engine.query(query_str)

the problem is it for the embedding part it requries openaiEmbedding, what if i want to use sentence-transformers model!
You can use any embedding model πŸ™‚

pip install llama-index-embeddings-huggingface

Plain Text
from llama_index.embeddings.huggingface import HuggingFaceEmbedding

embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")

query_engine = NLSQLTableQueryEngine(
    sql_database=sql_database, 
    tables=["city_stats"], 
    llm=llm, 
    embed_model=embed_model
)
Add a reply
Sign up and join the conversation on Discord