ibm-granite-community / pm

Granite Community Project Management
0 stars 0 forks source link

legal graph rag on caselaw #158

Open fayvor opened 3 weeks ago

fayvor commented 3 weeks ago

Implement Graph RAG against the NH Caselaw dataset.

Links:

Steps: Taking a cue from this paper, the steps would include:

  1. Come up with a taxonomy or list of categories of entities involved in case law (eg., plaintiff, defendant, rule, issue, etc.). Ask an LLM to draft this.
  2. For each chunk of text, extract the entities that fall into the taxonomy above.
  3. Generate triples for how each entity interacts with each other.
  4. Compose subgraphs into a larger graph (eg., using networkx.compose).
  5. Create embeddings for each node in the graph.
  6. Merge nodes that are highly similar, using the highest-connected node label as the merged node label.
  7. Clean up the graph by finding connected components and removing those below a critical size threshold.
  8. For community analysis, group graphs into communities. The paper uses the Girvan-Newman algorithm, which detects communities by progressively removing nodes with the highest "betweenness centrality" -- those that participate in the highest number of shortest-paths between other nodes.
  9. For question answering, extract entities from the question and use the graph to find relevant cases. Retrieve the case text and answer the question.