GraphGPT: convert unstructured natural language into a knowledge graph

Dr. Veronica Espinoza
8 min readMar 7, 2023

--

By Dr. Verónica Espinoza, 2023 / ✔Twitter @Verukita1 ✔LinkedIn Dra. Verónica Espinoza

Image by the author

Build complex, directed graphs to add structure to your ideas using natural language. Understand the relationships between people, systems, and maybe solve a mystery.

¿What is a knowledge graph?

A knowledge graph is a directed labeled graph in which domain-specific meanings are associated with nodes and edges. A node could represent any real-world entity, for example, people, companies, and computers. An edge label captures the relationship of interest between the two nodes. For example, a friendship relationship between two people; a customer relationship between a company and person; or a network connection between two computers [1].

What can I do with GraphGPT?

GraphGPT converts unstructured natural language into a knowledge graph. Pass in the synopsis of your favorite movie, a passage from a Wikipedia page, or transcript from a video to generate a graph visualization of entities and their relationships. Successive queries can update the existing state of the graph or create an entirely new structure. For example, updating the current state could involve injecting new information through nodes and edges or changing the color of certain nodes [2].

The current few-shot prompt guides GPT-3 in accurately understanding the JSON formatting GraphGPT requires for proper rendering. A major issue at the moment is latency. Due to the nature of OpenAI API calls, it takes up to 20 seconds to receive a response[2].

Varun Shenoy , a researcher at Stanford University, has developed an AI GraphGPT that creates a knowledge graph of the connections between people and proper nouns contained in input sentences. GraphGPT uses GPT-3, a natural language processing model developed by OpenAI, and converts unstructured natural language into graphs [3].

Find here the repository of GraphGPT.

What will we review in this story?

In this story, I will tell you about my experience exploring GraphGPT. I will show five exercises I did. I also share tips that I found while exploring this App and finally, I share three open access books that can be useful in case you want to know more about knowledge graphs!

The exercises that will be reviewed in this story are the following:

· Exercise 1. Generation of a knowledge network from a paragraph of a scientific article.

· Exercise 2. Generation of a knowledge graph from the description of a person.

· Exercise 3. Two examples of knowledge graphs generated from the description of two network analysis tools. These two descriptions were taken from each tool’s website.

· Exercise 4: Knowledge graph from a transcript of a YouTube video.

· Exercise 5. Knowledge graph with text and emojis generated from a Wikipedia paragraph.

🏁Let’s start!

Exercise 1. Generation of a knowledge network from a paragraph of a scientific article.

Step 1. Get your OpenAI API key here, it is very easy!

Step 2. Open the App GraphGPT here, you will see the following options: “Describe your graph” and “Enter your OpenAI API key”, as shown.

Figure 1. GraphGPT interface.

Now, write the description of your graph and your OpenAI API key, then click on “Generate”.

For this example, I pasted the following scientific paragraph into the field “Describe your graph”. The paragraph was taken from the article: Sheikh NK, Dua A. Cannabinoids, 2022 [4].

Figure 3. Information used to generate the knowledge network. Sheikh NK, Dua A. Cannabinoids, 2022 [4]

The following gif shows the procedure:

Figure 2. Process to generate the knowledge network from a paragraph of a scientific article.

The following image shows the knowledge graph that I obtained with the information from the scientific article mentioned above.

Figure 2. Knowledge graph obtained from article paragraph.

Step 3. Now, I added colors to some nodes. Below is an example to color 4 nodes light blue with the following prompt:

“Make Cannabinoid, Cannabidiol, Nabilone and Dronabinol light blue”

You can also change “Make” by “Color” It works both ways for me.

Figure 4. Example of how to color the nodes in the knowledge graph.

The following figure shows the result obtained:

Figure 5. Result obtained from the prompt to color nodes.

You can color all the nodes as you wish using this example!

Exercise 2. Generation of a knowledge graph from the description of a person.

For this exercise I used a brief description about myself:

Prompt: Verónica studied at UNAM. UNAM is a public university in Mexico. Verónica studied Humanities, Neurobiology and Chemistry. She collaborates with researchers from various areas. Verónica’s hobbies are reading and playing the piano.

I pasted this description into the ChatGPT application, as shown:

Figure 6. Process to generate a knowledge graph from the description of a person.

After getting my knowledge graph with the brief description about me, I added colors to the nodes following the procedure as we reviewed in Exercise 1 (step 2) and I got the following graph:

Figure 7. Generation of a knowledge graph from the description of a person.

Exercise 3. Knowledge graphs generated from the description of two network analysis tools: Gephi [5] and NodeXL [6]. These two descriptions were taken from each tool’s website.

a) Gephi knowledge graph:

Figure 8. Example of a Gephi knowledge graph. The description was taken from the website.

b) NodeXL knowledge graph:

Figure 9. Example of a NodeXL knowledge graph. The description was taken from the website.

Exercise 4: Knowledge graph from a transcript of a YouTube video.
First, I got the transcript of an interview of Daniel Miller whose YouTube video title is “Digital Anthropology.” [7]. The duration of the interview is 14 minutes 12 seconds (13 pages). Because the transcript is long, only a part of the transcript is displayed in the Prompt.

The following illustration shows what was described above.

Figure 10. Knowledge graph from a transcript of a YouTube video.

Exercise 5. Knowledge graph with text and emojis generated from a paragraph of the Wikipedia article titled “Emotions”[8].

