gusye1234 / nano-graphrag

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

Convert Entity Relationship Extraction in DSPy to using CoT #44

Closed NumberChiffre closed 2 months ago

NumberChiffre commented 2 months ago

Description

DSPy has typed predictors/CoT that uses pydantic models as schema for their return types, however this is not as reliable as non-typed like CoT (because if something goes wrong with the formatting, you can catch it and resolve it yourself, often times some JSON parsing error or response from outputfield ends up in the prediction.rationale of CoT). Therefore, this PR is here to resolve these formatting issues with DSPy once and for all (hopefully) and run MIPROv2 to generate optimal prompt instructions for entity relationship extraction.

Misc:

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 98.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 94.25%. Comparing base (f11e9f2) to head (20bb681). Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
nano_graphrag/entity_extraction/extract.py 96.77% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #44 +/- ## ========================================== - Coverage 94.36% 94.25% -0.12% ========================================== Files 11 12 +1 Lines 1189 1288 +99 ========================================== + Hits 1122 1214 +92 - Misses 67 74 +7 ``` | [Flag](https://app.codecov.io/gh/gusye1234/nano-graphrag/pull/44/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Gustavo+Ye) | Coverage Δ | | |---|---|---| | [](https://app.codecov.io/gh/gusye1234/nano-graphrag/pull/44/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Gustavo+Ye) | `94.25% <98.66%> (?)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Gustavo+Ye#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.