llama-index-packs-self-rag


Namellama-index-packs-self-rag JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
Summaryllama-index packs self rag integration
upload_time2024-09-25 18:29:23
maintainermmaatouk
docs_urlNone
authorYour Name
requires_python<4.0,>=3.8.1
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.8.1",
    "maintainer_email": null,
    "keywords": "llm, self-RAG, smart-retreiver",
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/48/db/fbfeecc61920d282e16c01b3afe2da7fee21eb91acfec857bbec7a250191/llama_index_packs_self_rag-0.2.1.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.2.1",
    "project_urls": null,
    "split_keywords": [
        "llm",
        " self-rag",
        " smart-retreiver"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8e9689ca4f57d50e7cea89c3ac36b81a3ff6d07d9d634dffe0d69da9ade04d5d",
                "md5": "bcf693c8e3c205df7b52f387851ddf6f",
                "sha256": "585f3659961f5cfbbe357d550af8306fefa22b873cadce47b1d9e6c8e26f9965"
            },
            "downloads": -1,
            "filename": "llama_index_packs_self_rag-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bcf693c8e3c205df7b52f387851ddf6f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8.1",
            "size": 5385,
            "upload_time": "2024-09-25T18:29:22",
            "upload_time_iso_8601": "2024-09-25T18:29:22.635001Z",
            "url": "https://files.pythonhosted.org/packages/8e/96/89ca4f57d50e7cea89c3ac36b81a3ff6d07d9d634dffe0d69da9ade04d5d/llama_index_packs_self_rag-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "48dbfbfeecc61920d282e16c01b3afe2da7fee21eb91acfec857bbec7a250191",
                "md5": "74cf064aae4925236522728758df0df7",
                "sha256": "04ce24aa4edf0ea64edbec45f3ef122f8ff32ac04318d80ac8713d3901157c8e"
            },
            "downloads": -1,
            "filename": "llama_index_packs_self_rag-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "74cf064aae4925236522728758df0df7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8.1",
            "size": 5119,
            "upload_time": "2024-09-25T18:29:23",
            "upload_time_iso_8601": "2024-09-25T18:29:23.901069Z",
            "url": "https://files.pythonhosted.org/packages/48/db/fbfeecc61920d282e16c01b3afe2da7fee21eb91acfec857bbec7a250191/llama_index_packs_self_rag-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-25 18:29:23",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-packs-self-rag"
}
        
Elapsed time: 0.31732s