Papiercode Schema-adaptable Knowledge Graph Construction .
Unsere Arbeit wurde von der EMNLP2023 -Erkenntniskonferenz akzeptiert.
Um den Code auszuführen, müssen Sie die folgenden Anforderungen installieren:
conda create -n adakgc python=3.8
pip install torch==1.8.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
pip install -r requirements.txt
Unser Modell -Tokenizer -Teil verwendet UIE, und die anderen verwenden T5, daher handelt es sich um eine gemischte Datei. Der Download -Link wird hier bereitgestellt. Bitte verwenden Sie dieses Modell. hf_models/mix
Weitere Informationen zur Datensatzkonstruktion finden Sie in der Datenkonstruktion.
Sie finden den Datensatz über den folgenden Google Drive -Link.
Datensatz ACE05, WENIGER-NERD, NYT
mkdir hf_models
cd hf_models
git lfs install
git clone https : // huggingface . co / google / t5 - v1_1 - base
cd ..
mkdir output # */AdaKGC/output # Current path: */AdaKGC
mode=H
data_name=Few-NERD
task=entity
device=0
ratio=0.8
bash scripts/fine_prompt.bash --model=hf_models/mix --data=data/ ${data_name} _ ${mode} /iter_1 --output=output/ ${data_name} _ ${mode} _ ${ratio} --config=config/prompt_conf/Few-NERD.ini --device= ${device} --negative_ratio= ${ratio} --record2=data/ ${data_name} _ ${mode} /iter_7/record.schema --use_prompt=True --init_prompt=True
model : Der Name oder Pfad des vorbereiteten Modells.
data : Der Pfad zum Datensatz.
output : Der Pfad des gespeicherten Fine-Tuning-Checkpoint und der endgültige automatisch generierte Ausgangspfad `adakgc/output/ace05_event_h_e30_lr1e-4_b14_n0.
config : In der Standardkonfigurationsdatei im Verzeichnis config/prompt_conf ist die Konfiguration jeder Aufgabe unterschiedlich.
mode : Datensatzmodus ( H , V , M oder R ).
device : CUDA_VISIBLE_DEVICES.
batch : Chargengröße.
(Siehe Bash -Skripte und Python -Dateien für detaillierte Befehlszeilenparameter.)
mode=H
data_name=NYT
task=relation
device=0
ratio=0.8
bash scripts/fine_prompt.bash --model=hf_models/mix --data=data/ ${data_name} _ ${mode} /iter_1 --output=output/ ${data_name} _ ${mode} _ ${ratio} --config=config/prompt_conf/NYT.ini --device= ${device} --negative_ratio= ${ratio} --record2=data/ ${data_name} _ ${mode} /iter_7/record.schema --use_prompt=True --init_prompt=Truemode=H
data_name=ace05_event
task=event
device=0
ratio=0.8
bash scripts/fine_prompt.bash --model=hf_models/mix --data=data/ ${data_name} _ ${mode} /iter_1 --output=output/ ${data_name} _ ${mode} _ ${ratio} --config=config/prompt_conf/ace05_event.ini --device= ${device} --negative_ratio= ${ratio} --record2=data/ ${data_name} _ ${mode} /iter_7/record.schema --use_prompt=True --init_prompt=Truedata/ace05_event_H/iter_1 ) mode=H
data_name=ace05_event
task=event
device=0
ratio=0.8
python3 inference.py --dataname=data/ ${data_name} / ${data_name} _ ${mode} /iter_2 --t5_path=hf_models/mix --model=output/ ${data_name} _ ${mode} _ ${ratio} --task= ${task} --cuda= ${device} --mode= ${mode} --use_prompt --use_ssi --prompt_len=80 --prompt_dim=512 datasetname : Der Pfad zum vorhergesagten Datensatz ( ace05_event , NYT oder Few-NERD ).
model : Der Pfad des nach dem vorherigen Trainings erhaltenen Modells (Ausgabe in der Trainingsphase).
t5_path : Basismodell T5 (Modell in der Trainingsphase).
task : Aufgabentyp (Entität, Beziehung, Ereignis).
cuda : CUDA_VISIBLE_DEVICES.
mode : Datensatzmodus ( H , V , M oder R ).
use_ssi , use_prompt , prompt_len und prompt_dim müssen mit der Trainingszeit übereinstimmen. Sie können es in der entsprechenden Konfigurationsdateikonfiguration/forderungs_conf/ace05_event.ini anzeigen und festlegen.
data/iter_1/ace05_event_H ~ data/iter _7/ace05_event_H ) mode=H
data_name=ace05_event
task=event
device=0
ratio=0.8
python3 inference_mul.py --dataname=data/ ${data_name} / ${data_name} _ ${mode} --t5_path=hf_models/mix --model=output/ ${data_name} _ ${mode} _ ${ratio} --task= ${task} --cuda= ${device} --mode= ${mode} --use_prompt --use_ssi --prompt_len=80 --prompt_dim=512 use_ssi , use_prompt , prompt_len und prompt_dim müssen mit dem Training überein sein.
Der vollständige Vorgang, einschließlich Feinabstimmung und Argumentation (in "Skripten/run.bash"):
mode=H
data_name=ace05_event
task=event
device=0
ratio=0.8
bash scripts/run_prompt.bash --model=hf_models/mix --data=data/ ${data_name} _ ${mode} /iter_1 --output=output/ ${data_name} _ ${mode} _ ${ratio} --config=config/prompt_conf/ace05_event.ini --device= ${device} --negative_ratio= ${ratio} --record2=data/ ${data_name} _ ${mode} /iter_7/record.schema --use_prompt=True --init_prompt=True
python3 inference_mul.py --dataname=data/ ${data_name} / ${data_name} _ ${mode} --t5_path=hf_models/mix --model=output/ ${data_name} _ ${mode} _ ${ratio} --task= ${task} --cuda= ${device} --mode= ${mode} --use_prompt --use_ssi --prompt_len=80 --prompt_dim=512| Index | Definition | F1 |
|---|---|---|
| Ent- (P/R/F1) | Entität MICRO-F1-Punktzahl (Entitätstyp, Entitätspanne) | Spot-F1 |
| rel-strikt- (p/r/f1) | MICRO-F1-Werte für strenge Beziehungsmodi (Beziehungstyp, Arg1-Span, Arg1-Typ, Arg2-Span, Arg2-Typ) | ASOC-F1 wird für Beziehungen verwendet. Spot-F1 wird für Entitäten verwendet |
| EVT-Trigger- (P/R/F1) | MICRO-F1-Punktzahl des Ereignisauslöser-Wortes (Ereignisart, Triggerspannweite) | Spot-F1 |
| EVT-ROLE- (P/R/F1) | MICRO-F1-Punktzahl für Ereignisrollen (Ereignisart, Arg-Rolle, Arg-Span) | ASOC-F1 |
Insgesamt-F1 bezieht sich auf die Summe von Spot-F1 und ASOC-F1, die 100 überschreiten darf.
Ein Teil unseres Kodex wird von UIE und Unifiedskg ausgeliehen, vielen Dank.
Wenn Sie unsere Arbeit verwenden oder erweitern, zitieren Sie bitte das Papier wie folgt:
@article { DBLP:journals/corr/abs-2305-08703 ,
author = { Hongbin Ye and
Honghao Gui and
Xin Xu and
Huajun Chen and
Ningyu Zhang } ,
title = { Schema-adaptable Knowledge Graph Construction } ,
journal = { CoRR } ,
volume = { abs/2305.08703 } ,
year = { 2023 } ,
url = { https://doi.org/10.48550/arXiv.2305.08703 } ,
doi = { 10.48550/arXiv.2305.08703 } ,
eprinttype = { arXiv } ,
eprint = { 2305.08703 } ,
timestamp = { Wed, 17 May 2023 15:47:36 +0200 } ,
biburl = { https://dblp.org/rec/journals/corr/abs-2305-08703.bib } ,
bibsource = { dblp computer science bibliography, https://dblp.org }
}