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 .
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.
- Install all required libraries:
$ pip install -r requirements.txt
-
You should deploy the model or call the api. Then, specify the calling functions under
./llm.For example, you can specify the
urlandapi_keyon./llm/gpt.py. -
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
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.
python ./src/run_alcuna_complementary.py --model model_name
python ./src/run_alcuna_conflicting.py --model model_name
......
├── 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
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},
}