安装阶段:
- environmental preparation:Python 3.8+和PyTorch 1.13.1+(建议CUDA 11.7 GPU环境)
- Installation::
pip install graphg
(PyPI安装)
maybegit clone
源码后pip install -r requirements.txt
- API Configuration:在.env文件设置SYNTHESIZER_MODEL等关键参数
Operational Processes:
- Prepare to enter:制作符合要求的JSONL格式文本文件(参考resources/examples)
- Configuration parameters:编辑graphgen_config.yaml设置采样深度、生成风格等
- Execution generation::
Command line method:python -m graphg --config configs/graphgen_config.yaml
或通过python webui/app.py
启动Gradio可视化界面 - 获取输出:在output_dir指定目录查看生成的JSONL格式问答对
caveat:首次运行需5-10分钟初始化知识图谱;GPU设备可加速多跳关系处理;建议从demo数据开始验证环境。
This answer comes from the articleGraphGen: Fine-tuning Language Models Using Knowledge Graphs to Generate Synthetic DataThe