• Stars
    star
    182
  • Rank 211,154 (Top 5 %)
  • Language
    Python
  • Created about 1 year ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[Paper][ACL 2024 Findings] Knowledgeable Preference Alignment for LLMs in Domain-specific Question Answering

Knowledgeable Preference Alignment for LLMs in Domain-specific Question Answering

license Preprint Pytorch

For domain-specific application of large language models (LLMs), external knowledge and LLMs should work together to achieve best user experience. LLMs should acquire an ability to make the right choices about retrieved external knowledge to meet the human needs. Knowledgeable Preference AlignmenT (KnowPAT) is a new pipeline to align LLMs with human's knowledge preference. KnowPAT incorporates domain knowledge graphs to construct preference set and design new alignment objective to fine-tune the LLMs.

🌈 Model Architecture

Model_architecture

πŸ’» Data preparation

For reasons of commercial confidentiality, the dataset in our paper will not be made public. However, we provide examples of the data in data/ so that you can construct your own preference dataset and try out our alignment method according to the given format.

For each data instance, you should prepare a question and several answers, and the human preference score of each answer. A higher score means a better and preferred answer. Note that the answers should be sorted in the score descending order, which means the better answer and its score should be in the front.

πŸ”¬ Dependencies

Our code is developed based on RRHF. Please build the Python environment following the instruction like RRHF.

To set up, you can use the following command lines to set up python3.8 and pytorch requirements:

conda create -n alignment python=3.8
pip install torch==1.13.0+cu116 torchvision==0.14.0+cu116 torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/cu116

Install other packages:

pip install -r requirements.txt

πŸ“• Training & Test

  • run KnowPAT tuning
export MODEL_PATH="YOUR LLM PATH"
export SAVE_PATH="YOUR SAVE PATH"
export DATA_PATH="YOUR DATA PATH"
export WANDB_DISABLED=true
wandb offline

CUDA_VISIBLE_DEVICES=0 nohup python train.py \
    --model_name_or_path $MODEL_PATH \
    --data_path $DATA_PATH \
    --bf16 True \
    --output_dir $SAVE_PATH \
    --num_train_epochs 3 \
    --per_device_train_batch_size 1 \
    --per_device_eval_batch_size 1 \
    --gradient_accumulation_steps 8 \
    --evaluation_strategy "no" \
    --save_strategy "steps" \
    --save_steps 3000 \
    --save_total_limit 40 \
    --learning_rate 3e-4 \
    --weight_decay 0. \
    --warmup_ratio 0.03 \
    --lr_scheduler_type "cosine" \
    --logging_steps 1 \
    --model_max_length 512 --rrhf_weight 0.1 > log.txt &

You may need to fill your model/save/data path before running. The model path should be a llama-architecture LLM.

  • run inference
CUDA_VISIBLE_DEVICES=0 python inference.py

🀝 Cite:

Please consider citing this paper if you use the code from our work. Thanks a lot :)


@article{DBLP:journals/corr/abs-2311-06503,
  author       = {Yichi Zhang and
                  Zhuo Chen and
                  Yin Fang and
                  Lei Cheng and
                  Yanxi Lu and
                  Fangming Li and
                  Wen Zhang and
                  Huajun Chen},
  title        = {Knowledgeable Preference Alignment for LLMs in Domain-specific Question
                  Answering},
  journal      = {CoRR},
  volume       = {abs/2311.06503},
  year         = {2023}
}

More Repositories

1

KG-LLM-Papers

[Paper List] Papers integrating knowledge graphs (KGs) and large language models (LLMs)
1,409
star
2

NeuralKG

[Tool] For Knowledge Graph Representation Learning
Python
350
star
3

KG-MM-Survey

Knowledge Graphs Meet Multi-Modal Learning: A Comprehensive Survey
305
star
4

MyGO

[Paper][Preprint 2024] MyGO: Discrete Modality Information as Fine-Grained Tokens for Multi-modal Knowledge Graph Completion
Python
208
star
5

