Name | llama-index-packs-fuzzy-citation JSON |
Version |
0.1.0
JSON |
| download |
home_page | |
Summary | llama-index packs fuzzy_citation integration |
upload_time | 2024-02-10 23:14:43 |
maintainer | |
docs_url | None |
author | Your Name |
requires_python | >=3.8.1,<3.12 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Fuzzy Citation Query Engine Pack
Creates and runs a `CustomQueryEngine` -- `FuzzCitationQueryEngine` -- which post-processes response objects to identify source sentences using fuzzy matching.
The identified sentences are available in the `response.metadata` dictionary, containing a mapping of `(response_sentence, source_chunk)` -> `{"start_char_idx": idx, "end_char_idx": idx, "node" node}`. The start/end idxs represent the character indexes in the node text that the source chunk comes from.
The fuzzy matching uses `fuzz.ratio()` to compare sentences. The default threshold score is 50.
## CLI Usage
You can download llamapacks directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:
```bash
llamaindex-cli download-llamapack FuzzyCitationEnginePack --download-dir ./fuzzy_citation_pack
```
You can then inspect the files at `./fuzzy_citation_pack` and use them as a template for your own project!
## Code Usage
You can download the pack to a the `./fuzzy_citation_pack` directory:
```python
from llama_index import Document, VectorStoreIndex
from llama_index.core.llama_pack import download_llama_pack
# download and install dependencies
FuzzyCitationEnginePack = download_llama_pack(
"FuzzyCitationEnginePack", "./fuzzy_citation_pack"
)
index = VectorStoreIndex.from_documents([Document.example()])
query_engine = index.as_query_engine()
fuzzy_engine = FuzzyCitationEnginePack(query_engine, threshold=50)
```
The `run()` function is a light wrapper around `query_engine.query()`. The response will have metadata attached to it indicating the fuzzy citations.
```python
response = fuzzy_engine.run("What can you tell me about LLMs?")
# print source sentences
print(response.metadata.keys())
# print full source sentence info
print(response.metadata)
```
See the [notebook on llama-hub](https://github.com/run-llama/llama-hub/blob/main/llama_hub/llama_packs/fuzzy_citation/fuzzy_citation_example.ipynb) for a full example.
Raw data
{
"_id": null,
"home_page": "",
"name": "llama-index-packs-fuzzy-citation",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8.1,<3.12",
"maintainer_email": "",
"keywords": "",
"author": "Your Name",
"author_email": "you@example.com",
"download_url": "https://files.pythonhosted.org/packages/30/a8/0e802896455c9992d62a21e9155c7bd582269a845bfcfb0d7162f480c517/llama_index_packs_fuzzy_citation-0.1.0.tar.gz",
"platform": null,
"description": "# Fuzzy Citation Query Engine Pack\n\nCreates and runs a `CustomQueryEngine` -- `FuzzCitationQueryEngine` -- which post-processes response objects to identify source sentences using fuzzy matching.\n\nThe identified sentences are available in the `response.metadata` dictionary, containing a mapping of `(response_sentence, source_chunk)` -> `{\"start_char_idx\": idx, \"end_char_idx\": idx, \"node\" node}`. The start/end idxs represent the character indexes in the node text that the source chunk comes from.\n\nThe fuzzy matching uses `fuzz.ratio()` to compare sentences. The default threshold score is 50.\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 FuzzyCitationEnginePack --download-dir ./fuzzy_citation_pack\n```\n\nYou can then inspect the files at `./fuzzy_citation_pack` and use them as a template for your own project!\n\n## Code Usage\n\nYou can download the pack to a the `./fuzzy_citation_pack` directory:\n\n```python\nfrom llama_index import Document, VectorStoreIndex\nfrom llama_index.core.llama_pack import download_llama_pack\n\n# download and install dependencies\nFuzzyCitationEnginePack = download_llama_pack(\n \"FuzzyCitationEnginePack\", \"./fuzzy_citation_pack\"\n)\n\nindex = VectorStoreIndex.from_documents([Document.example()])\nquery_engine = index.as_query_engine()\n\nfuzzy_engine = FuzzyCitationEnginePack(query_engine, threshold=50)\n```\n\nThe `run()` function is a light wrapper around `query_engine.query()`. The response will have metadata attached to it indicating the fuzzy citations.\n\n```python\nresponse = fuzzy_engine.run(\"What can you tell me about LLMs?\")\n\n# print source sentences\nprint(response.metadata.keys())\n\n# print full source sentence info\nprint(response.metadata)\n```\n\nSee the [notebook on llama-hub](https://github.com/run-llama/llama-hub/blob/main/llama_hub/llama_packs/fuzzy_citation/fuzzy_citation_example.ipynb) for a full example.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "llama-index packs fuzzy_citation integration",
"version": "0.1.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d06b403d076b8e8bf3566ced133e5f3324a2e6333b38f1eff01f6e3b15df5975",
"md5": "0c770194717a6e63110c2cde1f63da83",
"sha256": "22867a10d329d6d2afb5dd649e033165d4ced2edfef962fc6f71437226f2b7c7"
},
"downloads": -1,
"filename": "llama_index_packs_fuzzy_citation-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0c770194717a6e63110c2cde1f63da83",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8.1,<3.12",
"size": 4173,
"upload_time": "2024-02-10T23:14:42",
"upload_time_iso_8601": "2024-02-10T23:14:42.895239Z",
"url": "https://files.pythonhosted.org/packages/d0/6b/403d076b8e8bf3566ced133e5f3324a2e6333b38f1eff01f6e3b15df5975/llama_index_packs_fuzzy_citation-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "30a80e802896455c9992d62a21e9155c7bd582269a845bfcfb0d7162f480c517",
"md5": "f7e662c7eab5f4b87897e94c39ae0e0c",
"sha256": "e6fd5a50e50037cb49db7c3e9c882499b3667953d18a87a7bc79880238aea43b"
},
"downloads": -1,
"filename": "llama_index_packs_fuzzy_citation-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "f7e662c7eab5f4b87897e94c39ae0e0c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.1,<3.12",
"size": 3609,
"upload_time": "2024-02-10T23:14:43",
"upload_time_iso_8601": "2024-02-10T23:14:43.844926Z",
"url": "https://files.pythonhosted.org/packages/30/a8/0e802896455c9992d62a21e9155c7bd582269a845bfcfb0d7162f480c517/llama_index_packs_fuzzy_citation-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-10 23:14:43",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "llama-index-packs-fuzzy-citation"
}