MCP - Titan Memory Server

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Collaboration between GitHub users @jasonkneen and @ExpressionsBot

  • Uses TensorFlow.js for efficient tensor operations in the neural memory model with operations wrapped in tf.tidy() for proper memory management

  • Implements a type-safe implementation with TypeScript including type-safe MCP tool definitions

🧠 MCP - Titan 内存服务器实现

@jasonkneen@ExpressionsBot之间的合作

在 X 上关注我们

受 Google Research 论文《用于编程的生成式 AI:一个通用任务框架》启发的实现。该服务器提供了一个神经记忆系统,该系统可以学习和预测序列,同时通过记忆向量保持状态,并遵循研究中概述的改进代码生成和理解的原则。

📚 研究背景

此实现借鉴了 Google 研究论文(Muennighoff 等人,2024)中提出的概念,该论文介绍了一个用于评估和改进代码生成模型的框架。Titan 内存服务器实现了该论文中的关键概念:

  • 记忆增强序列学习
  • 新颖性检测的意外指标
  • 稳定学习的流形优化
  • 通过记忆向量进行状态维护

这些特性与本文的目标一致,即通过更好的内存和状态管理来提高代码理解和生成。

🚀 功能

  • 具有可配置维度的神经记忆模型
  • 序列学习与预测
  • 意外指标计算
  • 模型持久性(保存/加载)
  • 内存状态管理
  • 完整的 MCP 工具集成

📦安装

# Install dependencies npm install # Build the project npm run build # Run tests npm test

🛠️ 可用的 MCP 工具

1.🎯 init_model

使用自定义配置初始化 Titan 内存模型。

{ inputDim?: number; // Input dimension (default: 64) outputDim?: number; // Output/Memory dimension (default: 64) }

2. 📚 train_step

使用当前和下一个状态向量执行单个训练步骤。

{ x_t: number[]; // Current state vector x_next: number[]; // Next state vector }

3. 🔄 前向传递

使用输入向量对模型进行前向传递。

{ x: number[]; // Input vector }

4. 💾save_model

将模型保存到指定路径。

{ path: string; // Path to save the model }

5. 📂 load_model

从指定路径加载模型。

{ path: string; // Path to load the model from }

6. ℹ️ get_status

获取当前模型状态和配置。

{} // No parameters required

7. 🔄 train_sequence

在一系列向量上训练模型。

{ sequence: number[][]; // Array of vectors to train on }

🌟 使用示例

// Initialize model await callTool('init_model', { inputDim: 64, outputDim: 64 }); // Train on a sequence const sequence = [ [1, 0, 0, /* ... */], [0, 1, 0, /* ... */], [0, 0, 1, /* ... */] ]; await callTool('train_sequence', { sequence }); // Run forward pass const result = await callTool('forward_pass', { x: [1, 0, 0, /* ... */] });

🔧 技术细节

  • 使用 TensorFlow.js 构建,实现高效的张量运算
  • 使用流形优化实现稳定学习
  • 实施用于新颖性检测的惊喜指标
  • 通过适当的张量清理进行内存管理
  • 使用 TypeScript 实现类型安全
  • 全面的错误处理

🧪 测试

该项目包括全面的测试,涵盖:

  • 模型初始化和配置
  • 训练和前传操作
  • 内存状态管理
  • 模型持久化
  • 边缘情况和错误处理
  • 张量清理和内存管理

使用以下方式运行测试:

npm test

🔍 实施说明

  • 所有张量操作都包装在tf.tidy()中,以便进行正确的内存管理
  • 使用详细的错误消息实现正确的错误处理
  • 使用类型安全的 MCP 工具定义
  • 在操作之间保持内存状态
  • 处理具有 epsilon 容差的浮点精度问题

📝 许可证

MIT 许可证 - 请随意使用并根据需要修改!

-
security - not tested
F
license - not found
-
quality - not tested

通过记忆增强模型实现神经记忆序列学习,以改善代码理解和生成,具有状态管理、新颖性检测和模型持久性。

  1. 📚 Research Background
    1. 🚀 Features
      1. 📦 Installation
        1. 🛠️ Available MCP Tools
          1. 1. 🎯 init_model
          2. 2. 📚 train_step
          3. 3. 🔄 forward_pass
          4. 4. 💾 save_model
          5. 5. 📂 load_model
          6. 6. ℹ️ get_status
          7. 7. 🔄 train_sequence
        2. 🌟 Example Usage
          1. 🔧 Technical Details
            1. 🧪 Testing
              1. 🔍 Implementation Notes
                1. 📝 License
                  ID: iasz64qj43