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.1.0.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

Supported by

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