# BaseMemory

> **Class** in `langchain_classic`

📖 [View in docs](https://reference.langchain.com/python/langchain-classic/base_memory/BaseMemory)

Abstract base class for memory in Chains.

Memory refers to state in Chains. Memory can be used to store information about
    past executions of a Chain and inject that information into the inputs of
    future executions of the Chain. For example, for conversational Chains Memory
    can be used to store conversations and automatically add them to future model
    prompts so that the model has the necessary context to respond coherently to
    the latest input.

## Signature

```python
BaseMemory()
```

## Description

**Example:**

```python
class SimpleMemory(BaseMemory):
    memories: dict[str, Any] = dict()

    @property
    def memory_variables(self) -> list[str]:
        return list(self.memories.keys())

    def load_memory_variables(self, inputs: dict[str, Any]) -> dict[str, str]:
        return self.memories

    def save_context(
        self, inputs: dict[str, Any], outputs: dict[str, str]
    ) -> None:
        pass

    def clear(self) -> None:
        pass
```

## Extends

- `Serializable`
- `ABC`

## Properties

- `model_config`
- `memory_variables`

## Methods

- [`load_memory_variables()`](https://reference.langchain.com/python/langchain-classic/base_memory/BaseMemory/load_memory_variables)
- [`aload_memory_variables()`](https://reference.langchain.com/python/langchain-classic/base_memory/BaseMemory/aload_memory_variables)
- [`save_context()`](https://reference.langchain.com/python/langchain-classic/base_memory/BaseMemory/save_context)
- [`asave_context()`](https://reference.langchain.com/python/langchain-classic/base_memory/BaseMemory/asave_context)
- [`clear()`](https://reference.langchain.com/python/langchain-classic/base_memory/BaseMemory/clear)
- [`aclear()`](https://reference.langchain.com/python/langchain-classic/base_memory/BaseMemory/aclear)

## ⚠️ Deprecated

Deprecated since version 0.3.3.

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/51e954877efd2d2c3c5bf09364dcfec8794eadb0/libs/langchain/langchain_classic/base_memory.py#L19)