llama-index packs fuzzy_citation integration
Project description
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:
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:
from llama_index.core 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.
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 for a full example.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_index_packs_fuzzy_citation-0.4.1.tar.gz.
File metadata
- Download URL: llama_index_packs_fuzzy_citation-0.4.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ff32a155d8491306de2ea8685a93f8ee872477bd79219d0c4625268897ece01
|
|
| MD5 |
e8c48000fe7d0a94a80695c7e268f71d
|
|
| BLAKE2b-256 |
788965e1c39f0c3c7593891eb6241dcb75d84a79cc8dbac7e36eb4b5b136921a
|
File details
Details for the file llama_index_packs_fuzzy_citation-0.4.1-py3-none-any.whl.
File metadata
- Download URL: llama_index_packs_fuzzy_citation-0.4.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
636c90ec598230f5c6f22b825255bf5d3253f0d32f32e3b923ec9e96b63ea926
|
|
| MD5 |
8840af2439da67c92f5e5882e3cb66ee
|
|
| BLAKE2b-256 |
eeb6ad46c923360d4081aa2bbe80bbf924732997d5641bd05b2232057d9efccd
|