Skip to content

XMUDeepLIT/LLM-OREF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

README

Code for "LLM-OREF: An Open Relation Extraction Framework Based on Large Language Models"

  1. Install Environment:
conda env create -f env.yml 
  1. Data Format:
{
    "text": ...,
    "head": ...,
    "tail": ...,
    "label": ...,
    "ins_idx": ...
}
  1. Train RP:
torchrun --nproc_per_node=${n} --master_port=${port}  src/train_RP.py \
  --model_name ${model_name} \
  --model_path ${model_path}\
  --train_path ${train_path} \
  --output_path ${output_path} \
  --few_shot ${few_shot} \
  --train_batch_size ${train_batch_size} \
  --gradient_accumulation_steps ${gradient_accumulation_steps} \
  --num_train_epochs ${num_train_epochs} \
  --max_grad_norm ${max_grad_norm} \
  --bf16 \
  --deepspeed ${config} \
  --logging_steps ${logging_steps} \
  --lr ${lr} \
  --lora_r ${lora_r} \
  --lora_alpha ${lora_alpha} \
  --lora_dropout ${lora_dropout} \
    
  1. Train RD:
torchrun --nproc_per_node=${n} --master_port=${port}  src/train_RD.py \
  --model_name ${model_name} \
  --model_path ${model_path} \
  --train_path ${train_path} \
  --output_path ${output_path} \
  --RP_lora_path ${RP_lora_path} \
  --few_shot ${few_shot} \
  --temperature ${temperature} \
  --alpha ${alpha} \
  --train_batch_size ${train_batch_size} \
  --gradient_accumulation_steps ${gradient_accumulation_steps} \
  --num_train_epochs ${num_train_epochs} \
  --max_grad_norm ${max_grad_norm} \
  --bf16 \
  --deepspeed ${config} \
  --logging_steps ${logging_steps} \
  --lr ${LR} \
  --lora_r ${lora_r} \
  --lora_alpha ${lora_alpha} \
  --lora_dropout ${lora_dropout} \
  1. Relation Discovery:
python src/relation_discovery.py \
  --model_path ${model_path} \
  --train_path ${train_path} \
  --test_path ${test_path} \
  --unknown_r_path ${unknown_r_path} \
  --discoverer_lora_path ${discoverer_lora_path} \
  --output_path ${output_path} \
  --K ${K} \
  --few_shot ${few_shot} \
  1. Relation Denoising:
python src/relation_denoising.py \
  --model_path ${model_path} \
  --test_path ${test_path} \
  --RP_lora_path ${RP_lora_path} \
  --unknown_r_path ${unknown_r_path} \
  --output_path ${output_path} \
  --few_shot ${few_shot} \
  1. Relation Prediction:
python src/relation_prediction.py \
    --model_path ${model_path} \
    --test_path ${test_path} \
    --demo_path ${demo_path} \
    --unknown_r_path ${unknown_r_path} \
    --RP_lora_path ${RP_lora_path} \
    --output_path ${output_path} \
    --few_shot ${few_shot} \

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages