llama-index-packs-tables


Namellama-index-packs-tables JSON
Version 0.1.3 PyPI version JSON
download
home_page
Summaryllama-index packs tables integration
upload_time2024-02-22 01:42:46
maintainerDisiok
docs_urlNone
authorYour Name
requires_python>=3.8.1,<4.0
licenseMIT
keywords chain dataframe pandas table tables
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Tables Packs

## Chain-of-table Pack

This LlamaPack implements the [Chain-of-Table paper by Wang et al.](https://arxiv.org/pdf/2401.04398v1.pdf).

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_column`
- `f_select_row`
- `f_select_column`
- `f_group_by`
- `f_sort_by`

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 found [here](https://github.com/run-llama/llama-hub/blob/main/llama_hub/llama_packs/tables/chain_of_table/chain_of_table.ipynb).

### CLI Usage

You can download llamapacks directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:

```bash
llamaindex-cli download-llamapack ChainOfTablePack --download-dir ./chain_of_table_pack
```

You can then inspect the files at `./chain_of_table_pack` and use them as a template for your own project!

### Code Usage

We will show you how to import the agent from these files!

```python
from llama_index.core.llama_pack import download_llama_pack

# download and install dependencies
ChainOfTablePack = 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).

```python
from chain_of_table_pack.base import ChainOfTableQueryEngine, serialize_table

query_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.

```python
from llm_compiler_agent_pack.base import ChainOfTablePack

agent_pack = ChainOfTablePack(df, llm=llm, verbose=True)
```

The `run()` function is a light wrapper around `agent.chat()`.

```python
response = pack.run("Who won best Director in the 1972 Academy Awards?")
```

## Mix-Self-Consistency Pack

This LlamaPack implements the the mix self-consistency method proposed in ["Rethinking Tabular Data Understanding with Large Language Models"](https://arxiv.org/pdf/2312.16702v1.pdf) paper by Liu et al.

LLMs can reason over tabular data in 2 main ways:

1. textual reasoning via direct prompting
2. symbolic 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 found [here](https://github.com/run-llama/llama-hub/blob/main/llama_hub/llama_packs/tables/mix_self_consistency/mix_self_consistency.ipynb).

### CLI Usage

You can download llamapacks directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:

```bash
llamaindex-cli download-llamapack MixSelfConsistencyPack --download-dir ./mix_self_consistency_pack
```

You can then inspect the files at `./mix_self_consistency_pack` and use them as a template for your own project!

### Code Usage

We will show you how to import the module from these files!

```python
from llama_index.core.llama_pack import download_llama_pack

# download and install dependencies
MixSelfConsistencyPack = 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).

```python
from mix_self_consistency_pack.base import MixSelfConsistencyQueryEngine

query_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.

```python
from mix_self_consistency_pack.base import MixSelfConsistencyPack

