More than code

More Than Code
The efficiency of your iteration of reading, practicing and thinking decides your understanding of the world.
  1. 首页
  2. ml
  3. 正文

MS GraphRAG 增量更新

2025年3月30日 112点热度 0人点赞 0条评论

这篇文章来看一下MS GraphRAG是怎么实现增量更新的。核心的代码在:https://github.com/microsoft/graphrag/blob/main/graphrag/index/run/run_pipeline.py

入口在run_pipeline中,参数is_update_run,表示本次写入是增量还是全量

  • run_pipeline
    • get_delta_docs,这里是根据之前存储中的文档过滤一下,只处理新生成的文档。这里是根据title做的过滤,而非md5什么的。一般来说这里的title就是文件的path
    • 创建一些新的临时storage:
      • 本次增量数据的存储位置
      • 前一次全量数据的backup
      • 这里会把新的数据写到增量数据对应的存储空间中,然后把全量数据做backup。然后在base目录下写新的全量数据
    • _run_pipeline,做全量写入的逻辑,这里的数据就会写到上面创建的增量数据的storage中
    • update_dataframe_outputs做增量和全量数据的合并
  • update_dataframe_outputs
    • 这里的参数核心有三个:previous_storage/delta_storage/output_storage
    • document,直接把两个df合并,写到新的数据中即可
    • entity/relationship:
      • 这里因为ms graphrag有一个自己分配的human readable id,需要重新分配一下。
      • 把重复的实体/边的description做一下summary
    • text_unit 这里也涉及到human readable id也需要处理一下
    • covariates暂时不看,现在还不知道有谁在用claim
    • _update_communities
      • 这里是直接把社区concate到一起了,并没有考虑同一个实体在两个社区的情况
    • _update_and_merge_community_reports
      • 这里也是直接把community report concate到一起了
标签: 暂无
最后更新:2025年3月30日

sheep

think again

点赞
< 上一篇

文章评论

取消回复

COPYRIGHT © 2021 heavensheep.xyz. ALL RIGHTS RESERVED.

THEME KRATOS MADE BY VTROIS