Below I describe the steps I followed for this exercise:
1.-I selected a Wikipedia paragraph from the mentioned article.
2.-In ChatGPT, I converted the basic emotions mentioned in this paragraph into emojis (see prompt in the image below).
3.-I pasted and processed the result of ChatGPT into GraphGPT.
4.-I got the knowledge graph and I added colors to the nodes.

The following illustration shows the process:

Figure 11. Knowledge graph with text and emojis from Wikipedia paragraph.

For teaching purposes, I processed a brief text, but you can make your knowledge graph with more nodes, relationships and emojis based on this example.

Interesting tips that I discovered while exploring this App.

  1. You can delete a node that doesn’t interest you with the following prompt: Delete [node name].
  2. If you want to color a node use the following: Color/ Make [node name] [color]. Example: “Color Mike red” or “Make Mike red”.
  3. If you can’t delete or color a node longer than one word, enclose it into quotes. Example: Delete “facial expression”.
  4. If you have already made a knowledge graph and you want to add more nodes and relations, just write the new prompt (on the same graph) and the nodes and relations (if any) will be added where it corresponds.
  5. If your text to be analyzed is very long, the following message will appear: “Error: Something went wrong with the request, please check the Network log”. So I recommend that the texts you analyze are not too long.
  6. To save your network don’t take a screenshot! You can right-click and save the graph as a .png 📸

Conclusion

From my point of view, Graph GPT is an easy-to-use tool, quite intuitive. It allows you to convert unstructured natural language into a knowledge graph in a few seconds. You can quickly generate a graphical display of entities and their relationships, from scientific article paragraphs, Wikipedia paragraphs, descriptions of people, video transcripts, and much more!

GraphGPT is in its early stages of development, but without a doubt, I think it will increase its accuracy, functions and capabilities later on. So if you want to get knowledge graphs in a quick and easy way to find relationships in your texts, GraphGPT may be an option.

On the other hand, if you want to generate knowledge graphs with large databases coming from different sources, you can surely select other tools or some Python or R libraries. The choice of your tool will depend on various factors such as the type of data you have, the research needs you require, the type of analysis you need to do, among others. Some tools that I found that allow to generate knowledge graphs could be: Neo4j, Stardog, Vaticle, AllegroGraph, Protege, GraphDB, PoolParty, Ontotext, to mention just a few.

👍Thanks for reading this story.

😃My Twitter

🔍Find more stories I’ve written here

OPEN ACCESS RESOURCES

Do you want to know more about knowledge graphs?

I share three open access books related to knowledge graphs.

1.- Knowledge Graphs [9]. You can read this book directly online from the free HTML version.

2. - Knowledge Graphs and Big Data Processing [10]. This book is open access, and you can download it directly in PDF format from the website.

3.- Knowledge Graphs Book — Data Scientists [11]. This book is open access, and is provided by Neo4j. You can download it directly from the website, you just must write some information like your name and email and after that, you will get the book in PDF!

References

  1. Chaudhri VK, Baru C, Chittar N, Dong XL, Genesereth M, Hendler J, et al. Knowledge graphs: Introduction, history, and perspectives. AI Magazine. 2022;43(1):17–29.
  2. Shenoy V. GraphGPT [Internet]. 2023 [cited 2023 Feb 20]. Available from: https://github.com/varunshenoy/GraphGPT
  3. “GraphGPT’’ that creates a knowledge graph of connections between people and proper nouns from sentences input by AI appears [Internet]. GIGAZINE. 2023 [cited 2023 Feb 25]. Available from: http://gigazine.net/gsc_news/en/20230209-graphgpt/
  4. Sheikh NK, Dua A. Cannabinoids [Internet]. StatPearls [Internet]. StatPearls Publishing; 2022 [cited 2023 Feb 19]. Available from: https://www.ncbi.nlm.nih.gov/books/NBK556062/
  5. Gephi — The Open Graph Viz Platform [Internet]. [cited 2023 Feb 20]. Available from: https://gephi.org/
  6. Social Media Research Foundation [Internet]. Social Media Research Foundation. [cited 2023 Feb 20]. Available from: https://www.smrfoundation.org/
  7. Digital Anthropology Daniel Miller [Internet]. 2017 [cited 2023 Feb 24]. Available from: https://www.youtube.com/watch?v=XNus-xZ7_6Y
  8. Emotion. In: Wikipedia [Internet]. 2023 [cited 2023 Feb 26]. Available from: https://en.wikipedia.org/w/index.php?title=Emotion&oldid=1140583773
  9. Hogan A, Blomqvist E, Cochez M, d’Amato C, d Melo G. Knowledge graphs [J]. Synthesis Lectures on Data Semantics and Knowledge. 2021.
  10. Janev V, Graux D, Jabeen H, Sallinger E. Knowledge graphs and big data processing. Springer Nature; 2020.
  11. Knowledge Graphs Book — Data Scientists [Internet]. Neo4j Graph Data Platform. [cited 2023 Feb 25]. Available from: https://neo4j.com/knowledge-graphs-data-in-context-for-responsive-businesses-data-scientists/

--

--

Dr. Veronica Espinoza

👨‍🎓 PhD Humanities 🧠M. Sc Neurobiology 🧪B.S. Chemistry. 👉 X: @Verukita1 😉 Support my work here: https://acortar.link/1ZonMU 🌐website: www.nethabitus.org