### Initialize and Use StructMem Source: https://github.com/zjunlp/lightmem/blob/main/StructMem.md Quick start example for initializing LightMemory with StructMem configurations, adding memories with event extraction, and generating summaries. ```python from lightmem.memory.lightmem import LightMemory # Configure StructMem config = { # ... base LightMem configs ... # StructMem-specific settings "extraction_mode": "event", "summary_retriever": { "model_name": "qdrant", "configs": { "collection_name": "my_summaries", "embedding_model_dims": 384, "path": "./my_summaries", } }, # ... other configs ... } # Initialize lightmem = LightMemory.from_config(config) # Add memories with event extraction, providing both factual and relational prompts. lightmem.add_memory( messages=turn_messages, METADATA_GENERATE_PROMPT={ "factual": LoCoMo_Event_Binding_factual, "relational": LoCoMo_Event_Binding_relational }, force_segment=True, force_extract=True ) # Generate cross-event summaries lightmem.summarize( retrieval_scope="global", time_window=3600, top_k=15, process_all=True ) ``` -------------------------------- ### Install LightMem from Source Source: https://github.com/zjunlp/lightmem/blob/main/README.md Clone the repository, create a virtual environment, and install dependencies using pip. ```bash git clone https://github.com/zjunlp/LightMem.git cd LightMem conda create -n lightmem python=3.11 -y conda activate lightmem unset ALL_PROXY pip install -e . ``` -------------------------------- ### API Call Prompt Example Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_code.ipynb Shows an example of a user prompt for an API call, including historical context and file system information. This is used to guide the AI in generating relevant responses or actions. ```text Output: User prompt for API call 0: --- Topic 1 --- [2025-12-02T17:06:00.000, Tue] 0.User: Output total 192 - rw - rw - r - 1 user user 387 12 1 17 : 06 build - alpine. sh - rw - rw - r - user user 96220 12 1 17 : 06 CHANGELOG. md - rw - rw - r - user user 263 12 1 17 : 06 CITATION. cff - rw - rw - r - user user 2273 12 1 17 : 06 CONTRIBUTING. rst - rw - rw - r - user user 265 12 1 : 06 dev - requirements. txt drwxrwxr - 6 user user 4096 12 docs drwxrwxr - 7 user user 4096 faker - rw - rw - r - user user 9320 12 generate _ stubs. py - rw - rw - r - user 1060 12 1 LICENSE. txt - rw - rw - r - user user 410 12 1 Makefile - rw - rw - r - user user 661 12 1 MANIFEST. in - rw - rw - r - user user 295 12 1 mypy. ini - rw - rw - r - user user 14189 12 1 README. rst - rw - rw - r - user user 161 12 1 readthedocs. yml - rw - rw - r - user user 815 12 1 : RELEASE _ PROCESS. rst - rw - rw - r - user user 182 12 1 setup. cfg - rw - rw - r - user user 2543 12 1 setup. py drwxrwxr - 7 user user 4096 12 tests - rw - rw - r - user user 1416 12 1 : tox. ini - rw - rw - r - user user 0 12 1 : 06 untitledtxt - rw - r 1 user user 7 12 1 17 : 06 VERSION [2025-12-02T17:06:00.500, Tue] 0.Assistant: Command : cat / disk disk _ 20T user GitTaskBench code _ base Faker / README. ``` -------------------------------- ### Setup Environment for FullContext Source: https://github.com/zjunlp/lightmem/blob/main/src/lightmem/memory_toolkits/readme.md Installs dependencies for the FullContext baseline. It involves creating and activating a conda environment named 'fullcontext_env' and then running pip install. ```bash conda create -n fullcontext_env python=3.12 -y && conda activate fullcontext_env pip install -r envs/fullcontext_requirements.txt ``` -------------------------------- ### Installing Eparse from Source Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_code.ipynb These commands show how to clone the eparse repository and install it from source. This is useful for development or when the latest version is needed. ```bash $ pip install eparse ``` ```bash $ pip install. ``` ```bash $ cd eparse ``` ```bash $ git clone https://github.com/ChrisPappalardo/eparse.git ``` -------------------------------- ### Install LightMem and Dependencies Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_longmemeval.ipynb This snippet shows the pip installation command for LightMem and its required NVIDIA CUDA components. It highlights the use of cached wheels for faster installation and lists the various CUDA libraries being installed. ```bash pip install lightmem ``` -------------------------------- ### Successful Package Installation Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_code.ipynb This output confirms the successful building and installation of the 'lightmem' package in editable mode. It also lists all the collected packages that were installed or are already satisfied. ```bash Building wheels for collected packages: lightmem Building editable for lightmem (pyproject.toml) ... [?25ldone Created wheel for lightmem: filename=lightmem-0.1.0-0.editable-py3-none-any.whl size=11716 sha256=b8bc5212fe5403e20a1808f7f1f0b7db4990d50b8699794f24852a5fa211cdd2 Stored in directory: /tmp/pip-ephem-wheel-cache-nmptuqgp/wheels/6e/78/3e/ad25a8ed5245b53409d8ea7f1a62638ba248b738ed4cf419a3 Successfully built lightmem Installing collected packages: nvidia-cusparselt-cu12, mpmath, urllib3, typing-inspection, triton, tqdm, threadpoolctl, sympy, sniffio, safetensors, regex, pydantic_core, psutil, protobuf, portalocker, pillow, nvidia-nvtx-cu12, nvidia-nvjitlink-cu12, nvidia-nccl-cu12, nvidia-curand-cu12, nvidia-cufile-cu12, nvidia-cuda-runtime-cu12, nvidia-cuda-nvrtc-cu12, nvidia-cuda-cupti-cu12, nvidia-cublas-cu12, numpy, networkx, joblib, jiter, idna, hyperframe, hpack, hf-xet, grpcio, fsspec, filelock, distro, click, charset-normalizer, certifi, annotated-types, scipy, pydantic, nvidia-cusparse-cu12, nvidia-cufft-cu12, nvidia-cudnn-cu12, nltk, h2, anyio, tiktoken, scikit-learn, nvidia-cusolver-cu12, huggingface-hub, torch, tokenizers, openai, transformers, qdrant-client, accelerate, sentence-transformers, llmlingua, lightmem ``` -------------------------------- ### MCP Client Configuration Example Source: https://github.com/zjunlp/lightmem/blob/main/README.md An example JSON configuration for an MCP client to connect to the LightMem MCP server. It specifies the server URL and other potential parameters. ```json { "yourMcpServers": { "LightMem": { "url": "http://127.0.0.1:8000/mcp", "otherParameters": "..." } } } ``` -------------------------------- ### Set Project Path and Install LightMem Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_travel.ipynb Configures the LightMemory project path and installs the library in editable mode. Ensure the LIGHTMEM_PROJECT_PATH is set correctly before running. ```python # Set your LightMemory project path LIGHTMEM_PROJECT_PATH = '/disk/disk_20T/xubuqiang/lightmem' # Install in editable mode %cd {LIGHTMEM_PROJECT_PATH} %env ALL_PROXY= !pip install -e . %cd tutorial-notebooks ``` -------------------------------- ### Example Output of Runtime Configuration Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_longmemeval.ipynb Illustrates the expected output after running the configuration script, showing the generated log directory and the path to the dataset file. ```text Output: RUN_LOG_DIR: ./logs/20251206_202021 DATA_FILE_PATH: /disk/disk_20T/xubuqiang/lightmem/dataset/longmemeval/longmemeval_single.json ``` -------------------------------- ### Setup EgoLife Experiment Environment Source: https://github.com/zjunlp/lightmem/blob/main/EM2Mem.md Navigate to the EgoLife experiment directory and set up the virtual environment. This command skips data download. ```bash cd experiments/egolife bash scripts/1_setup.sh --skip-data source .venv/bin/activate ``` -------------------------------- ### Installing LightMem and Dependencies Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_code.ipynb This snippet shows the pip installation process for LightMem and its required NVIDIA CUDA components. It includes various CUDA toolkit versions and libraries like triton and torch. ```bash pip install lightmem==0.1.0 ``` -------------------------------- ### Install FluxMem Extras Source: https://github.com/zjunlp/lightmem/blob/main/FluxMem.md Install the optional FluxMem extras from the LightMem project root. This command should be run within the LightMem environment. ```bash pip install -e ".[fluxmem]" ``` -------------------------------- ### Setup Environment for A-MEM Source: https://github.com/zjunlp/lightmem/blob/main/src/lightmem/memory_toolkits/readme.md Create a new conda environment named 'amem_env', activate it, and install dependencies using the provided requirements file. This is recommended for avoiding dependency conflicts. ```bash conda create -n amem_env python=3.12 -y conda activate amem_env pip install -r envs/amem_requirements.txt ``` -------------------------------- ### Setup Environment for NaiveRAG Source: https://github.com/zjunlp/lightmem/blob/main/src/lightmem/memory_toolkits/readme.md Sets up the environment for the NaiveRAG baseline by creating a conda environment 'rag_env', activating it, and installing necessary packages using pip. ```bash conda create -n rag_env python=3.12 -y && conda activate rag_env pip install -r envs/rag_requirements.txt ``` -------------------------------- ### Install LightMem via Pip Source: https://github.com/zjunlp/lightmem/blob/main/README.md Install the LightMem package using pip. This option is coming soon. ```bash pip install lightmem # Coming soon ``` -------------------------------- ### Install vLLM for Local Models Source: https://github.com/zjunlp/lightmem/blob/main/src/lightmem/memory_toolkits/readme.md Install vLLM if you intend to use local models for LLM-as-a-Judge. ```bash pip install vllm ``` -------------------------------- ### Output Log Example Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_longmemeval.ipynb Shows the output log indicating the successful generation of segments and the start of adding new turns to memory. This log provides insights into the system's operational status. ```text Output: 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202308_798026] Generated 5 segments Adding turns: 4%|▍ | 12/273 [00:01<00:30, 8.62it/s]2025-12-06 20:23:09 - LightMemory - INFO - ========== START add_memory_20251206_202309_260341 ========== 2025-12-06 20:23:09 - LightMemory - INFO - force_segment=False, force_extract=False 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_260341] Extracted 0 visual contexts 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_260341] Restored visual contexts after compression 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_260341] Target compression rate: 0.8 2025-12-06 20:23:09 - LightMemory - INFO - ========== START add_memory_20251206_202309_308900 ========== 2025-12-06 20:23:09 - LightMemory - INFO - force_segment=False, force_extract=False 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_308900] Extracted 0 visual contexts 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_308900] Restored visual contexts after compression 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_308900] Target compression rate: 0.8 2025-12-06 20:23:09 - LightMemory - INFO - ========== START add_memory_20251206_202309_346395 ========== 2025-12-06 20:23:09 - LightMemory - INFO - force_segment=False, force_extract=False 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_346395] Extracted 0 visual contexts 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_346395] Restored visual contexts after compression 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_346395] Target compression rate: 0.8 Adding turns: 5%|▌ | 15/273 [00:01<00:22, 11.22it/s]2025-12-06 20:23:09 - LightMemory - INFO - ========== START add_memory_20251206_202309_386960 ========== 2025-12-06 20:23:09 - LightMemory - INFO - force_segment=False, force_extract=False 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_386960] Extracted 0 visual contexts 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_386960] Restored visual contexts after compression 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_386960] Target compression rate: 0.8 2025-12-06 20:23:09 - LightMemory - INFO - ========== START add_memory_20251206_202309_425047 ========== 2025-12-06 20:23:09 - LightMemory - INFO - force_segment=False, force_extract=False 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_425047] Extracted 0 visual contexts 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_425047] Restored visual contexts after compression 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_425047] Target compression rate: 0.8 2025-12-06 20:23:09 - LightMemory - INFO - ========== START add_memory_20251206_202309_454857 ========== 2025-12-06 20:23:09 - LightMemory - INFO - force_segment=False, force_extract=False 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_454857] Extracted 0 visual contexts 2025-12-06 20:23:09 - LightMemory - INFO - [add_memory_20251206_202309_454857] Restored visual contexts after compression ``` -------------------------------- ### Setup Environment for MemZero / MemZeroGraph Source: https://github.com/zjunlp/lightmem/blob/main/src/lightmem/memory_toolkits/readme.md Isolate MemZero and MemZeroGraph dependencies by creating a dedicated conda environment named 'memzero_env', activating it, and installing required packages via pip. ```bash conda create -n memzero_env python=3.12 -y conda activate memzero_env pip install -r envs/mem0_requirements.txt ``` -------------------------------- ### Start MCP Server with HTTP Source: https://github.com/zjunlp/lightmem/blob/main/README.md Starts the Model Context Protocol (MCP) server using HTTP transport on port 8000. This allows LightMem to be accessed as an MCP service. ```bash # Running at Root Directory cd LightMem # Environment pip install '.[mcp]' # MCP Inspector [Optional] npx @modelcontextprotocol/inspector python mcp/server.py # Start API by HTTP (http://127.0.0.1:8000/mcp) fastmcp run mcp/server.py:mcp --transport http --port 8000 ``` -------------------------------- ### Programmatic Use of FluxMemAgent Source: https://github.com/zjunlp/lightmem/blob/main/FluxMem.md Demonstrates how to initialize and use FluxMemAgent for adding knowledge, running tasks with retrieval and refinement, and performing offline consolidation. Ensure optional dependencies are installed. ```python import asyncio from fluxmem import FluxMemAgent, FluxMemConfig, OpenAILLM, OpenAIEmbedder async def main(): # 1. Initialize the agent config = FluxMemConfig(top_k_semantic=3, top_k_episodic=2) llm = OpenAILLM(model="gpt-4o-mini") embedder = OpenAIEmbedder() agent = FluxMemAgent(llm=llm, embedder=embedder, config=config) # 2. Add knowledge into the semantic layer await agent.add_knowledge("Your fact documents here...", source="docs") # 3. Execute a task with Stage I retrieval and Stage II refinement async def execute_fn(context: str): result = do_something(context) return (result, feedback, success) result = await agent.run_task( task_query="Your task description", execute_fn=execute_fn, observations=["Initial observation"], ) # 4. Offline Stage III consolidation consolidation = await agent.consolidate() print(consolidation) asyncio.run(main()) ``` -------------------------------- ### LightMem Add Memory Start Log Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_code.ipynb Log indicating the start of a new add_memory operation. ```log 2025-12-06 19:13:43 - LightMemory - INFO - ========== START add_memory_20251206_191343_792780 ========== 2025-12-06 19:13:43 - LightMemory - INFO - force_segment=False, force_extract=False ``` -------------------------------- ### Environment Variable Setup for MiniGC Source: https://github.com/zjunlp/lightmem/blob/main/src/em2mem/embedding/VLM2Vec/src/grad_cache/minigc_cmd.md Sets up necessary environment variables for running MiniGC, including paths to executables, cache directories, and Weights & Biases configuration. ```bash ENV_PATH=/export/share/ruimeng/env/anaconda/envs/llm/bin/ninja export PATH="${ENV_PATH}/:$PATH" export NCCL_DEBUG=WARN export HF_DATASETS_CACHE=/export/xgen-embedding/data/.hfdata_cache export TRANSFORMERS_CACHE=/export/xgen-embedding/data/.hfmodel_cache/ export TOKENIZERS_PARALLELISM=true export WANDB_DISABLED=false export WANDB_PROJECT=mini-gradcache export WANDB_API_KEY=local-d64a4127e8d4a1782aedbb72e76080b3dfbf89dd export WANDB_BASE_URL=https://salesforceairesearch.wandb.io ``` -------------------------------- ### LightMem API Call User Prompt Example Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_code.ipynb Example of a user prompt generated for an API call, including conversation history and context, formatted for a specific topic. ```text User prompt for API call 0: --- Topic 2 --- [2025-12-02T17:06:00.000, Tue] 0.User: Output : * Faker * is a Python package generates fake data for you. need to bootstrap your database, create good - looking XML documents, fill - in your persistence to stress test it, or anonymize data from production service, Faker is for you. Faker is heavily inspired by PHP Faker _, Perl Faker _, and by Ruby Faker _. - - - - : : _ | _ | _ | _ | _ | _ | _ | _ | _ | _ | _ | _ | _ | _ | _ | _ _ _ _ _ | | _ | _ | _ _ | _ | _ _ _ _ | _ | _ | _ | _ | _ | | pypi | | build | | coverage | | license | - Compatibility - Starting from version 4. 0. 0, Faker dropped support for Python 2 and from version 5. 0. 0 only supports Python 3. 8 and above. If still need Python 2 compatibility, install version 3. 0. 1 in, consider updating codebase to support Python 3 can enjoy latest features Faker has to offer. see extended docs _ for more details, especially if upgrading from version 2. 0. 4 and below might be breaking changes. This package was also previously called fake - factory already deprecated by end of 2016, and much has changed since then, ensure your project and dependencies do not depend on old package. Basic Usage - - - Install with pip :.. code : : bash pip install Faker Use faker. Faker ( ) to create and initialize a faker generator, can generate data by accessing properties named after type of data you want..code : python from faker import Faker fake = Faker ( fake. name ( # Lucy Cechtelar ' fake. address ( 426 Jordy Lodge Cartwrightshire SC 88120 - 6700 ' fake. text ( Sint velit eveniet. Rerum repellat voluptatem rerum excepturi beatae sint laudantium consequatur Magni occaecati sint sit tempore. Nesciunt # a. ( truncated [2025-12-02T17:06:00.500, Tue] 0.Assistant: Command : pip install - r disk disk _ 20T user GitTaskBench code _ base Faker / dev - requirements. ``` -------------------------------- ### API Call Prompt Example Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_code.ipynb An example of a user prompt generated for an API call, including topic information and file system details. This is used for context in memory operations. ```text Output: User prompt for API call 0: --- Topic 6 --- [2025-12-03T15:01:00.000, Wed] 0.User: Output total 192 - rw - rw - r - 1 user user 387 12 1 17 : 06 build - alpine. sh - rw - rw - r - user user 96220 12 1 17 : 06 CHANGELOG. md - rw - rw - r - user user 263 12 1 17 : 06 CITATION. cff - rw - rw - r - user user 2273 12 1 17 : 06 CONTRIBUTING. rst - rw - rw - r - user user 265 12 1 : 06 dev - requirements. txt drwxrwxr - 6 user user 4096 12 docs drwxrwxr - 7 user user 4096 faker - rw - rw - r - user user 9320 12 generate _ stubs. py - rw - rw - r - user 1060 12 1 LICENSE. txt - rw - rw - r - user user 410 12 1 Makefile - rw - rw - r - user user 661 12 1 MANIFEST. in - rw - rw - r - user user 295 12 1 mypy. ini - rw - rw - r - user user 14189 12 1 README. rst - rw - rw - r - user user 161 12 1 readthedocs. yml - rw - rw - r - user user 815 12 1 : RELEASE _ PROCESS. rst - rw - rw - r - user user 182 12 1 setup. cfg - rw - rw - r - user user 2543 12 1 setup. py drwxrwxr - 7 user user 4096 12 tests - rw - rw - r - user user 1416 12 1 : tox. ini - rw - rw - r - user user 0 12 1 : 06 untitledtxt - rw - r 1 user user 7 12 1 17 : 06 VERSION [2025-12-03T15:01:00.500, Wed] 0.Assistant: Command : cat / disk disk _ 20T user GitTaskBench code _ base Faker / README. ``` -------------------------------- ### API Call Example for Memory Addition Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_code.ipynb This snippet shows an example API call made during memory addition, including the prompt and completion tokens used. It also logs the completion of metadata generation and the creation of MemoryEntry objects. ```python 2025-12-06 19:13:54 - LightMemory - INFO - [add_memory_20251206_191350_114036] API Call 0 tokens - Prompt: 1418, Completion: 308, Total: 1726 2025-12-06 19:13:54 - LightMemory - INFO - [add_memory_20251206_191350_114036] Metadata generation completed with 1 API calls 2025-12-06 19:13:54 - LightMemory - INFO - [add_memory_20251206_191350_114036] Created 4 MemoryEntry objects ``` -------------------------------- ### Setup logging and configuration Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_code.ipynb Configures the logging directory based on the current timestamp and sets API keys, base URLs, and model paths for LLM and embedding models. It also defines the data file path. ```python # logging setup LOGS_ROOT = "./logs" RUN_TIMESTAMP = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") RUN_LOG_DIR = os.path.join(LOGS_ROOT, RUN_TIMESTAMP) os.makedirs(RUN_LOG_DIR, exist_ok=True) # API API_KEY = '' API_BASE_URL = '' LLM_MODEL = 'gpt-4o-mini' LLMLINGUA_MODEL_PATH = '/models/llmlingua-2-bert-base-multilingual-cased-meetingbank' EMBEDDING_MODEL_PATH = '/models/all-MiniLM-L6-v2' DATA_FILE_PATH = '/code_single.json' print(f"RUN_LOG_DIR: {RUN_LOG_DIR}") print(f"DATA_FILE_PATH: {DATA_FILE_PATH}") ``` -------------------------------- ### API Config File Format Source: https://github.com/zjunlp/lightmem/blob/main/src/lightmem/memory_toolkits/readme.md Example JSON structure for configuring API keys and base URLs for external model access. ```json { "api_keys": [ "sk-your-api-key-1", "sk-your-api-key-2" ], "base_urls": [ "https://api.openai.com/v1", "https://api.openai.com/v1" ] } ``` -------------------------------- ### Uninstalling Existing Packages Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_code.ipynb This output shows the process of uninstalling older versions of packages like 'urllib3' and 'psutil' to resolve potential conflicts during the installation of new versions required by LightMem. ```bash [2K Attempting uninstall: urllib3━━━━━━━━━━━━━━━━━━━━━━━━━━ [0m [32m 1/62 [0m [mpmath]t-cu12] [2K Found existing installation: urllib3 2.6.0━━━━━━━ [0m [32m 1/62 [0m [mpmath] [2K Uninstalling urllib3-2.6.0:━━━━━━━━━━━━━━━━━━━━━━ [0m [32m 1/62 [0m [mpmath] [2K Successfully uninstalled urllib3-2.6.0━━━━━━━━━ [0m [32m 1/62 [0m [mpmath] [2K Attempting uninstall: psutil[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [0m [32m11/62 [0m [pydantic_core]ion] [2K Found existing installation: psutil 7.1.3━━━━━━━━━━━━━━━━━ [0m [32m11/62 [0m [pydantic_core] ``` -------------------------------- ### User Prompt and Assistant Command Example Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_code.ipynb This snippet displays a user prompt related to an OSError during a file save operation and the subsequent assistant command to create a directory. It highlights a typical interaction flow involving error handling and system commands. ```text User prompt for API call 0: --- Topic 8 --- [2025-12-03T15:01:00.000, Wed] 0.User: Output OSError Traceback recent call last Cell In [ 1 ] line 23 20 output file path = ' disk / disk _ 20T user GitTaskBench prompt / Faker _ 02 output. csv ' 22 Save to CSV > 23 df. to csv ( output file path index = False File disk / disk _ 20T user / anaconda3 envs gittaskbench lib / python3. 12 site - packages pandas / util / decorators. py : 333 deprecate nonkeyword arguments locals > decorate locals wrapper ( * args, kwargs ) 327 if len ( args ) > num allow args : 328 warnings. warn ( 329 msg. format ( arguments = format argument list allow args ) ) 330 FutureWarning 331 stacklevel = find _ stack _ level ( ) 332 ) - > 333 return func ( * args, kwargs ) File disk / disk _ 20T user anaconda3 envs gittaskbench lib / python3. 12 site - packages / pandas / core / generic. py : 3967 NDFrameto _ csv ( self path buf sep na rep float format columns header index index label mode encoding compression quoting quotechar lineterminator chunksize date _ format doublequote escapechar decimal errors storage options 3956 df = self isinstance self ABCDataFrame self frame 3958 formatter = DataFrameFormatter 3959 frame = df 3964 decimal = decimal 3965 - > 3967 return DataFrameRenderer formatter to _ csv 3968 path _ buf 3969 lineterminator = 3970 sep = sep 3971 encoding 3972 errors = errors 3973 compression = compression 3974 quoting = quoting 3975 columns = columns 3976 index _ label = index 3977 mode = mode 3978 chunksize = 3979 quotechar = quotechar 3980 date _ format = date _ format 3981 doublequote 3982 escapechar = escapechar 3983 storage options = storage options 3984 File / disk / disk _ 20T / user... ( [2025-12-03T15:01:00.500, Wed] 0.Assistant: Command mkdir - p disk disk _ 20T user / GitTaskBench prompt / Faker _ ``` -------------------------------- ### User Prompt for API Call Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_longmemeval.ipynb Example of a user prompt used for an API call within the LightMem system, detailing a travel planning conversation. ```text User prompt for API call 0: --- Topic 16 --- [2023-05-21T22:48:00.000, Sun] 0.User: I ' m thinking of planning a trip to Europe, possibly to Italy or Spain wondering if could recommend some popular destinations and itineraries. By way starting to plan a road trip with friends to Pacific Coast Highway in California today, ' m in full travel planning mode [2023-05-21T22:48:01.000, Sun] 1.User: I ' thinking of 7 - 10 day trip to Europe, open to renting a car or using public transportation, depending on itinerary. interested in history, culture, and trying local food and drinks [2023-05-21T22:48:02.000, Sun] 2.User: think leaning towards Italy option, probably Tuscany and Umbria food and wine adventure. always fascinated by rolling hills and medieval towns of Tuscany d love to try some local wines and dishes. What are some must - try foods and drinks in Tuscany and Umbria [2023-05-21T22:48:03.000, Sun] 3.User: some must - visit wineries vineyards in Tuscany Umbria I should consider adding to my itinerary [2023-05-21T22:48:04.000, Sun] 4.User: think ll add Castello di Brolio and Cantina Fratelli Pardi to my itinerary both seem like great options for wine tastings tours. interested in visiting local olive oil producers to learn more about production process taste region ' s best olive oils. recommend any olive oil producers or farms in Tuscany and Umbria I should visit [2023-05-21T22:48:05.000, Sun] 5.User: like to visit Fattoria La Vialla Frantoio di Siena in Tuscany Frantoio Oleificio dell ' Umbria in Umbria seem like great options for learning about production process tasting region ' s best olive oils ``` -------------------------------- ### LightMem Output: Adding Sessions Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_longmemeval.ipynb This output shows the initial messages printed when starting the process of adding historical sessions to the LightMemory repository, including the conversion of timestamps. ```text Starting to add historical sessions to memory repository... Converting timestamps to standard format... ``` -------------------------------- ### User Prompt for API Call Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_longmemeval.ipynb Example of a user prompt structured for an API call, including conversation history and topic segmentation. ```text Output: User prompt for API call 0: --- --- Topic 21 --- [2023-05-22T14:27:00.000, Mon] 0.User: ' m looking for some sports news updates. By way World Series ended, was rooting for Astros all. ' m still on a high from their win! Can you give me some analysis on their performance this season [2023-05-22T14:27:01.000, Mon] 1.User: Yeah, it amazing! favorite moment probably when Jose Altuve hit walk - off homer in Game 2 watching it with my dad, we both went nuts [2023-05-22T14:27:02.000, Mon] 2.User: Yeah, I must ' ve gotten that wrong. Anyway, that ' s okay, ' m still on cloud nine! Speaking of sports also been following NBA season impressed by Luka Doncic ' s performance far. Can you give me updates on his stats and how Mavericks doing [2023-05-22T14:27:03.000, Mon] 3.User: think he ' s a top contender, but ' s still early in season. d like to see him keep up this pace for few more months before making bold predictions. What do think about Mavericks ' chances of making deep playoff run [2023-05-22T14:27:04.000, Mon] 4.User: think they need to find way improve three - point shooting consistency They ' ve had some games where they ' ve shot well from beyond arc, but others where struggled. If they can find way to be more consistent from three ll open up floor for Luka to operate make them tougher team to defend [2023-05-22T14:27:05.000, Mon] 5.User: I think ' s a great idea. Adding reliable three - point shooter or playmaker could take their offense to next level. Someone can stretch floor and create their own shot great asset, especially if can play off Luka ' s strengths. Mavericks have flexibility with their roster, s possible they could make a move to address their needs. could look to trade for a player like, Bogdan Bogdanovic or Mikal Bridges, both capable shooters and playmakers. Alternatively could try to sign a free agent like Kyle Korver or JJ Redick, both seasoned shooters with playoff experience. Either way adding a piece like could make big difference in their playoff push. By you been following English Premier League? been trying to catch up on Manchester City ' s games, they re looking strong this season --- --- Topic 22 --- [2023-05-22T14:37:00.000, Mon] 6.User: looking for advice on how to properly wash my Nike Dri - FIT running socks to get rid of smell. been using them for about 6 months now they ' ve been great, but been using them non - stop for my morning jogs in new Asics Gel - Kayano shoes got last month ``` -------------------------------- ### API Call Prompt Generation Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_longmemeval.ipynb Example of a user prompt generated for an API call, including conversational history and specific details like dates and podcast references. ```python Output: User prompt for API call 0: --- Topic 10 --- [2023-05-20T15:03:00.000, Sat] 0.User: ' ve been thinking about starting my own business wondering if could recommend some inspiring podcasts about entrepreneurship, aside from " How I Built This " been listening to for months now. By finished listening to a true crime podcast my sister recommended to me on January 15th, got me thinking about how important is to take risks pursue my passions [2023-05-20T15:03:01.000, Sat] 1.User: That ' s great list! ' ll check some those out. particularly interested in " The Tim Ferriss Show " since already been listening to it on and off for past few months. Can you tell me more about episode with Naval Ravikant? remember listening to it on December 20th made me think about my own goals and priorities [2023-05-20T15:03:02.000, Sat] 2.User: ' been listening to " The Daily " from The New York Times almost every day love how it keeps me up - to - date on what ' s happening in world. remember listening to episode about COVID - 19 vaccine rollout on February 10th helped me to understand complex issues surrounding [2023-05-20T15:03:03.000, Sat] 3.User: been listening to comedy podcasts like " My Brother, My Brother and Me " " improv4humans " They always make me laugh, they ' re great for when need break from more serious topics [2023-05-20T15:03:04.000, Sat] 4.User: remember listening to episode of " My Brother, My Brother and Me " on January 25th, had me giggling out loud on bus brothers ' humor so infectious [2023-05-20T15:03:05.000, Sat] 5.User: think it combination of their silly jokes and ridiculous advice had me laughing out loud. They answering a question about how to deal with noisy neighbor, their suggestions were over - the - top absurd I couldn ' t help but crack up. one of moments I trying to stifle my laughter so wouldn ' t disturb other people on bus, but couldn ' t help it [2023-05-20T20:47:00.000, Sat] 6.User: ' m looking for some recommendations on pet grooming tools been using a Furminator brush on Luna, but wondering if other products could help with her shedding. By way, I recently got her a new pet bed from Petco, it was originally $ 40, but really happy with the purchase [2023-05-20T20:47:01.000, Sat] 7.User: looking for recommendations for both Luna and Max. Max is a 5 - year - old golden retriever, Luna is a cat. been giving Luna Omega - 3 supplements to help with her skin and coat health open to trying out new products can complement those supplements ``` -------------------------------- ### Offline Update Initialization Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_longmemeval.ipynb This snippet illustrates the start of an offline update process, showing the number of memory entries received and the initial status of update queue and offline update triggers. ```python 2025-12-06 20:23:19 - LightMemory - INFO - ========== START offline_update_20251206_202319_929684 ========== 2025-12-06 20:23:19 - LightMemory - INFO - [offline_update_20251206_202319_929684] Received 12 memory entries 2025-12-06 20:23:19 - LightMemory - INFO - [offline_update_20251206_202319_929684] construct_update_queue_trigger=False, offline_update_trigger=False 2025-12-06 20:23:19 - LightMemory - INFO - [offline_update_20251206_202319_929684] Starting embedding and insertion to vector database ``` -------------------------------- ### Logging Memory Addition in LightMem Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_longmemeval.ipynb This snippet shows the informational logs generated during the process of adding memory to LightMem. It includes details about extracted visual contexts, compression rates, and the start of memory addition. ```python 2025-12-06 20:25:14 - LightMemory - INFO - [add_memory_20251206_202514_215359] Extracted 0 visual contexts 2025-12-06 20:25:14 - LightMemory - INFO - [add_memory_20251206_202514_215359] Restored visual contexts after compression 2025-12-06 20:25:14 - LightMemory - INFO - [add_memory_20251206_202514_215359] Target compression rate: 0.8 Adding turns: 65%|██████▍ | 177/273 [02:06<00:31, 3.00it/s]2025-12-06 20:25:14 - LightMemory - INFO - ========== START add_memory_20251206_202514_253470 ========== 2025-12-06 20:25:14 - LightMemory - INFO - force_segment=False, force_extract=False 2025-12-06 20:25:14 - LightMemory - INFO - [add_memory_20251206_202514_253470] Extracted 0 visual contexts 2025-12-06 20:25:14 - LightMemory - INFO - [add_memory_20251206_202514_253470] Restored visual contexts after compression 2025-12-06 20:25:14 - LightMemory - INFO - [add_memory_20251206_202514_253470] Target compression rate: 0.8 ``` -------------------------------- ### LightMem Metadata Generation Log Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_longmemeval.ipynb Logs detailing the completion of metadata generation and the start of the offline update process, including API call token counts. ```log 2025-12-06 20:23:49 - LightMemory - INFO - [add_memory_20251206_202343_386424] API Call 0 tokens - Prompt: 1014, Completion: 466, Total: 1480 2025-12-06 20:23:49 - LightMemory - INFO - [add_memory_20251206_202343_386424] Metadata generation completed with 1 API calls 2025-12-06 20:23:49 - LightMemory - INFO - [add_memory_20251206_202343_386424] Created 12 MemoryEntry objects 2025-12-06 20:23:49 - LightMemory - INFO - ========== START offline_update_20251206_202349_692884 ========== 2025-12-06 20:23:49 - LightMemory - INFO - [offline_update_20251206_202349_692884] Received 12 memory entries 2025-12-06 20:23:49 - LightMemory - INFO - [offline_update_20251206_202349_692884] construct_update_queue_trigger=False, offline_update_trigger=False 2025-12-06 20:23:49 - LightMemory - INFO - [offline_update_20251206_202349_692884] Starting embedding and insertion to vector database ``` -------------------------------- ### LightMem Add Memory Output Log Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_longmemeval.ipynb This snippet displays the log output after successfully adding memory. It includes details on generated segments, assigned topic IDs, extraction events, and the start of metadata generation. ```text Output: 2025-12-06 20:25:34 - LightMemory - INFO - [add_memory_20251206_202533_811970] Generated 2 segments 2025-12-06 20:25:34 - LightMemory - INFO - [add_memory_20251206_202533_811970] Assigned global topic IDs: total=2, mapping=[[47, 48]] 2025-12-06 20:25:34 - LightMemory - INFO - [add_memory_20251206_202533_811970] Extraction triggered 1 times, extract_list length: 1 2025-12-06 20:25:34 - LightMemory - INFO - [add_memory_20251206_202533_811970] Batch max_source_ids: [12] 2025-12-06 20:25:34 - LightMemory - INFO - [add_memory_20251206_202533_811970] Starting metadata generation ``` -------------------------------- ### Offline Update Process Log Source: https://github.com/zjunlp/lightmem/blob/main/tutorial-notebooks/LightMem_Example_longmemeval.ipynb This log details the start of an offline update process, including the reception of memory entries and the initialization of embedding and insertion into the vector database. It also shows the status of update triggers. ```log 2025-12-06 20:24:27 - LightMemory - INFO - ========== START offline_update_20251206_202427_773246 ========== 2025-12-06 20:24:27 - LightMemory - INFO - [offline_update_20251206_202427_773246] Received 15 memory entries 2025-12-06 20:24:27 - LightMemory - INFO - [offline_update_20251206_202427_773246] construct_update_queue_trigger=False, offline_update_trigger=False 2025-12-06 20:24:27 - LightMemory - INFO - [offline_update_20251206_202427_773246] Starting embedding and insertion to vector database ``` -------------------------------- ### Setup Environment for LangMem Source: https://github.com/zjunlp/lightmem/blob/main/src/lightmem/memory_toolkits/readme.md Create a separate conda environment named 'langmem_env', activate it, and install dependencies from 'envs/langmem_requirements.txt'. This isolation helps manage conflicting dependencies. ```bash conda create -n langmem_env python=3.12 -y conda activate langmem_env pip install -r envs/langmem_requirements.txt ```