llama-index-packs-searchain


Namellama-index-packs-searchain JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
Summaryllama-index packs searchain integration
upload_time2024-08-22 17:51:48
maintainerNone
docs_urlNone
authorYour Name
requires_python<4.0,>=3.8.1
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LlamaIndex Packs Integration: Searchain

This LlamaPack implements a framework called SearChain, which implements the interaction between LLM and IR in the form of the global reasoning chain called Chain-of-Query (CoQ).

This follows the idea in the paper [Search-in-the-Chain: Towards Accurate, Credible and Traceable Large Language Models for Knowledge-intensive Tasks](https://arxiv.org/abs/2304.14732).

Making content generated by large language models (LLMs) such as ChatGPT accurate, trustworthy, and traceable is critical, especially for knowledge-intensive tasks. Introducing information retrieval (IR) to provide LLM with external knowledge is likely to solve this problem, however, where and how to introduce IR is a big challenge. The SearChain framework generates a global reasoning chain called a Chain of Query (CoQ) for LLM, where each node contains an IR-oriented query and the answer to the query. Second, IR verifies the answer of each node of CoQ, it corrects the answer that is not consistent with the retrieved information when IR gives high confidence, which improves the credibility. Third, LLM can mark its missing knowledge in CoQ and IR can provide this knowledge to LLM. These three operations improve the accuracy of LLM for complex knowledge-intensive tasks in terms of reasoning ability and knowledge. This Pack implements the above🤗!

You can see its use case in the examples folder.

This implementation is adapted from the author's implementation. You can find the official code repository [here](https://github.com/xsc1234/Search-in-the-Chain).

## Code Usage

First, you need to install SearChainpack using the following code,

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

download_llama_pack("SearChainPack", "./searchain_pack")
```

Next you can load and initialize a searchain object,

```python
from searchain_pack.base import SearChainPack

searchain = SearChainPack(
    data_path="data",
    dprtokenizer_path="dpr_reader_multi",
    dprmodel_path="dpr_reader_multi",
    crossencoder_name_or_path="Quora_cross_encoder",
)
```

Relevant data can be found [here](https://www.kaggle.com/datasets/anastasiajia/searchain/data). You can run searchain using the following method,

```python
start_idx = 0
while not start_idx == -1:
    start_idx = execute(
        "/hotpotqa/hotpot_dev_fullwiki_v1_line.json", start_idx=start_idx
    )
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llama-index-packs-searchain",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8.1",
    "maintainer_email": null,
    "keywords": null,
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/1c/d5/e8f73b146b23b251a233ff898c77e5acbf144db85e6cb11d8b669b8bdeb4/llama_index_packs_searchain-0.2.0.tar.gz",
    "platform": null,
    "description": "# LlamaIndex Packs Integration: Searchain\n\nThis LlamaPack implements a framework called SearChain, which implements the interaction between LLM and IR in the form of the global reasoning chain called Chain-of-Query (CoQ).\n\nThis follows the idea in the paper [Search-in-the-Chain: Towards Accurate, Credible and Traceable Large Language Models for Knowledge-intensive Tasks](https://arxiv.org/abs/2304.14732).\n\nMaking content generated by large language models (LLMs) such as ChatGPT accurate, trustworthy, and traceable is critical, especially for knowledge-intensive tasks. Introducing information retrieval (IR) to provide LLM with external knowledge is likely to solve this problem, however, where and how to introduce IR is a big challenge. The SearChain framework generates a global reasoning chain called a Chain of Query (CoQ) for LLM, where each node contains an IR-oriented query and the answer to the query. Second, IR verifies the answer of each node of CoQ, it corrects the answer that is not consistent with the retrieved information when IR gives high confidence, which improves the credibility. Third, LLM can mark its missing knowledge in CoQ and IR can provide this knowledge to LLM. These three operations improve the accuracy of LLM for complex knowledge-intensive tasks in terms of reasoning ability and knowledge. This Pack implements the above\ud83e\udd17!\n\nYou can see its use case in the examples folder.\n\nThis implementation is adapted from the author's implementation. You can find the official code repository [here](https://github.com/xsc1234/Search-in-the-Chain).\n\n## Code Usage\n\nFirst, you need to install SearChainpack using the following code,\n\n```python\nfrom llama_index.core.llama_pack import download_llama_pack\n\ndownload_llama_pack(\"SearChainPack\", \"./searchain_pack\")\n```\n\nNext you can load and initialize a searchain object,\n\n```python\nfrom searchain_pack.base import SearChainPack\n\nsearchain = SearChainPack(\n    data_path=\"data\",\n    dprtokenizer_path=\"dpr_reader_multi\",\n    dprmodel_path=\"dpr_reader_multi\",\n    crossencoder_name_or_path=\"Quora_cross_encoder\",\n)\n```\n\nRelevant data can be found [here](https://www.kaggle.com/datasets/anastasiajia/searchain/data). You can run searchain using the following method,\n\n```python\nstart_idx = 0\nwhile not start_idx == -1:\n    start_idx = execute(\n        \"/hotpotqa/hotpot_dev_fullwiki_v1_line.json\", start_idx=start_idx\n    )\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "llama-index packs searchain integration",
    "version": "0.2.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d30468b7a9aef20382913f82e313d0f662db188ce86a60ccd0c2e4238058b2da",
                "md5": "0683e604293d1e936d4bb86654332526",
                "sha256": "3e519cc3ce731debcd7ebeaaa704216100595752106c47796d141cf3d537399a"
            },
            "downloads": -1,
            "filename": "llama_index_packs_searchain-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0683e604293d1e936d4bb86654332526",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8.1",
            "size": 5800,
            "upload_time": "2024-08-22T17:51:46",
            "upload_time_iso_8601": "2024-08-22T17:51:46.273187Z",
            "url": "https://files.pythonhosted.org/packages/d3/04/68b7a9aef20382913f82e313d0f662db188ce86a60ccd0c2e4238058b2da/llama_index_packs_searchain-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1cd5e8f73b146b23b251a233ff898c77e5acbf144db85e6cb11d8b669b8bdeb4",
                "md5": "67b3a77b49b7bbb22335eb14d824b743",
                "sha256": "fb2a1cf05d03c5ad14a77986437a72c13d37bc35503bad508e6c2b3e81db8dbc"
            },
            "downloads": -1,
            "filename": "llama_index_packs_searchain-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "67b3a77b49b7bbb22335eb14d824b743",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8.1",
            "size": 5488,
            "upload_time": "2024-08-22T17:51:48",
            "upload_time_iso_8601": "2024-08-22T17:51:48.596742Z",
            "url": "https://files.pythonhosted.org/packages/1c/d5/e8f73b146b23b251a233ff898c77e5acbf144db85e6cb11d8b669b8bdeb4/llama_index_packs_searchain-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-22 17:51:48",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-packs-searchain"
}
        
Elapsed time: 0.36129s