KoPA

[Paper][ACM MM 2024] Making Large Language Models Perform Better in Knowledge Graph Completion
Python
133
star
6

Structure-CLIP

[Paper][AAAI2024]Structure-CLIP: Towards Scene Graph Knowledge to Enhance Multi-modal Structured Representations
Python
106
star
7

MEAformer

[Paper][ACM MM 2023] MEAformer: Multi-modal Entity Alignment Transformer for Meta Modality Hybrid
Python
52
star
8

DUET

[Paper][AAAI 2023] DUET: Cross-modal Semantic Grounding for Contrastive Zero-shot Learning
Python
46
star
9

MorsE

[Paper][SIGIR2022] Meta-Knowledge Transfer for Inductive Knowledge Graph Embedding
Python
40
star
10

MaKEr

[Paper][IJCAI2022] Meta-Learning Based Knowledge Extrapolation for Knowledge Graphs in the Federated Setting
Python
29
star
11

EasySchema

29
star
12

UMAEA

[Paper][ISWC 2023] Rethinking Uncertainly Missing and Ambiguous Visual Modality in Multi-Modal Entity Alignment
Python
29
star
13

NATIVE

[Paper][SIGIR 2024] NativE: Multi-modal Knowledge Graph Completion in the Wild
Python
23
star
14

AdaMF-MAT

[Paper][LREC-COLING 2024] Unleashing the Power of Imbalanced Modality Information for Multi-modal Knowledge Graph Completion
Python
20
star
15

FedE

[Paper][IJCKG2021] FedE: Embedding Knowledge Graphs in Federated Setting
Python
19
star
16

RMPI

[Paper][ICDE2023] Relational Message Passing for Fully Inductive Knowledge Graph Completion
Python
18
star
17

Ruleformer

[Paper][COLING2022] Ruleformer: Context-aware Rule Mining over Knowledge Graph
Python
18
star
18

NeuralKG-ind

Python
15
star
19

CausE

[Paper][CCKS2023] CausE: Towards Causal Knowledge Graph Embedding
Python
15
star
20

SNAG

[Paper][Preprint 2024] The Power of Noise: Toward a Unified Multi-modal Knowledge Graph Representation Framework
Python
12
star
21

EARL

[Paper][AAAI2023] Entity-Agnostic Representation Learning for Parameter-Efficient Knowledge Graph Embedding
Python
12
star
22

KGTransformer

Source code for "Structure Pre-training and Prompt Tuning for Knowledge Graph Transfer" accepted by WWW'23
Python
11
star
23

MoMoK

[Paper][Preprint 2024] Mixture of Modality Knowledge Experts for Robust Multi-modal Knowledge Graph Completion
Python
9
star
24

DOZSL

[Paper][KDD2022] Disentangled Ontology Embedding for Zero-shot Learning
Python
8
star
25

MANS

[Paper][IJCNN2023] Modality-Aware Negative Sampling for Multi-modal Knowledge Graph Embedding
Python
7
star
26

AnKGE

[Paper][AAAI2023] Analogical Inference Enhanced Knowledge Graph Embedding
Python
7
star
27

LPKG

Python
6
star
28

ENeSy

[Paper][NeurIPS2022] Neural-Symbolic Entangled Framework for Complex Query Answering
Python
5
star
29

MACO

[Paper][NLPCC 2023] MACO: A Modality Adversarial and Contrastive Framework for Modality-missing Multi-modal Knowledge Graph Completion
Python
5
star
30

GEEA

Revisit and Outstrip Entity Alignment: A Perspective of Generative Models
Python
4
star
31

MuDoK

[Paper][Preprint 2024] Multi-domain Knowledge Graph Collaborative Pre-training and Prompt Tuning for Diverse Downstream Tasks
Python
3
star
32

GPHT-for-TSP

Python
2
star
33

cnGraph

1
star
34

PaperList-Neural-Symbolic-KGR

1
star