/kg-rag-egc2024

Knowledge graph-based retrieval augmeted generation demonstrator for EGC 2024

Primary LanguagePythonOtherNOASSERTION

EGC 2024

EGC 2024 is the 24th French-speaking conference on Knowledge Extraction and Management. EGC stands for "Extraction et la Gestion des Connaissances" 🇫🇷

The conference will take place in Dijon, France from January 22nd to 26th, 2024.

This repo contains the code related to the Call for Demonstrations.

Demonstration overview

Given a question in natural language, we want to extract the knowledge from the graph that can be used to answer it, and then generate an answer based on this knowledge.

5 different techniques to do knowledge graph-based retrieval augmented generation are available :

  • langchain_graph_qa_openai uses the LangChain tool to generate a Cypher query based on the user's utterance and then uses the knowledge extracted from the graph with the query to generate an answer to the question with OpenAI model.
  • langchain_custom_openai is the same as langchain_graph_qa_openai but with custom prompts and a custom graph schema definition.
  • rag_bert_openai uses semantic similarity between the content of the graph and the user's utterance to extract the relevant knowledge used to generate an answer with OpenAI model.
  • entity_linking_openai uses entity linking and query patterns to extract knowledge from the graph and then generate an answer to the question based on this knowledge with OpenAI model.
  • entity_linking_mistral is the same as entity_linking_openai but with Mistral model.

Graph construction

Information for building the graph used in the demonstrators is available in the graph_construction folder.

Dataset

The questions used to evaluate the different methods are listed in the file sdg_questions.csv in the dataset folder.

References

Fotopoulou E, Mandilara I, Zafeiropoulos A, Laspidou C, Adamos G, Koundouri P and Papavassiliou S (2022) SustainGraph: A knowledge graph for tracking the progress and the interlinking among the sustainable development goals’ targets. Front. Environ. Sci. 10:1003599. doi: 10.3389/fenvs.2022.1003599