Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update README #12

Merged
merged 5 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 39 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
# MemOnto 🧠

`memonto` (_memory + ontology_) adds memory to AI agents based on an user defined ontology. Define your own [RDF](https://www.w3.org/RDF/) ontology with [`rdflib`](https://github.com/RDFLib/rdflib) then have `memonto` automatically extract information that maps onto that ontology into a memory graph. The memories in the memory graph can be queried directly with `SPARQL` queries or contextually summarized.

```
┌─────────────────────────────┐ ┌──────────────────────┐ ┌───────────────────────────────────┐
│ Message │ │ LLM │ │ Memory Graph │
│ │ │ │ │ ... │
│ {Otto von Bismarck was a │ │ │ │ │ │
│ Prussian statesman and │ │ │ │ ┌───────────────▼───────────────┐ │
│ diplomat who oversaw the │ │ [Otto von Bismarck] │ │ │ Otto von Bismarck │ │
│ unification of Germany...} ┼──► │ │ └────────┬──────┬───────────────┘ │
│ │ │ is a [Person] who │ │ │ │ │
└─────────────────────────────┘ │ ┼──► livesAt│ │partOf │
┌─────────────────────────────┐ │ lives in a [Place] │ │ │ │ │
│ Ontology │ │ │ │ ┌────────▼┐┌────▼───────────────┐ │
│ ┼──► called [Prussia] │ │ │ Prussia ││ German Unification │ │
│ ┌─────────────┐ │ │ │ │ └─┬─────┬─┘└──────┬─────┬───────┘ │
│ │ Person │ │ │ and participated in │ │ │ │ │ │ │
│ └───┬─────┬───┘ │ │ │ │ ▼ ▼ ▼ ▼ │
│ │ │ │ │ an [Event] called │ │ ... ... ... ... │
│ livesAt│ │partOf │ │ │ └─────────────────┬─────────────────┘
│ │ │ │ │ [German Unification] │ │
│ ┌─────────▼─┐ ┌─▼─────────┐ │ │ │ ┌─────────────────▼─────────────────┐
│ │ Place │ │ Event │ │ │ │ │ │
│ └───────────┘ └───────────┘ │ │ │ │ SPARQL Queries / Memory Summaries │
│ │ │ │ │ │
└─────────────────────────────┘ └──────────────────────┘ └───────────────────────────────────┘
<p align="center">
<img src="https://memonto.s3.amazonaws.com/memonto-readme-banner.png" alt="logo"/>
</p>

`memonto` (_memory + ontology_) adds memory to AI agents based on custom defined ontology. Define your own [RDF](https://www.w3.org/RDF/) ontology with [`rdflib`](https://github.com/RDFLib/rdflib) then have `memonto` automatically extract information that maps onto that ontology into a memory graph. The memories in the memory graph can be queried directly with `SPARQL` queries or contextually summarized.

```
┌─────────────────────────────┐ ┌──────────────────────┐ ┌─────────────────────────────────┐
│ Message │ │ LLM │ │ Memory Graph │
│ │ │ │ │ ... │
│ {Otto von Bismarck was a │ │ │ │ │ │
│ Prussian statesman and │ │ │ │┌───────────────▼───────────────┐│
│ diplomat who oversaw the │ │ [Otto von Bismarck] │ ││ Otto von Bismarck ││
│ unification of Germany...} ┼─► │ │└────────┬──────┬───────────────┘│
│ │ │ is a [Person] who │ │ │ │ │
└─────────────────────────────┘ │ ┼─► livesAt│ │partOf │
┌─────────────────────────────┐ │ lives in a [Place] │ │ │ │ │
│ Ontology │ │ │ │┌────────▼┐┌────▼───────────────┐│
│ ┼─► called [Prussia] │ ││ Prussia ││ German Unification ││
│ ┌─────────────┐ │ │ │ │└─┬─────┬─┘└──────┬─────┬───────┘│
│ │ Person │ │ │ and participated in │ │ │ │ │ │ │
│ └───┬─────┬───┘ │ │ │ │ ▼ ▼ ▼ ▼ │
│ │ │ │ │ an [Event] called │ │ ... ... ... ... │
│ livesAt│ │partOf │ │ │ └─────────────────┬───────────────┘
│ │ │ │ │ [German Unification] │ │
│ ┌─────────▼─┐ ┌─▼─────────┐ │ │ │ ┌─────────────────▼───────────────┐
│ │ Place │ │ Event │ │ │ │ │ │
│ └───────────┘ └───────────┘ │ │ │ │ SPARQL Queries / Memory Summary │
│ │ │ │ │ │
└─────────────────────────────┘ └──────────────────────┘ └─────────────────────────────────┘
```

## 🚀 Install
Expand Down Expand Up @@ -55,6 +59,14 @@ g.bind("hist", HIST)
g.add((HIST.Person, RDF.type, RDFS.Class))
g.add((HIST.Event, RDF.type, RDFS.Class))
g.add((HIST.Place, RDF.type, RDFS.Class))

g.add((HIST.isFrom, RDF.type, RDF.Property))
g.add((HIST.isFrom, RDFS.domain, HIST.Person))
g.add((HIST.isFrom, RDFS.range, HIST.Place))

g.add((HIST.participatesIn, RDF.type, RDF.Property))
g.add((HIST.participatesIn, RDFS.domain, HIST.Person))
g.add((HIST.participatesIn, RDFS.range, HIST.Event))
```

**Configure LLM**
Expand Down Expand Up @@ -177,7 +189,7 @@ memonto = Memonto(

Extract the relevant information from a message that maps onto your ontology. It will only extract data that matches onto an entity in your ontology.
```python
memonto.retain("Otto von Bismarck was a Prussian statesman who oversaw the unification of Germany.")
memonto.retain("Otto von Bismarck was a Prussian statesman and diplomat who oversaw the unification of Germany.")
```

### Recall
Expand Down
87 changes: 1 addition & 86 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "memonto"
version = "0.1.0"
version = "0.2.0"
description = ""
authors = ["shihanwan <[email protected]>"]
readme = "README.md"
Expand All @@ -10,10 +10,8 @@ python = "^3.11"
pydantic = "^2.9.1"
rdflib = "^7.0.0"
openai = "^1.44.1"
python-dotenv = "^1.0.1"
graphviz = "^0.20.3"
black = "^24.8.0"
pre-commit = "^3.8.0"
tiktoken = "^0.7.0"
sparqlwrapper = "^2.0.0"
pytest = "^8.3.3"
Expand Down
Loading