-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from xionghuaidong/0.6_dev
feat(example): add example csqa
- Loading branch information
Showing
28 changed files
with
156,224 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ckpt/ | ||
/cs.jsonl | ||
/solver/data/csqa_kag_answers.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# KAG Example: CSQA | ||
|
||
The [UltraDomain](https://huggingface.co/datasets/TommyChien/UltraDomain/tree/main) | ||
``cs.jsonl`` dataset contains 10 documents in Computer Science and | ||
100 questions with their answers about those documents. | ||
|
||
Here we demonstrate how to build a knowledge graph for those documents, | ||
generate answers to those questions with KAG and compare KAG generated | ||
answers with those from other RAG systems. | ||
|
||
## Steps to reproduce | ||
|
||
1. Follow the Quick Start guide of KAG to install OpenSPG server and KAG. | ||
|
||
2. (Optional) Download [UltraDomain](https://huggingface.co/datasets/TommyChien/UltraDomain/tree/main) | ||
``cs.jsonl`` and execute ``generate_data.py`` to generate data files in | ||
``./builder/data`` and ``./solver/data``. Since the generated files | ||
was committed, this step is optional. | ||
|
||
3. Update ``llm`` and ``vectorizer_model`` configuration in ``kag_config.yaml`` | ||
properly. ``splitter`` and ``num_threads_per_chain`` may also be updated | ||
to match with other systems. | ||
|
||
4. Restore the KAG project. | ||
|
||
```bash | ||
knext project restore --host_addr http://127.0.0.1:8887 --proj_path . | ||
``` | ||
|
||
5. Commit the schema. | ||
|
||
```bash | ||
knext schema commit | ||
``` | ||
|
||
6. Execute ``indexer.py`` in the ``builder`` directory to build the knowledge graph. | ||
|
||
7. Execute ``eval.py`` in the ``solver`` directory to generate the answers. | ||
|
||
The results are saved to ``./solver/data/csqa_kag_answers.json``. | ||
|
||
8. (Optional) Follow the LightRAG [Reproduce](https://github.com/HKUDS/LightRAG?tab=readme-ov-file#reproduce) | ||
steps to generate answers to the questions and save the results to | ||
``./solver/data/csqa_lightrag_answers.json``. Since a copy was committed, | ||
this step is optional. | ||
|
||
9. Update LLM configurations in ``summarization_metrics.py`` and ``factual_correctness.py`` | ||
and execute them to get the metrics. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2023 OpenSPG Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
# in compliance with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License | ||
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
# or implied. | ||
|
||
""" | ||
Builder Dir. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2023 OpenSPG Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
# in compliance with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License | ||
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
# or implied. | ||
|
||
""" | ||
Place the files to be used for building the index in this directory. | ||
""" |
Oops, something went wrong.