Skip to content

feat(eval): add openai memory on locomo - eval guide - #54

Merged
Ki-Seki merged 16 commits into
MemTensor:devfrom
Duguce:dev
Jul 10, 2025
Merged

feat(eval): add openai memory on locomo - eval guide#54
Ki-Seki merged 16 commits into
MemTensor:devfrom
Duguce:dev

Conversation

@Duguce

@Duguce Duguce commented Jul 10, 2025

Copy link
Copy Markdown
Contributor

Description

Summary: add openai memory on locomo - eval guide

Fix: #(issue)

Reviewer: @hush-cd

Checklist:

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have added necessary documentation (if applicable) | 我已添加必要的文档(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

Copilot AI review requested due to automatic review settings July 10, 2025 10:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for evaluating OpenAI’s Memory feature on the LoCoMo dataset by providing automation scripts, a detailed guide, and an evaluation tool.

  • Introduces run_openai_eval.sh to orchestrate the LoCoMo OpenAI memory evaluation pipeline
  • Adds a step-by-step Markdown guide for manual memory extraction and consolidation
  • Implements locomo_openai.py to automate question answering against stored memories
  • Updates the main README.md to reference the new guide

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
evaluation/scripts/run_openai_eval.sh Shell script to run the OpenAI-based evaluation steps
evaluation/scripts/locomo/openai_memory_locomo_eval_guide.md Manual guide for extracting and consolidating ChatGPT memories
evaluation/scripts/locomo/locomo_openai.py Python script to query stored memories and evaluate responses
evaluation/README.md README update linking to the OpenAI memory evaluation guide
Comments suppressed due to low confidence (1)

evaluation/README.md:36

  • [nitpick] It would be helpful to include the exact command for running the new evaluation script (e.g., ./evaluation/scripts/run_openai_eval.sh --version <version>), so users don’t have to look it up.
✍️ For evaluating OpenAI's native memory feature with the LoCoMo dataset, please refer to the detailed guide: [OpenAI Memory on LoCoMo - Evaluation Guide](./scripts/locomo/openai_memory_locomo_eval_guide.md).

Comment on lines +10 to +25
echo "Running locomo_openai.py..."
python scripts/locomo/locomo_openai.py --version $VERSION
if [ $? -ne 0 ]; then
echo "Error running locomo_openai.py."
exit 1
fi

echo "Running locomo_eval.py..."
python scripts/locomo/locomo_eval.py --lib $LIB --version $VERSION --num_runs $NUM_RUNS
if [ $? -ne 0 ]; then
echo "Error running locomo_eval.py"
exit 1
fi

echo "Running locomo_metric.py..."
python scripts/locomo/locomo_metric.py --lib $LIB --version $VERSION

Copilot AI Jul 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The relative path scripts/locomo/locomo_openai.py will be resolved from the current working directory, which may not be the script’s location. Consider using the script’s directory for paths (e.g., DIR=$(dirname "$0") and then python "$DIR"/locomo/locomo_openai.py --version "$VERSION").

Suggested change
echo "Running locomo_openai.py..."
python scripts/locomo/locomo_openai.py --version $VERSION
if [ $? -ne 0 ]; then
echo "Error running locomo_openai.py."
exit 1
fi
echo "Running locomo_eval.py..."
python scripts/locomo/locomo_eval.py --lib $LIB --version $VERSION --num_runs $NUM_RUNS
if [ $? -ne 0 ]; then
echo "Error running locomo_eval.py"
exit 1
fi
echo "Running locomo_metric.py..."
python scripts/locomo/locomo_metric.py --lib $LIB --version $VERSION
DIR=$(dirname "$0")
echo "Running locomo_openai.py..."
python "$DIR"/scripts/locomo/locomo_openai.py --version $VERSION
if [ $? -ne 0 ]; then
echo "Error running locomo_openai.py."
exit 1
fi
echo "Running locomo_eval.py..."
python "$DIR"/scripts/locomo/locomo_eval.py --lib $LIB --version $VERSION --num_runs $NUM_RUNS
if [ $? -ne 0 ]; then
echo "Error running locomo_eval.py"
exit 1
fi
echo "Running locomo_metric.py..."
python "$DIR"/scripts/locomo/locomo_metric.py --lib $LIB --version $VERSION

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +77
class OpenAIPredict:
def __init__(self, model="gpt-4o-mini"):
self.model = model
self.openai_client = OpenAI(
api_key=os.getenv("OPENAI_API_KEY"), base_url=os.getenv("OPENAI_BASE_URL")
)
self.results = defaultdict(list)

def search_memory(self, idx):
with open(f"openai_memory/{idx}.txt", encoding="utf-8") as file:
memories = file.read().strip().replace("\n\n", "\n")

return memories, 0

Copilot AI Jul 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code assumes an openai_memory/ directory exists and hardcodes that path, but the guide uses openai_inputs/ and doesn’t mention creating openai_memory/. Either parameterize this directory or document/setup the folder before reading.

Suggested change
class OpenAIPredict:
def __init__(self, model="gpt-4o-mini"):
self.model = model
self.openai_client = OpenAI(
api_key=os.getenv("OPENAI_API_KEY"), base_url=os.getenv("OPENAI_BASE_URL")
)
self.results = defaultdict(list)
def search_memory(self, idx):
with open(f"openai_memory/{idx}.txt", encoding="utf-8") as file:
memories = file.read().strip().replace("\n\n", "\n")
return memories, 0
class OpenAIPredict:
def __init__(self, model="gpt-4o-mini", memory_dir="openai_memory"):
self.model = model
self.memory_dir = memory_dir
os.makedirs(self.memory_dir, exist_ok=True)
self.openai_client = OpenAI(
api_key=os.getenv("OPENAI_API_KEY"), base_url=os.getenv("OPENAI_BASE_URL")
)
self.results = defaultdict(list)
def search_memory(self, idx):
memory_file_path = os.path.join(self.memory_dir, f"{idx}.txt")
with open(memory_file_path, encoding="utf-8") as file:
memories = file.read().strip().replace("\n\n", "\n")
return memories, 0

Copilot uses AI. Check for mistakes.
Comment on lines +72 to +77
def search_memory(self, idx):
with open(f"openai_memory/{idx}.txt", encoding="utf-8") as file:
memories = file.read().strip().replace("\n\n", "\n")

return memories, 0

Copilot AI Jul 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently search_memory always returns 0 for the search time. For accurate metrics, consider measuring and returning the actual file‐read duration using time.time().

Suggested change
def search_memory(self, idx):
with open(f"openai_memory/{idx}.txt", encoding="utf-8") as file:
memories = file.read().strip().replace("\n\n", "\n")
return memories, 0
def search_memory(self, idx):
t1 = time.time()
with open(f"openai_memory/{idx}.txt", encoding="utf-8") as file:
memories = file.read().strip().replace("\n\n", "\n")
t2 = time.time()
search_time = (t2 - t1) * 1000 # Convert to milliseconds
return memories, search_time

Copilot uses AI. Check for mistakes.

@hush-cd hush-cd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file evaluation/scripts/locomo/openai_memory_locomo_eval_guide.md requires partial revisions.

4. **Save Memories:**
* Click on **Manage** in the memory confirmation to view the newly generated memories.
* Create a new local `.txt` file with the same name as the input file (e.g., `0-D1.txt`).
* Copy each memory entry from ChatGPT and paste it into the new file, with each memory on a new line.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is important to emphasize that once all sessions under a single conversation have been processed and their memories saved, all memories in ChatGPT must be deleted(Settings -> Personalization -> Manage memories -> Delete all) before starting memory extraction for the next conversation. This prevents interference between memories from different conversations.

## 3. Considerations

- **Account Differences:** Be aware of potential differences between free and Plus accounts, such as context length limitations and the number of memories that can be stored.
- **Granularity:** The current process adds memories at a **session** level. This is due to the context window limitations of the web UI. Evaluating at a full **conversation** level at once might be preferable if the context window allows.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memory extraction should be performed at the session level only. It is not recommended to input the entire conversation at once, as this often results in very few memories being extracted, leading to significant information loss.

@Duguce

Duguce commented Jul 10, 2025

Copy link
Copy Markdown
Contributor Author

@hush-cd has been reviewed; Please help me merge this branch @Ki-Seki

@Ki-Seki
Ki-Seki merged commit 97fdb06 into MemTensor:dev Jul 10, 2025
tianxing02 pushed a commit to tianxing02/MemOS that referenced this pull request Feb 24, 2026
* feat(eval): add eval dependencies

* feat(eval): add configs example

* docs(eval): update README.md

* feat(eval): remove the dependency (pydantic)

* feat(eval): add run locomo eval script

* fix(eval): delete about memos redundant search branches

* chore: fix format

* feat(eval): add openai memory on locomo - eval guide

* docs(eval): modify openai memory on locomo - eval guide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants