gusye1234 / nano-graphrag

A simple, easy-to-hack GraphRAG implementation
MIT License
1.66k stars 160 forks source link

Add multi-turn self-refine for entity relationship extractor #73

Closed NumberChiffre closed 1 month ago

NumberChiffre commented 1 month ago

Description

One-pass of the input text may not always return the full entities and relationships, so we can ask the LLM to refine its response via critique. The tradeoff for quality is to call the LLM several times more (perhaps parts of this can be substituted with distilled HF models in the future).

Here's a basic version that intends to improve mathematical solutions over multiple turns via critique: https://github.com/NumberChiffre/mcts-llm/blob/main/mcts_llm/mctsr.py#L36-L86

We'd have to make sure the refined entities and relationships are unique each.

gusye1234 commented 1 month ago

LGTM