llama-index-packs-self-rag


Namellama-index-packs-self-rag JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
Summaryllama-index packs self rag integration
upload_time2024-11-17 22:42:56
maintainermmaatouk
docs_urlNone
authorYour Name
requires_python<4.0,>=3.9
licenseMIT
keywords llm self-rag smart-retreiver
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Simple self-RAG short form pack

This LlamaPack implements (\*in short form) the [self-RAG paper by Akari et al.](https://arxiv.org/pdf/2310.11511.pdf).

This paper presents a novel framework called Self-Reflective Retrieval-Augmented Generation (SELF-RAG). Which aims to enhance the quality and factuality of large language models (LLMs) by combining retrieval and self-reflection mechanisms.

The implementation is adapted from the author [implementation](https://github.com/AkariAsai/self-rag)
A full notebook guide can be found [here](https://github.com/run-llama/llama-hub/blob/main/llama_hub/llama_packs/self_rag/self_rag.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 SelfRAGPack --download-dir ./self_rag_pack
```

You can then inspect the files at `./self_rag_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!
The implementation uses llama-cpp, to download the relevant models (be sure to replace DIR_PATH)

```bash
pip3 install -q huggingface-hub
huggingface-cli download m4r1/selfrag_llama2_7b-GGUF selfrag_llama2_7b.q4_k_m.gguf --local-dir "<DIR_PATH>" --local-dir-use-symlinks False
```

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

# download and install dependencies
SelfRAGPack = download_llama_pack("SelfRAGPack", "./self_rag_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 self_rag_pack.base import SelfRAGQueryEngine

query_engine = SelfRAGQueryEngine(
    model_path=model_path, retriever=retriever, 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 SelfRAGPack

agent_pack = SelfRAGPack(
    model_path=model_path, retriever=retriever, 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?")
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llama-index-packs-self-rag",
    "maintainer": "mmaatouk",
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "llm, self-RAG, smart-retreiver",
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/60/16/d97913dca8f54439d1b61a2cfccc41d262d65a947322c8f1b1eae84124e6/llama_index_packs_self_rag-0.3.0.tar.gz",
    "platform": null,
    "description": "# Simple self-RAG short form pack\n\nThis LlamaPack implements (\\*in short form) the [self-RAG paper by Akari et al.](https://arxiv.org/pdf/2310.11511.pdf).\n\nThis paper presents a novel framework called Self-Reflective Retrieval-Augmented Generation (SELF-RAG). Which aims to enhance the quality and factuality of large language models (LLMs) by combining retrieval and self-reflection mechanisms.\n\nThe implementation is adapted from the author [implementation](https://github.com/AkariAsai/self-rag)\nA full notebook guide can be found [here](https://github.com/run-llama/llama-hub/blob/main/llama_hub/llama_packs/self_rag/self_rag.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 SelfRAGPack --download-dir ./self_rag_pack\n```\n\nYou can then inspect the files at `./self_rag_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!\nThe implementation uses llama-cpp, to download the relevant models (be sure to replace DIR_PATH)\n\n```bash\npip3 install -q huggingface-hub\nhuggingface-cli download m4r1/selfrag_llama2_7b-GGUF selfrag_llama2_7b.q4_k_m.gguf --local-dir \"<DIR_PATH>\" --local-dir-use-symlinks False\n```\n\n```python\nfrom llama_index.core.llama_pack import download_llama_pack\n\n# download and install dependencies\nSelfRAGPack = download_llama_pack(\"SelfRAGPack\", \"./self_rag_pack\")\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 self_rag_pack.base import SelfRAGQueryEngine\n\nquery_engine = SelfRAGQueryEngine(\n    model_path=model_path, retriever=retriever, verbose=True\n)\n\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 SelfRAGPack\n\nagent_pack = SelfRAGPack(\n    model_path=model_path, retriever=retriever, verbose=True\n)\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",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "llama-index packs self rag integration",
    "version": "0.3.0",
    "project_urls": null,
    "split_keywords": [
        "llm",
        " self-rag",
        " smart-retreiver"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "316b6d535a5b1c33f8b13a420db8de6c003e6b0d77b0e4e4692d5373762664b1",
                "md5": "a747d84460be0e40bc3be268f083b81b",
                "sha256": "97d8c547c9e3ecc7ef89055a438579cd02e406bc1ffe2ec87e0c62f8fcc7549f"
            },
            "downloads": -1,
            "filename": "llama_index_packs_self_rag-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a747d84460be0e40bc3be268f083b81b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 5381,
            "upload_time": "2024-11-17T22:42:54",
            "upload_time_iso_8601": "2024-11-17T22:42:54.464838Z",
            "url": "https://files.pythonhosted.org/packages/31/6b/6d535a5b1c33f8b13a420db8de6c003e6b0d77b0e4e4692d5373762664b1/llama_index_packs_self_rag-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6016d97913dca8f54439d1b61a2cfccc41d262d65a947322c8f1b1eae84124e6",
                "md5": "91b4a26b6ee840371f75c06a8090ef68",
                "sha256": "e83e4f49ae373a2f728650337ac4701ef83c4a00ba0b65a1a9648da97ffb31bb"
            },
            "downloads": -1,
            "filename": "llama_index_packs_self_rag-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "91b4a26b6ee840371f75c06a8090ef68",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 5173,
            "upload_time": "2024-11-17T22:42:56",
            "upload_time_iso_8601": "2024-11-17T22:42:56.005890Z",
            "url": "https://files.pythonhosted.org/packages/60/16/d97913dca8f54439d1b61a2cfccc41d262d65a947322c8f1b1eae84124e6/llama_index_packs_self_rag-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-17 22:42:56",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-packs-self-rag"
}
        
Elapsed time: 0.37226s