Memoripy - A Python library for context-aware memory management in AI applications.
Memoripy is a Python library that provides context-aware memory management for AI applications. Memoripy supports both short-term and long-term memory storage and is compatible with the OpenAI and Ollama APIs. Core functionalities include memory retrieval, concept extraction, ...
What is Memoripy?
Memoripy is a Python library that provides context-aware memory management for AI applications. Memoripy supports both short-term and long-term memory storage and is compatible with the OpenAI and Ollama APIs. Core functionalities include memory retrieval, concept extraction, graph-based association, hierarchical clustering, and memory decay and reinforcement. Based on these functionalities, Memoripy helps AI systems better understand and respond to user interactions, improving the coherence and personalization of conversations.
Memoripy's main functions
- Short-term and long-term memory management: MemoryPy divides memories into short-term and long-term based on usage frequency and relevance, optimizing information storage and retrieval.
- Contextual Search: Analyze embedded vectors, concepts, and historical interactions; Memoripy retrieves past memories most relevant to the current interaction.
- Concept extraction and embedding generationBased on OpenAI and Ollam models, key concepts are extracted and corresponding embedding vectors are generated, which facilitates comparison and retrieval for easy memorization.
- Graph base association: Construct a concept graph and realize relevance-based memory retrieval based on the propagation activation mechanism.
- Hierarchical clusteringClustering similar memories based on semantic similarity facilitates context-dependent retrieval.
- Memory decay and enhancement: Memoryipy enables dynamic memory management, allowing infrequently accessed memories to gradually decay, while frequently accessed memories are strengthened.
Memoripy's technical principles
- Memory storageMemoripy uses two storage methods: in-memory storage and JSON file storage to save interactive data.
- Embedded technologyUsing natural language processing techniques, Memoripy converts text into embedded vectors. These vectors capture the semantic information of the text, making it easier to compare and retrieve.
- Similarity SearchUsing algorithms such as cosine similarity, we find the historical memory most similar to the current interaction based on the embedding vector.
- Concept MapConstruct a graph where nodes represent concepts and edges represent relationships between concepts, and use graph algorithms to retrieve complex relationships.
- Clustering AlgorithmClustering techniques are used to group similar memories together, improving retrieval efficiency and relevance.
Memoripy's project address
- GitHub repository:https://github.com/caspianmoon/memoripy
Application scenarios of Memoripy
- ChatbotIn customer service and online chat applications, help chatbots remember users' historical interactions to provide a more personalized and coherent conversational experience.
- Virtual AssistantIn personal assistant applications, storing user preferences and habits allows virtual assistants to provide more personalized services based on the user's historical behavior.
- Educational softwareIn educational applications, it tracks students' learning progress and preferences, providing customized learning content and suggestions.
- Recommendation systemOn e-commerce or content recommendation platforms, analyze users' historical interactions and preferences to provide more accurate personalized recommendations.
- Health monitoringIn health and fitness apps, users' activity and health data are recorded to help them track progress and adjust their health plans.