> ## Documentation Index
> Fetch the complete documentation index at: https://koreai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate a Knowledge Graph

[Back to NLP Topics](https://koreai.mintlify.site/ai-for-service/automation/natural-language/nlp-topics.md)

The KG Generator is a command-line tool that automatically extracts terms from your FAQ list, defines a hierarchy, and associates FAQs to the appropriate terms. Use it to bootstrap a KG from an existing Q\&A dataset instead of building the structure manually.

> [!NOTE]
>
> Review and adjust the generated output before importing—it is a suggestion, not a final structure.

The generator is available at [Kore.ai GitHub](https://github.com/Koredotcom/KnowledgeGraphGenerator).

***

## Prerequisites

| Requirement | Notes |
| - | - |
| Python 3.6 | [Download](https://www.python.org/downloads/) |
| Virtual environment | Recommended. See [Python venv docs](https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments). |
| Microsoft Visual C++ Build Tools (Windows) | Tested with v14.0. |
| Windows 10 SDK (Windows 10) | [Download](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/). Keep OS up to date for DLL compatibility. |
| FAQ file | JSON or CSV format. Export from Platform or build a CSV with questions in column 1 and answers in column 2. |

***

## Setup

1. Download and extract the KG Generator zip file.
2. Open a terminal in the extracted folder.
3. Activate your virtual environment:
   * **Windows:** `<venvs_folder>/<venv_name>/Scripts/activate`
   * **Unix/macOS:** `<venvs_folder>/<venv_name>/bin/activate`
4. Install dependencies:
   ```bash theme={null}
   pip install -r requirements.txt
   ```
5. Verify installation: `pip list` — confirm all packages from `requirements.txt` are listed.
6. Download the spaCy English model:
   ```bash theme={null}
   python -m spacy download en
   ```

***

## Run the Generator

```bash theme={null}
python KnowledgeGraphGenerator.py --file_path <INPUT_FILE_PATH> --type <INPUT_FILE_TYPE> --language <LANGUAGE_CODE> --v <true/false>
```

| Option | Description | Required | Default |
| - | - | - | - |
| `--file_path` | Path to the input file. | Yes | — |
| `--type` | File type: `json_export` (XO JSON export), `csv_export` (XO CSV export), or `CSV` (plain Q\&A CSV). | Yes | — |
| `--language` | Language code of the input data. | No | `en` |
| `--v` | Verbose mode — shows intermediate progress. | No | `false` |

***

## Output

The generator creates `ao_output.json` in the project root directory. This file can be imported directly into your AI Agent's KG.

See [Import a Knowledge Graph](https://koreai.mintlify.site/ai-for-service/automation/knowledge-ai/import-and-export-knowledge-graph).

> [!NOTE]
>
> Importing replaces the existing KG. Back up your current KG before importing.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.