jorgearango / llmapper

Use LLMs to draw concept maps from web pages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LLMapper

An experiment in using LLMs to draw simple concept maps. Currently, a simple bash script that uses Simon Willison's llm, strip-tags, and ttok tools to generate a PNG via Graphviz.

LLMapper is a crude prototype for refining the prompts. Which is to say, this isn't (yet) a serious tool; it's a toy for learning about generative AI.

It's very early days. Among other things, there's no error detection or graceful failures. Use at your own risk.

Requirements

The script runs in a bash shell. It's only been tested in macOS, but will likely work in Linux with minor changes.

Dependencies:

Except where noted, llm uses GPT-4 in this script. If you don't have access to the paid version of OpenAI's API, replace the model (-m) option on the llm calls.

Usage

Pass llmapper a Wikipedia URL. E.g.:

./llmapper https://en.wikipedia.org/wiki/The_Lord_of_the_Rings

Try running it several times. The map will be different each time.

Sample Output

A concept map of The Lord of the Rings

See more samples at modelor.ai.

How It Works

  1. curl retrieves the URL's content.
  2. strip-tags filters everything out except the div with the article's body.
  3. ttok truncates the article to 8,000 tokens
  4. llm summarizes the truncated article
  5. The summary is cleaned up and piped to an llm prompt that formats it as RDF.
  6. The RDF is passed to another llm that translates it to DOT code for rendering as a concept map in Graphviz.
  7. A sequence of calls to ImageMagick tools adds margins and the bottom caption.

About

Use LLMs to draw concept maps from web pages.

License:Apache License 2.0


Languages

Language:Shell 100.0%