From d816776eaa1ca5df8d59c6ffcbe9b0a081cddc03 Mon Sep 17 00:00:00 2001 From: Miao Xiong Date: Sat, 23 Mar 2024 18:44:50 +0800 Subject: [PATCH 1/4] anonymous update --- README.md | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/README.md b/README.md index 465972a..6c5fcd2 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,7 @@ Activation_Decoding: Decoding by sharpness inside Large Language Models ![](figure/ad.png) -This is the code implementation of the paper: [In-Context Sharpness as Alerts: An Inner Representation Perspective for Hallucination Mitigation -](https://arxiv.org/abs/2403.01548) +This is the code implementation of the paper: In-Context Sharpness as Alerts: An Inner Representation Perspective for Hallucination Mitigation We discover a pattern associated with hallucinations: correct generations tend to have *sharper* context activations in the hidden states of the in-context tokens, compared to that of the incorrect generations. Leveraging this signal, we propose an entropy-based metric to quantify the "*sharpness* " among the in-context hidden states and incorporate it into the decoding process, i.e, use the entropy value to adjust the next token prediction distribution to improve the factuality and overall quality of the generated text. @@ -94,20 +93,4 @@ bash run_tqa.sh # refer to this script for more details - Dola: https://github.com/voidism/DoLa -## Citation - -Please cite our paper if it's helpful to your work! - -```bibtex -@inproceedings{ -chen2024incontext, -title={In-Context Sharpness as Alerts: An Inner Representation Perspective for Hallucination Mitigation}, -author={Chen, Shiqi and Xiong, Miao and Liu, Junteng and Wu, Zhengxuan and Xiao, Teng and Gao, Siyang and He, Junxian}, -booktitle={Arxiv}, -year={2024}, -url={https://arxiv.org/abs/2403.01548} -} - -``` - From b51aa18374a282c4970e6a795660e9a9ac79b02f Mon Sep 17 00:00:00 2001 From: Miao Xiong Date: Mon, 25 Mar 2024 11:30:40 +0800 Subject: [PATCH 2/4] Update environment.yml --- environment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index db7b6df..bbb8d37 100644 --- a/environment.yml +++ b/environment.yml @@ -1,4 +1,4 @@ -name: shiqi +name: nickname channels: - anaconda - defaults @@ -125,4 +125,4 @@ dependencies: - xmltodict==0.13.0 - xxhash==3.2.0 - yarl==1.8.2 -prefix: /home/adseadmin/miniconda3/envs/shiqi +prefix: /home/adseadmin/miniconda3/envs/nickname From 1274e4d69353e04b3dd2596a88e14e33fd84fbf5 Mon Sep 17 00:00:00 2001 From: Miao Xiong Date: Mon, 25 Mar 2024 11:34:10 +0800 Subject: [PATCH 3/4] delete unuse conda env yml --- environment.yml | 128 ------------------------------------------------ 1 file changed, 128 deletions(-) delete mode 100644 environment.yml diff --git a/environment.yml b/environment.yml deleted file mode 100644 index bbb8d37..0000000 --- a/environment.yml +++ /dev/null @@ -1,128 +0,0 @@ -name: nickname -channels: - - anaconda - - defaults -dependencies: - - _libgcc_mutex=0.1=main - - _openmp_mutex=5.1=1_gnu - - blas=1.0=mkl - - brotlipy=0.7.0=py37h27cfd23_1003 - - ca-certificates=2023.01.10=h06a4308_0 - - certifi=2022.12.7=py37h06a4308_0 - - cffi=1.15.1=py37h5eee18b_3 - - charset-normalizer=2.0.4=pyhd3eb1b0_0 - - cryptography=39.0.1=py37h9ce1e76_0 - - filelock=3.9.0=py37h06a4308_0 - - flit-core=3.6.0=pyhd3eb1b0_0 - - future=0.18.3=py37h06a4308_0 - - idna=3.4=py37h06a4308_0 - - importlib-metadata=4.11.3=py37h06a4308_0 - - intel-openmp=2021.4.0=h06a4308_3561 - - ld_impl_linux-64=2.38=h1181459_1 - - libffi=3.4.2=h6a678d5_6 - - libgcc-ng=11.2.0=h1234567_1 - - libgomp=11.2.0=h1234567_1 - - libprotobuf=3.20.3=he621ea3_0 - - libstdcxx-ng=11.2.0=h1234567_1 - - mkl=2021.4.0=h06a4308_640 - - mkl-service=2.4.0=py37h7f8727e_0 - - mkl_fft=1.3.1=py37hd3c417c_0 - - mkl_random=1.2.2=py37h51133e4_0 - - ncurses=6.4=h6a678d5_0 - - ninja=1.10.2=h06a4308_5 - - ninja-base=1.10.2=hd09550d_5 - - numpy=1.21.5=py37h6c91a56_3 - - numpy-base=1.21.5=py37ha15fc14_3 - - openssl=1.1.1s=h7f8727e_0 - - packaging=22.0=py37h06a4308_0 - - pip - - pycparser=2.21=pyhd3eb1b0_0 - - pyopenssl=23.0.0=py37h06a4308_0 - - pysocks=1.7.1=py37_1 - - python=3.8 - - pyyaml=6.0=py37h5eee18b_1 - - readline=8.2=h5eee18b_0 - - regex=2022.7.9=py37h5eee18b_0 - - requests=2.28.1=py37h06a4308_0 - - setuptools=65.6.3=py37h06a4308_0 - - six=1.16.0=pyhd3eb1b0_1 - - sqlite=3.41.1=h5eee18b_0 - - tk=8.6.12=h1ccaba5_0 - - tqdm=4.64.1=py37h06a4308_0 - - typing-extensions=4.4.0=py37h06a4308_0 - - typing_extensions=4.4.0=py37h06a4308_0 - - urllib3=1.26.14=py37h06a4308_0 - - wheel=0.38.4=py37h06a4308_0 - - xz=5.2.10=h5eee18b_1 - - yaml=0.2.5=h7b6447c_0 - - zipp=3.11.0=py37h06a4308_0 - - zlib=1.2.13=h5eee18b_0 - - pip: - - accelerate==0.20.3 - - aiohttp==3.8.4 - - aiosignal==1.3.1 - - async-timeout==4.0.2 - - asynctest==0.13.0 - - attrs==22.2.0 - - beartype==0.13.1 - - beautifulsoup4==4.12.2 - - bs4==0.0.1 - - click==8.1.3 - - cycler==0.11.0 - - datasets==2.11.0 - - dill==0.3.6 - - einops==0.6.0 - - fonttools==4.38.0 - - frozenlist==1.3.3 - - fsspec==2023.1.0 - - ftfy==6.1.1 - - greenlet==2.0.2 - - huggingface-hub==0.15.1 - - jaraco-context==4.3.0 - - joblib==1.2.0 - - jsonlines==3.1.0 - - kiwisolver==1.4.5 - - langchain==0.0.27 - - matplotlib==3.5.3 - - more-itertools==9.1.0 - - multidict==6.0.4 - - multiprocess==0.70.14 - - nltk==3.8.1 - - nvidia-cublas-cu11==11.10.3.66 - - nvidia-cuda-nvrtc-cu11==11.7.99 - - nvidia-cuda-runtime-cu11==11.7.99 - - nvidia-cudnn-cu11==8.5.0.96 - - openai==0.27.7 - - pandas==1.3.5 - - pillow==9.5.0 - - protobuf==3.20.3 - - psutil==5.9.5 - - pyarrow==11.0.0 - - pydantic==1.10.7 - - pyparsing==3.1.1 - - python-dateutil==2.8.2 - - pytz==2023.3 - - rank-bm25==0.2.2 - - responses==0.18.0 - - safetensors==0.3.1 - - scikit-learn==1.0.2 - - scipy==1.7.3 - - sentencepiece==0.1.99 - - soupsieve==2.4.1 - - sqlalchemy==2.0.9 - - tenacity==8.2.2 - - threadpoolctl==3.1.0 - - tokenizers==0.13.3 - - toolformer==0.0.4 - - torch==1.13.1 - - torchtyping==0.1.4 - - torchvision==0.14.1 - - transformers==4.28.1 - - typeguard==3.0.2 - - wcwidth==0.2.6 - - wolframalpha==5.0.0 - - x-clip==0.12.1 - - xmltodict==0.13.0 - - xxhash==3.2.0 - - yarl==1.8.2 -prefix: /home/adseadmin/miniconda3/envs/nickname From 5db5e9cdb2b4d639587c8ae53ff3e3ec76f0b8f3 Mon Sep 17 00:00:00 2001 From: Miao Xiong Date: Sun, 31 Mar 2024 01:15:24 +0800 Subject: [PATCH 4/4] Update README.md --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index 6c5fcd2..5076f91 100644 --- a/README.md +++ b/README.md @@ -37,15 +37,6 @@ pip install -r requirements.txt | `--num-gpus` | `1` | Number of GPUs to use, `1/1/2` for `7B/13B/70B` model sizes respectively if you are using 80G GPU cards. | | `--do-rating` | | Add this to output evaluation results | -#### In-domain Hyperparameter choice - -In the table below, we present the `alpha` with the `info_layer` choices for each knowledge-seeking dataset, formatted as `alpha/info_layer`. - -| | TriviaQA | HotpotQA | NQ | -|---| --- | --- | --- | -|`LLaMa2-7B-chat`| `1/32`| `0.8/32` |`0.2/32` | -|`LLaMa2-13B-chat`| `0.6/32` |`1/28` | `0.8/34`| -|`LLaMa2-70B-chat`| `1/70`| `0.6/66` | `1/68` | ### TriviaQA, HotpotQA and Natural Questions