Skip to main content

This is a temporary project while I wait for my langchain [pull-request](https://github.com/langchain-ai/langchain/pull/7278) to be validated.

Project description

We believe that hallucinations pose a major problem in the adoption of LLMs (Language Model Models). It is imperative to provide a simple and quick solution that allows the user to verify the coherence of the answers to the questions they are asked.

The conventional approach is to provide a list of URLs of the documents that helped in answering (see qa_with_source). However, this approach is unsatisfactory in several scenarios:

  1. The question is asked about a PDF of over 100 pages. Each fragment comes from the same document, but from where?
  2. Some documents do not have URLs (data retrieved from a database or other loaders).

It appears essential to have a means of retrieving all references to the actual data sources used by the model to answer the question.

This includes:

  • The precise list of documents used for the answer (the Documents, along with their metadata that may contain page numbers, slide numbers, or any other information allowing the retrieval of the fragment in the original document).
  • The excerpts of text used for the answer in each fragment. Even if a fragment is used, the LLM only utilizes a small portion to generate the answer. Access to these verbatim excerpts helps to quickly ascertain the validity of the answer.

We propose a two pipelines: qa_with_reference and qa_with_reference_and_verbatims for this purpose. It is a Question/Answer type pipeline that returns the list of documents used, and in the metadata, the list of verbatim excerpts exploited to produce the answer.

If the verbatim is not really from the original document, it's removed.

Install

pip install langchain-qa_with_reference

Sample notebook

See here

langchain Pull-request

This is a temporary project while I wait for my langchain pull-request to be validated.

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

langchain_qa_with_references-0.0.284.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file langchain_qa_with_references-0.0.284.tar.gz.

File metadata

File hashes

Hashes for langchain_qa_with_references-0.0.284.tar.gz
Algorithm Hash digest
SHA256 50dffc37146a4298e9692abdff24a537df784e68b8504d3501c8bb8c0ca53e3f
MD5 9bd64e7b79fe04900945e6b50ff7ee43
BLAKE2b-256 72c8fa0b9ebe9d671eb319c5f44d754d84d0f1e511ab647e50befe3460d2e900

See more details on using hashes here.

File details

Details for the file langchain_qa_with_references-0.0.284-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_qa_with_references-0.0.284-py3-none-any.whl
Algorithm Hash digest
SHA256 34f664b9d4bfa24da123f01b93a7cfe8864f936a41f7354f022bc1e4534f4020
MD5 1405eab262e2fe4f34df1e92655d411b
BLAKE2b-256 f7af4e90adeef6ff4bdd5d2ab044e92344727a8de502c28a4b3d6dd4aa92e489

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