Package: llama-index-packs-tables
Tables PacksChain-of-table PackThis LlamaPack implements theChain-of-Table paper by Wang et al..Chain-of-Table proposes the following: given a user query over tabular data, plan out a sequence of tabular operations over the table to retrieve the right information in order to satisfy the user query. The updated table is explicitly used/modified throughout the intermediate chain (unlike chain-of-thought/ReAct which uses generic thoughts).There is a fixed set of tabular operations that are defined in the paper:f_add_columnf_select_rowf_select_columnf_group_byf_sort_byWe implemented the paper based on the prompts described in the paper, and adapted it to get it working. That said, this is marked as beta, so there may still be kinks to work through. Do you have suggestions / contributions on how to improve the robustness? Let us know!A full notebook guide can be foundhere.CLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackChainOfTablePack--download-dir./chain_of_table_packYou can then inspect the files at./chain_of_table_packand use them as a template for your own project!Code UsageWe will show you how to import the agent from these files!fromllama_index.core.llama_packimportdownload_llama_pack# download and install dependenciesChainOfTablePack=download_llama_pack("ChainOfTablePack","./chain_of_table_pack")From here, you can use the pack. You can import the relevant modules from the download folder (in the example below we assume it's a relative import or the directory
has been added to your system path).fromchain_of_table_pack.baseimportChainOfTableQueryEngine,serialize_tablequery_engine=ChainOfTableQueryEngine(df,llm=llm,verbose=True)response=query_engine.query("Who won best Director in the 1972 Academy Awards?")You can also use/initialize the pack directly.fromllm_compiler_agent_pack.baseimportChainOfTablePackagent_pack=ChainOfTablePack(df,llm=llm,verbose=True)Therun()function is a light wrapper aroundagent.chat().response=pack.run("Who won best Director in the 1972 Academy Awards?")Mix-Self-Consistency PackThis LlamaPack implements the the mix self-consistency method proposed in"Rethinking Tabular Data Understanding with Large Language Models"paper by Liu et al.LLMs can reason over tabular data in 2 main ways:textual reasoning via direct promptingsymbolic reasoning via program synthesis (e.g. python, SQL, etc)The key insight of the paper is that different reasoning pathways work well in different tasks. By aggregating results from both with a self-consistency mechanism (i.e. majority voting), it achieves SoTA performance.We implemented the paper based on the prompts described in the paper, and adapted it to get it working. That said, this is marked as beta, so there may still be kinks to work through. Do you have suggestions / contributions on how to improve the robustness? Let us know!A full notebook guide can be foundhere.CLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackMixSelfConsistencyPack--download-dir./mix_self_consistency_packYou can then inspect the files at./mix_self_consistency_packand use them as a template for your own project!Code UsageWe will show you how to import the module from these files!fromllama_index.core.llama_packimportdownload_llama_pack# download and install dependenciesMixSelfConsistencyPack=download_llama_pack("MixSelfConsistencyPack","./mix_self_consistency_pack")From here, you can use the pack. You can import the relevant modules from the download folder (in the example below we assume it's a relative import or the directory
has been added to your system path).frommix_self_consistency_pack.baseimportMixSelfConsistencyQueryEnginequery_engine=MixSelfConsistencyQueryEngine(df=df,llm=llm,verbose=True)response=query_engine.query("Who won best Director in the 1972 Academy Awards?")You can also use/initialize the pack directly.frommix_self_consistency_pack.baseimportMixSelfConsistencyPackpack=MixSelfConsistencyPack(df=df,llm=llm,verbose=True)Therun()function is a light wrapper aroundquery_engine.query().response=pack.run("Who won best Director in the 1972 Academy Awards?")