Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kyb3r/emergent
An implementation of long term memory and external tools for LLMs
https://github.com/kyb3r/emergent
Last synced: 7 days ago
JSON representation
An implementation of long term memory and external tools for LLMs
- Host: GitHub
- URL: https://github.com/kyb3r/emergent
- Owner: kyb3r
- License: mit
- Created: 2023-03-20T10:24:04.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-09T03:13:09.000Z (almost 2 years ago)
- Last Synced: 2024-12-30T01:42:02.364Z (9 days ago)
- Language: Python
- Homepage:
- Size: 156 KB
- Stars: 69
- Watchers: 5
- Forks: 7
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome_ai_agents - Emergent - An implementation of long term memory and external tools for LLMs (Building / Tools)
- awesome_ai_agents - Emergent - An implementation of long term memory and external tools for LLMs (Building / Tools)
README
# Emergent
Emergent is a library designed to enhance LLMs like GPT-4 by providing an easy way to integrate external tools and long-term memory capabilities. With Emergent, you can effortlessly transform any Python function into a tool that LLMs can utilize. The library also includes a built-in implementation of a long-term memory system called [HMCS](https://github.com/daveshap/HierarchicalMemoryConsolidationSystem) (WIP), which seeks to emulate human-like memory organization and recall.
https://user-images.githubusercontent.com/29310830/229719121-4d1dae6e-9282-4353-8d54-008bbc35f78e.MOV
# Usage
Making your own tools
```python
import emergent
from emergent import ChatAgent@emergent.tool()
def search(query):
"""This tool is useful for searching through the company's documents."""
...
return "Results: ..."
agent = ChatAgent(tools=[search])
agent.run()
```Using the long-term memory system
```python
from emergent import ChatAgent, HierarchicalMemorymemory = HierarchicalMemory.from_json("memories.json")
agent = ChatAgent(memory=memory)
agent.run()
```# Overview
The HMCS consists of several key components and processes:
1. Log-based memory: Records thoughts, inputs, and outputs as individual logs.
2. Rollup summaries: Periodically consolidates logs into higher-level summaries to reduce memory load.
3. KB articles: Organizes rollup summaries based on semantic similarity to create or update knowledge base (KB) articles.
4. Clustering or gating functions: Determines topical boundaries for efficient storage and retrieval of information.
5. Scalability: Adapts memory management to accommodate growing data volumes.
6. Periodic reindexing events: Optimizes memory by reorganizing and pruning the hierarchy as needed.## Note: This is a work in progress
This project tries to implement this system, here's the progress so far.
- [x] Log based memory
- [x] Rollup summaries
- [x] KB articles, automatically create or update existing KB articles
- [x] Clustering, or gating functions
- [ ] Scalability
- [ ] Periodic reindexing# Example conversation
I had a conversation with chatgpt earlier about two different topics. After that conversation. I saved the memory to a json file and wiped chatGPT's context window. When we started a new conversation, ChatGPT demonstrated its ability to recall pertinent details effectively.
```
You: Do you remember me David, I'm bobAgent: Yes, Bob. It's good to hear from you again. How can I assist you today?
You: Prove you remember me
Agent: Of course, Bob. We have interacted before, and based on the information I have in my memory, you are a 25-year-old resident of [redacted] with four siblings. Is there anything else I can help you with?
You: what is HMCS? Explain it to me
Agent: HMCS stands for Hierarchical Memory Consolidation System. It is a system that is being developed to improve the efficiency and effectiveness of large language models like ChatGPT. The system aims to mimic human-like memory organization and recall, enabling efficient storage and retrieval of information while adapting to growing data. The testing process is ongoing, and the user is monitoring the performance of ChatGPT with the implementation of HMCS.
You: Who's the user?
Agent: The user is you, Bob.
```
# Installation
```
pip install git+https://github.com/kyb3r/emergent
```or for development, clone the repository and then run
```
pip install -e .
```