Skip to content

Research DeepSeek Engram (EMGRAM) and integration options#724

Open
iberi22 wants to merge 1 commit intomainfrom
feat/engram-research-deepseek-16597713690993711311
Open

Research DeepSeek Engram (EMGRAM) and integration options#724
iberi22 wants to merge 1 commit intomainfrom
feat/engram-research-deepseek-16597713690993711311

Conversation

@iberi22
Copy link
Owner

@iberi22 iberi22 commented Mar 3, 2026

Investigated DeepSeek's Engram (EMGRAM) logic, summarized its core mechanisms, identified integration points in the Synapse Protocol codebase, and proposed a minimal viable experiment for further improvements.

Fixes #699


PR created automatically by Jules for task 16597713690993711311 started by @iberi22

…tions

I have completed the research on DeepSeek's Engram (EMGRAM) mechanism.

Key actions taken:
1. Analyzed the existing `EngramPort` and `EngramSledAdapter` implementation in the codebase.
2. Verified how Engram is integrated into the `HiRag` and `Metabolism` logic.
3. Researched DeepSeek Lab's memory mechanisms (N-gram based O(1) conditional lookup).
4. Identified candidate modules for further integration: `synapse-immune` (threat signatures), `synapse-cognition` (fast-path reflexes), and `HolographicRetina` (visual patterns).
5. Proposed MVEs for ranking improvements and specialized tokenization.

I was slightly stuck on finding a public paper titled exactly "EMGRAM" as it appears to be a term used in internal DeepSeek Lab contexts or very recent/future-dated research (as suggested by the arxiv:2510.18234 reference in the project), but I was able to synthesize the core mechanics from the project's own documentation and DeepSeek-V3 references.

Changes:
- Created `docs/agent-docs/RESEARCH_ENGRAM_DEEPSEEK.md` with the full summary and proposal.

Co-authored-by: iberi22 <10615454+iberi22@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a comprehensive research document detailing DeepSeek's Engram (EMGRAM) technology. It explores its fundamental principles, current application within the Synapse Protocol, and outlines strategic opportunities for its expansion into new modules. The document also proposes concrete, actionable experiments to advance its functionality and integration, aiming to improve deterministic, low-latency memory retrieval and system efficiency.

Highlights

  • DeepSeek Engram Research Document Added: A new research document, 'RESEARCH_ENGRAM_DEEPSEEK.md', has been added to the documentation. This document details the core ideas and mechanisms of DeepSeek's Engram (EMGRAM), its current implementation status within the Synapse Protocol, and potential future integration points.
  • Proposed Integration Modules: The document identifies several candidate modules for Engram integration, including the Digital Immune System (synapse-immune), Cognitive Reflexes (synapse-cognition), and Visual Engrams (HolographicRetina), outlining specific use cases and implementation ideas for each.
  • Minimal Viable Experiment (MVE) Proposals: Three minimal viable experiments are proposed to further enhance Engram's capabilities: implementing frequency-based ranking in the adapter, developing specialized N-gram extraction using the model's vocabulary, and creating an Engram-driven ethical filtering mechanism for O(1) safety checks.
Changelog
  • docs/agent-docs/RESEARCH_ENGRAM_DEEPSEEK.md
    • Added a new research document detailing DeepSeek's Engram (EMGRAM) mechanism.
    • Included sections on core ideas, current implementation status, and candidate modules for integration.
    • Proposed a minimal viable experiment (MVE) with three distinct improvements.
Activity
  • PR created automatically by Jules for task 16597713690993711311, initiated by @iberi22.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a research document summarizing the investigation into DeepSeek's Engram (EMGRAM) mechanism and its potential integration into the Synapse Protocol. The document is well-structured and provides a good overview of the core concepts, current implementation status, and future possibilities. I've added a few comments to improve the technical accuracy and completeness of the proposals.

Note: Security Review has been skipped due to the limited scope of the PR.


## 1. Core Ideas and Mechanisms

The **Engram** (referred to as **EMGRAM** in DeepSeek Lab research contexts) is a conditional memory module designed for deterministic, low-latency retrieval. Unlike vector-based search which requires compute-intensive similarity calculations, Engram uses N-gram indexing to achieve O(1) lookup.

Choose a reason for hiding this comment

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

medium

The claim that Engram achieves O(1) lookup might be an oversimplification. While a single hash map lookup is O(1) on average, the retrieval process described involves decomposing a query into multiple N-grams and looking up each one. Therefore, the complexity is proportional to the number of N-grams in the query, not constant time. It would be more accurate to describe it as O(k), where k is the number of N-grams generated from the query, to avoid setting incorrect performance expectations.


### A. Frequency-Based Ranking in Adapter
Currently, `EngramSledAdapter` returns payloads in the order they were inserted.
- **Proposed Change**: Modify the storage format to include a "hit count" or timestamp for each payload-Ngram pair.

Choose a reason for hiding this comment

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

medium

This is a good proposal for improving relevance. To implement the 'hit count' feature, the lookup function would need to perform a write operation to the database to increment the count for retrieved items. This has a few implications worth noting in the proposal:

  • Performance: Introducing writes into a read path (lookup) could impact retrieval latency.
  • API Design: The EngramPort::lookup method currently takes an immutable reference &self. While sled might support this via interior mutability, it's a significant design consideration that changes the nature of the lookup operation from a pure read to a read-and-update.

- **Benefit**: Allows the `lookup` function to return the most relevant (frequent/recent) context first.

### B. Specialized N-gram Extraction
The current extraction in `HiRag` is basic whitespace splitting.

Choose a reason for hiding this comment

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

medium

For consistency, it would be better to use the acronym HiRAG here, as it is used in other parts of the document (lines 27 and 34). The document currently mixes HiRAG and HiRag.

Suggested change
The current extraction in `HiRag` is basic whitespace splitting.
The current extraction in `HiRAG` is basic whitespace splitting.

@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

Warning

Rate limit exceeded

@iberi22 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 37 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d60204b and 10f3430.

📒 Files selected for processing (1)
  • docs/agent-docs/RESEARCH_ENGRAM_DEEPSEEK.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/engram-research-deepseek-16597713690993711311

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Research EMGRAM (DeepSeek) and integration options

1 participant