pack = MixSelfConsistencyPack(df=df, llm=llm, verbose=True)
```

The `run()` function is a light wrapper around `query_engine.query()`.

```python
response = pack.run("Who won best Director in the 1972 Academy Awards?")
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "llama-index-packs-tables",
    "maintainer": "Disiok",
    "docs_url": null,
    "requires_python": ">=3.8.1,<4.0",
    "maintainer_email": "",
    "keywords": "chain,dataframe,pandas,table,tables",
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/40/74/00287671b757c23b24bef409323d4e4a2773528d9c8e75c8132f7caf45e3/llama_index_packs_tables-0.1.3.tar.gz",
    "platform": null,
    "description": "# Tables Packs\n\n## Chain-of-table Pack\n\nThis LlamaPack implements the [Chain-of-Table paper by Wang et al.](https://arxiv.org/pdf/2401.04398v1.pdf).\n\nChain-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).\n\nThere is a fixed set of tabular operations that are defined in the paper:\n\n- `f_add_column`\n- `f_select_row`\n- `f_select_column`\n- `f_group_by`\n- `f_sort_by`\n\nWe 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!\n\nA full notebook guide can be found [here](https://github.com/run-llama/llama-hub/blob/main/llama_hub/llama_packs/tables/chain_of_table/chain_of_table.ipynb).\n\n### CLI Usage\n\nYou can download llamapacks directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:\n\n```bash\nllamaindex-cli download-llamapack ChainOfTablePack --download-dir ./chain_of_table_pack\n```\n\nYou can then inspect the files at `./chain_of_table_pack` and use them as a template for your own project!\n\n### Code Usage\n\nWe will show you how to import the agent from these files!\n\n```python\nfrom llama_index.core.llama_pack import download_llama_pack\n\n# download and install dependencies\nChainOfTablePack = download_llama_pack(\n    \"ChainOfTablePack\", \"./chain_of_table_pack\"\n)\n```\n\nFrom 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\nhas been added to your system path).\n\n```python\nfrom chain_of_table_pack.base import ChainOfTableQueryEngine, serialize_table\n\nquery_engine = ChainOfTableQueryEngine(df, llm=llm, verbose=True)\nresponse = query_engine.query(\n    \"Who won best Director in the 1972 Academy Awards?\"\n)\n```\n\nYou can also use/initialize the pack directly.\n\n```python\nfrom llm_compiler_agent_pack.base import ChainOfTablePack\n\nagent_pack = ChainOfTablePack(df, llm=llm, verbose=True)\n```\n\nThe `run()` function is a light wrapper around `agent.chat()`.\n\n```python\nresponse = pack.run(\"Who won best Director in the 1972 Academy Awards?\")\n```\n\n## Mix-Self-Consistency Pack\n\nThis LlamaPack implements the the mix self-consistency method proposed in [\"Rethinking Tabular Data Understanding with Large Language Models\"](https://arxiv.org/pdf/2312.16702v1.pdf) paper by Liu et al.\n\nLLMs can reason over tabular data in 2 main ways:\n\n1. textual reasoning via direct prompting\n2. symbolic reasoning via program synthesis (e.g. python, SQL, etc)\n\nThe 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.\n\nWe 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!\n\nA full notebook guide can be found [here](https://github.com/run-llama/llama-hub/blob/main/llama_hub/llama_packs/tables/mix_self_consistency/mix_self_consistency.ipynb).\n\n### CLI Usage\n\nYou can download llamapacks directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:\n\n```bash\nllamaindex-cli download-llamapack MixSelfConsistencyPack --download-dir ./mix_self_consistency_pack\n```\n\nYou can then inspect the files at `./mix_self_consistency_pack` and use them as a template for your own project!\n\n### Code Usage\n\nWe will show you how to import the module from these files!\n\n```python\nfrom llama_index.core.llama_pack import download_llama_pack\n\n# download and install dependencies\nMixSelfConsistencyPack = download_llama_pack(\n    \"MixSelfConsistencyPack\", \"./mix_self_consistency_pack\"\n)\n```\n\nFrom 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\nhas been added to your system path).\n\n```python\nfrom mix_self_consistency_pack.base import MixSelfConsistencyQueryEngine\n\nquery_engine = MixSelfConsistencyQueryEngine(df=df, llm=llm, verbose=True)\nresponse = query_engine.query(\n    \"Who won best Director in the 1972 Academy Awards?\"\n)\n```\n\nYou can also use/initialize the pack directly.\n\n```python\nfrom mix_self_consistency_pack.base import MixSelfConsistencyPack\n\npack = MixSelfConsistencyPack(df=df, llm=llm, verbose=True)\n```\n\nThe `run()` function is a light wrapper around `query_engine.query()`.\n\n```python\nresponse = pack.run(\"Who won best Director in the 1972 Academy Awards?\")\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "llama-index packs tables integration",
    "version": "0.1.3",
    "project_urls": null,
    "split_keywords": [
        "chain",
        "dataframe",
        "pandas",
        "table",
        "tables"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "19b52c546831c5b19ae69a43727eaa2edcf50b35e088b64245c4f30abb2d8d1d",
                "md5": "93af0722b97caf35993067a353f6642a",
                "sha256": "0c15615954f5e6fa032b3259eb0b86fd10d43618ed3698648b45e57ece724d09"
            },
            "downloads": -1,
            "filename": "llama_index_packs_tables-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "93af0722b97caf35993067a353f6642a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<4.0",
            "size": 14541,
            "upload_time": "2024-02-22T01:42:45",
            "upload_time_iso_8601": "2024-02-22T01:42:45.127462Z",
            "url": "https://files.pythonhosted.org/packages/19/b5/2c546831c5b19ae69a43727eaa2edcf50b35e088b64245c4f30abb2d8d1d/llama_index_packs_tables-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "407400287671b757c23b24bef409323d4e4a2773528d9c8e75c8132f7caf45e3",
                "md5": "d900ab6340e04ea03b0ed8409d7ed448",
                "sha256": "53ccf2761b33a1a71800a3a5d7be082819903efc7ac2c8333d009b78ae79c8dd"
            },
            "downloads": -1,
            "filename": "llama_index_packs_tables-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "d900ab6340e04ea03b0ed8409d7ed448",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<4.0",
            "size": 14228,
            "upload_time": "2024-02-22T01:42:46",
            "upload_time_iso_8601": "2024-02-22T01:42:46.176250Z",
            "url": "https://files.pythonhosted.org/packages/40/74/00287671b757c23b24bef409323d4e4a2773528d9c8e75c8132f7caf45e3/llama_index_packs_tables-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-22 01:42:46",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-packs-tables"
}
        
Elapsed time: 0.19314s