Name | llama-index-packs-dense-x-retrieval JSON |
Version |
0.4.0
JSON |
| download |
home_page | None |
Summary | llama-index packs dense_x_retrieval integration |
upload_time | 2024-11-18 01:32:51 |
maintainer | logan-markewich |
docs_url | None |
author | Your Name |
requires_python | <4.0,>=3.9 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Dense-X-Retrieval Pack
This LlamaPack creates a query engine that uses a `RecursiveRetriever` in llama-index to fetch nodes based on propoistions extracted from each node.
This follows the idea from the paper [Dense X Retrieval: What Retrieval Granularity Should We Use?](https://arxiv.org/abs/2312.06648).
From the paper, a proposition is described as:
```
Propositions are defined as atomic expressions within text, each encapsulating a distinct factoid and presented in a concise, self-contained natural language format.
```
We use the provided OpenAI prompt from their paper to generate propositions, which are then embedded and used to retrieve their parent node chunks.
**NOTE:** While the paper uses a fine-tuned model to extract propositions, it is unreleased at the time of writing. Currently, this pack uses the LLM to extract propositions, which can be expensive for large amounts of data.
## CLI Usage
You can download llamapacks directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:
```bash
llamaindex-cli download-llamapack DenseXRetrievalPack --download-dir ./dense_pack
```
You can then inspect the files at `./dense_pack` and use them as a template for your own project!
## Code Usage
You can download the pack to a the `./dense_pack` directory:
```python
from llama_index.core import SimpleDirectoryReader
from llama_index.core.llama_pack import download_llama_pack
# download and install dependencies
DenseXRetrievalPack = download_llama_pack(
"DenseXRetrievalPack", "./dense_pack"
)
documents = SimpleDirectoryReader("./data").load_data()
# uses the LLM to extract propositions from every document/node!
dense_pack = DenseXRetrievalPack(documents)
# for streaming
dense_pack = DenseXRetrievalPack(documents, streaming=True)
```
The `run()` function is a light wrapper around `query_engine.query()`.
```python
response = dense_pack.run("What can you tell me about LLMs?")
print(response)
```
for streaming:
The `run()` function is a light wrapper around `query_engine.query()`.
```python
stream_response = dense_pack.run("What can you tell me about LLMs?")
stream_response.print_response_stream()
```
See the [notebook on llama-hub](https://github.com/run-llama/llama-hub/blob/main/llama_hub/llama_packs/dense_x_retrieval/dense_x_retrieval.ipynb) for a full example.
Raw data
{
"_id": null,
"home_page": null,
"name": "llama-index-packs-dense-x-retrieval",
"maintainer": "logan-markewich",
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Your Name",
"author_email": "you@example.com",
"download_url": "https://files.pythonhosted.org/packages/b4/1f/569616eb99b960a56581099b9e235b2bd433a2e63397713a9cf8f55a749b/llama_index_packs_dense_x_retrieval-0.4.0.tar.gz",
"platform": null,
"description": "# Dense-X-Retrieval Pack\n\nThis LlamaPack creates a query engine that uses a `RecursiveRetriever` in llama-index to fetch nodes based on propoistions extracted from each node.\n\nThis follows the idea from the paper [Dense X Retrieval: What Retrieval Granularity Should We Use?](https://arxiv.org/abs/2312.06648).\n\nFrom the paper, a proposition is described as:\n\n```\nPropositions are defined as atomic expressions within text, each encapsulating a distinct factoid and presented in a concise, self-contained natural language format.\n```\n\nWe use the provided OpenAI prompt from their paper to generate propositions, which are then embedded and used to retrieve their parent node chunks.\n\n**NOTE:** While the paper uses a fine-tuned model to extract propositions, it is unreleased at the time of writing. Currently, this pack uses the LLM to extract propositions, which can be expensive for large amounts of data.\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 DenseXRetrievalPack --download-dir ./dense_pack\n```\n\nYou can then inspect the files at `./dense_pack` and use them as a template for your own project!\n\n## Code Usage\n\nYou can download the pack to a the `./dense_pack` directory:\n\n```python\nfrom llama_index.core import SimpleDirectoryReader\nfrom llama_index.core.llama_pack import download_llama_pack\n\n# download and install dependencies\nDenseXRetrievalPack = download_llama_pack(\n \"DenseXRetrievalPack\", \"./dense_pack\"\n)\n\ndocuments = SimpleDirectoryReader(\"./data\").load_data()\n\n# uses the LLM to extract propositions from every document/node!\ndense_pack = DenseXRetrievalPack(documents)\n\n# for streaming\ndense_pack = DenseXRetrievalPack(documents, streaming=True)\n```\n\nThe `run()` function is a light wrapper around `query_engine.query()`.\n\n```python\nresponse = dense_pack.run(\"What can you tell me about LLMs?\")\n\nprint(response)\n```\n\nfor streaming:\n\nThe `run()` function is a light wrapper around `query_engine.query()`.\n\n```python\nstream_response = dense_pack.run(\"What can you tell me about LLMs?\")\n\nstream_response.print_response_stream()\n```\n\nSee the [notebook on llama-hub](https://github.com/run-llama/llama-hub/blob/main/llama_hub/llama_packs/dense_x_retrieval/dense_x_retrieval.ipynb) for a full example.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "llama-index packs dense_x_retrieval integration",
"version": "0.4.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7ca6bce6305fc7ada26f27c79cbee603742c94262f01cd25d1d3b3c9fa4ca2c2",
"md5": "f56188fac133013e004536508a5d2e6c",
"sha256": "cab908d7d2102ba1c8257c470321e3d711811d4c83da5dec770ce2ce4870bc6f"
},
"downloads": -1,
"filename": "llama_index_packs_dense_x_retrieval-0.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f56188fac133013e004536508a5d2e6c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 5251,
"upload_time": "2024-11-18T01:32:49",
"upload_time_iso_8601": "2024-11-18T01:32:49.356689Z",
"url": "https://files.pythonhosted.org/packages/7c/a6/bce6305fc7ada26f27c79cbee603742c94262f01cd25d1d3b3c9fa4ca2c2/llama_index_packs_dense_x_retrieval-0.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b41f569616eb99b960a56581099b9e235b2bd433a2e63397713a9cf8f55a749b",
"md5": "68fcd4699b87c0e68022771c209025d1",
"sha256": "3211d29c7989a53c87ea04ddd0031347e9aac6d0e079ea02ffc553d6f4d778a3"
},
"downloads": -1,
"filename": "llama_index_packs_dense_x_retrieval-0.4.0.tar.gz",
"has_sig": false,
"md5_digest": "68fcd4699b87c0e68022771c209025d1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 4963,
"upload_time": "2024-11-18T01:32:51",
"upload_time_iso_8601": "2024-11-18T01:32:51.390209Z",
"url": "https://files.pythonhosted.org/packages/b4/1f/569616eb99b960a56581099b9e235b2bd433a2e63397713a9cf8f55a749b/llama_index_packs_dense_x_retrieval-0.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-18 01:32:51",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "llama-index-packs-dense-x-retrieval"
}