Repository navigation
v1.1.2
Release v1.1.2 - Performance Optimization and Memory Efficiency
We are thrilled to announce the release of version 1.1.2 of the shortterm-memory package. This update focuses on optimizing performance, enhancing memory management, and improving overall efficiency.
Main Updates
1. Advanced Memory Management Enhancements
-
GPU Acceleration:
Added automatic GPU support using PyTorch, significantly improving summarization performance when a CUDA device is available. -
Batch Processing for Memory Compression:
Introduced batch processing (default batch size: 5) for more efficient handling of conversation history during summarization, reducing latency. -
Optimized Memory Counter:
Enhanced the memory counter to use token-based counting instead of word-based, improving accuracy and performance.
2. Efficient Conversation History Handling
-
Optimized Update Memory Method:
Theupdate_memorymethod has been refactored for better performance, including dynamic compression and automatic trimming of older conversations. -
Dynamic Compression Threshold:
Compression is now triggered based on the token count rather than word count, providing more precise control over memory usage.
3. Integration with Transformers
-
Enhanced Summarization:
Improved summarization using BART with optimized parameters for faster and more concise summaries. -
Efficient Tokenization:
Direct use of tokenization for both counting and summarization, reducing redundant operations.
4. Error Handling and Logging
-
Improved Logging:
Enhanced logging features to provide detailed insights into memory operations, including compression and trimming events. -
Error Handling:
Added robust error handling to manage issues during summarization and memory updates gracefully.
Usage Example
import torch
from transformers import pipeline
import logging
from shortterm_memory.ChatbotMemory import ChatbotMemory
# Initialize Chatbot Memory
chat_memory = ChatbotMemory()
# Example of updating the memory with user input and bot response
user_input = "Hello, how are you?"
bot_response = "I'm fine, thank you! How about you?"
chat_memory.update_memory(user_input, bot_response)
# Retrieve the updated conversation history
history = chat_memory.get_memory()
print(history)How to Upgrade
To upgrade to this latest version, run the following command:
pip install --upgrade shortterm-memory