Skip to content

About

Code and dataset for EchoQA, testing LLMs ability to leverage parametric knowledge when contextual knowledge is available.

Resources

Stars

12 stars

Watchers

1 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Understanding the Interplay between Parametric and Contextual Knowledge for Large Language Models

This repository contains the open-sourced official implementation and dataset of the paper

Understanding the Interplay between Parametric and Contextual Knowledge for Large Language Models .

Dataset: EchoQA

As described in our paper, we elicit parametric knowledge (pk) and construct contextual knowledge (ck) based on various relationship between ck and pk for various commonly used large language models (LLMs). Here, we release our data under ./echoqa_dataset w.r.t., LLMs and reasoning types. Please note that the datasets is itself dynamic (you can generate as much data as you like for each model). We release the data for future research.

Setup

  1. Install all required libraries:
$ pip install -r requirements.txt
  1. You should deploy the model or call the api. Then, specify the calling functions under ./llm.

    For example, you can specify the url and api_key on ./llm/gpt.py.

  2. Construct questions with various relations between pk and ck for your own model (Optional. You can directly use our data under ./echoqa_dataset)

You can elicit the parametric knowledge and construct the contextual knowledge for each type for any model by running the preprocessing code under each dataset in ./src. For example, to obtain the pk and ck for your model for MuSiQue, you can run:

$ python ./src/musique/musique_preprocess.py --model model_name

Evaluation

The logic of evaluating each model and each type of knowledge under our progressively-enforced instructions is by combining the constructed question and ck with the specific instruction and then testing the model.

run alcuna complementary

python ./src/run_alcuna_complementary.py --model model_name

run alcuna conflicting

python ./src/run_alcuna_conflicting.py --model model_name

......

File Trees

├── data  \\ Original datasets
├── echoqa_dataset  \\ our constructed dataset. In all json files, the 'question', 'ck', 'answer' conresponds to our constructed data, contextual knowledge and the answer. Others are info from the original datasets.
├── prompt \\ Our proposed Progressively-Enforced Reasoning Instructions
├── README.md
├── requirements.txt
├── src
│   ├── alcuna
│   ├── conflictQA
│   ├── musique
│   ├── openbookqa
└── utils

Citation

If you find this paper or code useful, please cite by:

@misc{cheng2024understandinginterplayparametriccontextual,
      title={Understanding the Interplay between Parametric and Contextual Knowledge for Large Language Models}, 
      author={Sitao Cheng and Liangming Pan and Xunjian Yin and Xinyi Wang and William Yang Wang},
      year={2024},
      eprint={2410.08414},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2410.08414}, 
}

About

Code and dataset for EchoQA, testing LLMs ability to leverage parametric knowledge when contextual knowledge is available.

Resources

Stars

12 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages