{"id":21291567,"url":"https://github.com/smartdataanalytics/kgirnet","last_synced_at":"2025-07-11T16:30:47.881Z","repository":{"id":40959261,"uuid":"280179172","full_name":"SmartDataAnalytics/kgirnet","owner":"SmartDataAnalytics","description":"Scripts for KGIRNet model for ESWC","archived":false,"fork":false,"pushed_at":"2023-07-06T22:01:43.000Z","size":22781,"stargazers_count":10,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-16T07:41:34.212Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SmartDataAnalytics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-16T14:43:19.000Z","updated_at":"2023-05-31T01:47:49.000Z","dependencies_parsed_at":"2022-09-20T19:53:32.647Z","dependency_job_id":null,"html_url":"https://github.com/SmartDataAnalytics/kgirnet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartDataAnalytics%2Fkgirnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartDataAnalytics%2Fkgirnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartDataAnalytics%2Fkgirnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartDataAnalytics%2Fkgirnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SmartDataAnalytics","download_url":"https://codeload.github.com/SmartDataAnalytics/kgirnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225738024,"owners_count":17516477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T13:36:05.185Z","updated_at":"2024-11-21T13:36:05.902Z","avatar_url":"https://github.com/SmartDataAnalytics.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KGIRNET: Grounding Dialogue Systems via Knowledge Graph Aware Decoding with Pre-trained Transformers\nGenerating knowledge grounded responses in both goal and non-goal oriented dialogue systems is an important research challenge. Knowledge Graphs (KG) can be viewed as an abstraction of the real world, which can potentially facilitate a dialogue system to produce knowledge grounded responses. However, integrating KGs into the dialogue generation process in an end-to-end manner is a non-trivial task. This paper proposes a novel architecture for integrating KGs into the response generation process by training a BERT model that learns to answer using the elements of the KG (entities and relations) in a multi-task, end-to-end setting. The k-hop subgraph of the KG is incorporated into the model during training and inference using Graph Laplacian. Empirical evaluation suggests that the model achieves better knowledge groundedness (measure via entity F1 score) compared to other state-of-the-art models for both goal and non-goal oriented dialogues.\n\n![](https://github.com/DeepInEvil/kgirnet/blob/master/model_diagram.png)\n\n## ✅ Requirements\n* python==3.6\n* torch==1.5.1\n* [Anaconda](https://www.anaconda.com/products/individual)\n\n\n## 🔧 Installation\nRun the following command to install the requirements:\n```commandline\nconda create -n kgirnet -y python=3.6 \u0026\u0026 source activate kgirnet\npip install -r requirements.txt\n\nwget https://dl.fbaipublicfiles.com/fasttext/vectors-wiki/wiki.simple.zip\nunzip wiki.simple.zip\nmv wiki.simple.bin data/\nrm wiki.simple.vec\nrm wiki.simple.zip\n```\n\n## 🏋️ Train\nTo train the model from scratch run the following command:\n#### For in-car dataset\n```python\npython -u ./train_kgirnet.py --batch_size 20 --hidden_size 256 --rnn_dropout 0.2 --dropout 0.3 --decoder_lr 10 --epochs 10 --teacher_forcing 10 --resp_len 20 --lr 0.0001 --use_bert 1 --dataset incar\n```\n#### For soccer dataset\n```python\npython -u ./train_kgirnet.py --batch_size 20 --hidden_size 256 --rnn_dropout 0.2 --dropout 0.3 --decoder_lr 10 --epochs 10 --teacher_forcing 10 --resp_len 20 --lr 0.0001 --use_bert 1 --dataset soccer\n```\nRunning the above command will train and then test the trained model. Then a *.csv file will be generated which will contain the test predictions.\n\n\n## 🎯 Test and Evaluation ⚖️\nTo test the pre-trained model download the saved model form here ([in-car model](https://ndownloader.figshare.com/files/26645885), [soccer model](https://ndownloader.figshare.com/files/26645699)) and put them inside the ```saved_models/``` directory. Now run the following commands:\n#### For in-car dataset:\n```python\npython -u ./train_kgirnet.py --batch_size 20 --hidden_size 128 --rnn_dropout 0.2 --dropout 0.3 --decoder_lr 10 --epochs 10 --teacher_forcing 10 --resp_len 20 --lr 0.0001 --use_bert 1 --dataset incar --evaluate 1\n```\n#### For soccer dataset:\n```python\npython -u ./train_kgirnet.py --batch_size 20 --hidden_size 256 --rnn_dropout 0.2 --dropout 0.3 --decoder_lr 10 --epochs 10 --teacher_forcing 10 --resp_len 20 --lr 0.0001 --use_bert 1 --dataset soccer --evaluate 1\n```\nEvaluation scores are generated at the end of testing.\n\n## 📜 License\nMIT\n\n## 📝 Citation\nComing soon\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartdataanalytics%2Fkgirnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartdataanalytics%2Fkgirnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartdataanalytics%2Fkgirnet/lists"}