Skip to main content

llama-index packs searchain integration

Project description

LlamaIndex Packs Integration: Searchain

This LlamaPack implements a framework called SearChain, which implements the interaction between LLM and IR in the form of the global reasoning chain called Chain-of-Query (CoQ).

This follows the idea in the paper Search-in-the-Chain: Towards Accurate, Credible and Traceable Large Language Models for Knowledge-intensive Tasks.

Making content generated by large language models (LLMs) such as ChatGPT accurate, trustworthy, and traceable is critical, especially for knowledge-intensive tasks. Introducing information retrieval (IR) to provide LLM with external knowledge is likely to solve this problem, however, where and how to introduce IR is a big challenge. The SearChain framework generates a global reasoning chain called a Chain of Query (CoQ) for LLM, where each node contains an IR-oriented query and the answer to the query. Second, IR verifies the answer of each node of CoQ, it corrects the answer that is not consistent with the retrieved information when IR gives high confidence, which improves the credibility. Third, LLM can mark its missing knowledge in CoQ and IR can provide this knowledge to LLM. These three operations improve the accuracy of LLM for complex knowledge-intensive tasks in terms of reasoning ability and knowledge. This Pack implements the above🤗!

You can see its use case in the examples folder.

This implementation is adapted from the author's implementation. You can find the official code repository here.

Code Usage

First, you need to install SearChainpack using the following code,

from llama_index.core.llama_pack import download_llama_pack

download_llama_pack("SearChainPack", "./searchain_pack")

Next you can load and initialize a searchain object,

from searchain_pack.base import SearChainPack

searchain = SearChainPack(
    data_path="data",
    dprtokenizer_path="dpr_reader_multi",
    dprmodel_path="dpr_reader_multi",
    crossencoder_name_or_path="Quora_cross_encoder",
)

Relevant data can be found here. You can run searchain using the following method,

start_idx = 0
while not start_idx == -1:
    start_idx = execute(
        "/hotpotqa/hotpot_dev_fullwiki_v1_line.json", start_idx=start_idx
    )

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_packs_searchain-0.2.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_packs_searchain-0.2.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_packs_searchain-0.2.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_packs_searchain-0.2.1.tar.gz
Algorithm Hash digest
SHA256 94ee5dc8f9ab604173817631c85356c2298e7bfefb5184f4595c92dd84d9707d
MD5 4f8e7bec2968ceffd45c08d8aa726e8a
BLAKE2b-256 c8c88f6834e0d62d8ea573e0587363a2cd8e4be97c20f32ebb2325638fd9600f

See more details on using hashes here.

File details

Details for the file llama_index_packs_searchain-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_packs_searchain-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 89c836321082a54e773698bfd9accad79319e2946c31539e5de3106861bab4be
MD5 9aac8b6f13a75bf9e0e6b2ee0a8f39d0
BLAKE2b-256 d6c30a490144a34d64aa7e3403f629297d508fa4c9c3b7f3607092332bebb8e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page