游乐游手机版
首页/AI热点日报/热点详情

AI框架揭示:注意力是记忆本质,解析记忆神秘过程

类型:热点整理2026-06-26
记忆力不好的人,通常注意力也不咋地——这个观察靠谱吗?记忆力和注意力之间到底有没有关系?怎么才能记得更高效?还有,人为什么记不起三岁之前的事? 如果你接触过记忆研究,大概率见过那张经典的记忆曲线图:随着时间推移,人们会逐渐遗忘知识或事实。一句老话讲“时间会淡化一切”,说的就是这个道理。 知道了记忆曲

记忆力不好的人,通常注意力也不咋地——这个观察靠谱吗?记忆力和注意力之间到底有没有关系?怎么才能记得更高效?还有,人为什么记不起三岁之前的事?

如果你接触过记忆研究,大概率见过那张经典的记忆曲线图:随着时间推移,人们会逐渐遗忘知识或事实。一句老话讲“时间会淡化一切”,说的就是这个道理。

知道了记忆曲线这回事,有规律地回顾那些记忆项,就能把记忆保留得更久。但光知道曲线还不够,咱们还需要理解记忆的本质。

记忆的本质是什么?

从大模型词嵌入的过程,以及人脑神经元连接的强化过程里,或许能看出些端倪。人脑并没有固定的“记忆脑区”——你不能切下一块说“这里存着记忆”,然后把它提取出来。与此同时,大模型对语义的理解也不是传统的“存储-检索”方式,而是一种多维向量表示。但这种方式展现出来的词义理解,就好像模型真的记住了词的意思。

那么,有没有一种可能:记忆力的本质,其实就是注意力?咱们就用注意力来解释记忆。这个过程有点像复习知识点或回顾事实:当你注意力高度集中时,就像在调用注意力机制给模型做微调;而词向量的权重矩阵,就像神经元之间的连接——权重越高,连接越强。每一次对知识或事实的回顾,就是在强化那些特定的连接,其背后的工作原理,就是人的注意力机制在起作用。

是否可以说记忆力的本质就是注意力?

不管注意力是不是记忆力的本质,至少我们知道了注意力在记忆过程中的重要作用。既然这样,就该利用这个特点来学习知识、记忆重要事实。改天不如今天,择日不如撞日——来设计一个小脚本吧,一个帮助记忆的系统,就叫它记忆管理系统MOS。我们需要一种叫“记忆项”的文件,以JSON格式存储:每个记忆项包含id、记忆等级、问题、答案、遗忘时间。

如果当前系统时间已经超过了记忆项的遗忘时间,说明该记忆项已经被遗忘了,就显示为红色;如果还没到遗忘时间,则显示为绿色。

让ChatGPT来帮忙写这个代码

采用最小可行性方案,用Windows里的PowerShell命令行来执行这个脚本。需要具备管理记忆项的功能:增加、删除、查看。查看功能就像列出整个文件列表,同时根据是否遗忘判断显示红色或绿色。此外,还需要复习功能,以及更新记忆等级和遗忘时间的算法。至此,就可以完成这个记忆管理系统的构建了。

把需求交给ChatGPT,经过一轮调整和Bug修复,得到一份两百多行的脚本。我们将代码拆开来看,分别有主函数、创建记忆项函数、查看记忆项列表函数、复习记忆项函数、删除记忆项函数。

主函数

首先显示使用提示,展示脚本的使用方法:

# 主程序逻辑
do {
    Clear-Host
    Show-MemoryNodes
    Write-Host "Yuanda>" -NoNewline
    $input = Read-Host

    if ($input -eq 'exit') {
        break
    } elseif ($input -eq 'cn') {
        Create-MemoryNode
    } elseif ($input -eq 'h') {
        help
    } elseif ($input -eq 'ct') {
        Create-TestNode
    } elseif ($input -eq 'dt') {
        Show-MemoryNodesDetails
    } elseif ($input -eq 'dn') {
        Write-Host "Enter the node number to delete:"
        $nodeIndex = [int](Read-Host)
        Delete-MemoryNode -nodeIndex $nodeIndex
    } elseif ($input -eq 'file') {
        Open-Folder
    } elseif ($input -match '^\d+$') {
        $nodeIndex = [int]$input
        Review-MemoryNode -nodeIndex $nodeIndex
    } else {
        Show-MemoryNodesDetails
    }
} while ($true)

记忆节点列表页

脚本运行后会自动执行记忆项列表查看功能——也就是说,一旦运行脚本,就会同时看到使用方法和列表:

# 显示记忆节点
function Get-ColoredText {
    param (
        [string]$text,
        [string]$color
    )
    return "$([char]27)[0;3${color}m$text$([char]27)[0m"
}

function Show-MemoryNodes {
    $currentTime = Get-CurrentUnixTimestamp
    $files = Get-ChildItem -Path $memoryNodesPath
    $index = 1
    $count = 0
    $lines = ""
    foreach ($file in $files) {
        $count = $count + 1
        $content = Get-Content -Path $file.FullName | ConvertFrom-Json
        $forgetTime = $content.ForgettingTime
        $status = if ($currentTime -gt $forgetTime) { 'Expired' } else { 'Active' }

        if ($status -eq 'Expired') {
            $lines += "$(Get-ColoredText "($index)`t" '1')"
        } else {
            $lines += "$(Get-ColoredText "($index)`t " '2')"
        }
        if ($count % 25 -eq 0) { $lines += "`n"}
        if ($count % 237 -eq 0) {Clear-Host; Write-Host "Memories List:"; Write-host "加载中:$count"}
        $index++
    }

    Clear-Host
    $readtime = Convert-TimestampToDateTime -timestamp $currentTime
    Write-Host "currentTime:$readtime" 
    Write-Host "Memories List:"
    Write-Host
    Write-Host $lines
    Write-Host
}

创建记忆节点

# 创建新的记忆节点
function Create-MemoryNode {
    Clear-Host
    Write-Host "Enter the question:"
    $question = Read-Host
    Write-Host "Enter the answer:"
    $answer = Read-Host

    $content = @{
        Question = $question
        Answer = $answer
        Level = 1
        ForgettingTime = (Get-CurrentUnixTimestamp) + 86400 # 24 hours in seconds
    }

    $fileName = "{0:D4}.json" -f ((Get-ChildItem -Path $memoryNodesPath).Count + 1)
    $filePath = Join-Path -Path $memoryNodesPath -ChildPath $fileName
    $content | ConvertTo-Json | Set-Content -Path $filePath

    Write-Host "New memory node created."
}

查看节点的详细信息

# 列出所有节点的详细信息
function Show-MemoryNodesDetails {
    Clear-Host
    $currentTime = Get-CurrentUnixTimestamp
    $readtime = Convert-TimestampToDateTime -timestamp $currentTime
    Write-Host "currentTime:$readtime"
    Write-Host "Detailed Memories List:"
    Write-Host
    $files = Get-ChildItem -Path $memoryNodesPath
    $index = 1
    $lines=''

    foreach ($file in $files) {
        $content = Get-Content -Path $file.FullName | ConvertFrom-Json
        $forgetTime = $content.ForgettingTime
        $level = $content.Level
        $question = $content.Question
        $forgetTimeReadable = Convert-TimestampToDateTime -timestamp $forgetTime
        $status = if ($currentTime -gt $forgetTime) { 'Expired' } else { 'Active' }

        if ($status -eq 'Expired') {
            $lines += "$(Get-ColoredText "($index) $question " '1')"
        } else {
            $lines += "$(Get-ColoredText "($index) $question " '2')"
        }
        $index++
    }

    Write-Host $lines
    Write-Host
    Write-Host "Yuanda>" -NoNewline

    $input = Read-Host

    if ($input -eq 'exit') {
        break
    } elseif ($input -eq 'cn') {
        Create-MemoryNode
    } elseif ($input -eq 'h') {
        help
    } elseif ($input -eq 'ct') {
        Create-TestNode
    } elseif ($input -eq 'dt') {
        Show-MemoryNodesDetails
    } elseif ($input -eq 'dn') {
        Write-Host "Enter the node number to delete:"
        $nodeIndex = [int](Read-Host)
        Delete-MemoryNode -nodeIndex $nodeIndex
    } elseif ($input -eq 'file') {
        Open-Folder
    } elseif ($input -match '^\d+$') {
        $nodeIndex = [int]$input
        Review-MemoryNode -nodeIndex $nodeIndex
    } else {
    }
}

复习记忆项

输入记忆项的序号,回车就能回顾该记忆项。如果记忆项还未遗忘,复习时会询问是否记得;如果选择n,就将记忆等级调回最初的等级,遗忘时间设为当前时间(就像刚创建一样)。如果记忆项还未遗忘但选择y,则状态不变。只有当记忆项已经过了遗忘时间时选择y,才会更新记忆等级和遗忘时间。

# 复习记忆节点
function Review-MemoryNode {
    param([int]$nodeIndex)

    $files = Get-ChildItem -Path $memoryNodesPath
    if ($nodeIndex -lt 1 -or $nodeIndex -gt $files.Count) {
        Write-Host "Invalid node index."
        return
    }

    $file = $files[$nodeIndex - 1]
    $content = Get-Content -Path $file.FullName | ConvertFrom-Json

    Clear-Host
    Write-Host "Question:"
    Write-Host " $($content.Question)"
    Write-Host
    Write-Host "Press Enter to see the answer..." -ForegroundColor Blue
    Read-Host
    Clear-Host
    Write-Host "Question:"
    Write-Host " $($content.Question)"
    Write-Host
    Write-Host "Answer:"
    Write-Host " $($content.Answer)"
    Write-Host
    Write-Host "Did you remember it? (y/n)>" -ForegroundColor Blue -NoNewline
    $response = Read-Host

    $currentTime = Get-CurrentUnixTimestamp

    $status = if ($currentTime -gt $content.ForgettingTime) { 'Expired' } else { 'Active' }

    if ($status -eq 'Expired') {
        if ([string]::IsNullOrWhiteSpace($response)) {
            Write-Host "No input provided. Assuming 'n' (no)."
            $response = 'y'
        }
        if ($response -eq 'y') {
            $newLevel = $content.Level + 1
            $forgetTime = $currentTime + ($newLevel * $newLevel * 86400) # Level squared hours converted to seconds
            $content.Level = $newLevel
            $content.ForgettingTime = $forgetTime
        } else {
            $content.Level = 1
            $forgetTime = $currentTime
        }
    } else {
        if ([string]::IsNullOrWhiteSpace($response)) {
            Write-Host "No input provided. Assuming 'n' (no)."
            $response = 'y'
        }
        if ($response -eq 'n') {
            $content.Level = 0
            $content.ForgettingTime = $currentTime -10
        }
    }
    $content | ConvertTo-Json | Set-Content -Path $file.FullName
}

打开记忆项文件夹

别忘了,记忆项以JSON格式存储在指定文件夹中,你需要进入脚本把文件夹路径修改为你本地存在的路径。

# 打开记忆节点目录
function Open-Folder {
    Start-Process explorer.exe -ArgumentList $memoryNodesPath
}

删除记忆项

# 删除记忆节点
function Delete-MemoryNode {
    param([int]$nodeIndex)

    $files = Get-ChildItem -Path $memoryNodesPath
    if ($nodeIndex -lt 1 -or $nodeIndex -gt $files.Count) {
        Write-Host "Invalid node index."
        return
    }

    $file = $files[$nodeIndex - 1]
    $content = Get-Content -Path $file.FullName | ConvertFrom-Json

    Clear-Host
    Write-Host "问题:"
    Write-Host "$($content.Question)"
    Write-Host "答案:"
    Write-Host "$($content.Answer)"
    Write-Host
    Write-Host "确定删除吗? (y/n)" -ForegroundColor Red

    $response = Read-Host

    if ($response -eq 'y') {
        Remove-Item -Path $file.FullName
        Write-Host "Memory node deleted."
    } else {
        Write-Host "Memory node deletion canceled."
    }
}

此外,还有一些细节部分:初始化、帮助界面、时间格式转换、检测目录是否存在、获取当前时间、测试等。最终会得到一份两百四十多行、后缀为ps1的脚本文件。

这个脚本的设计理念是反映记忆在脑中掌握的程度,帮助使用者有规律地周期性注意到自己想记忆的知识或事实。只要周期性地查看记忆项列表,重新注意到那些已经遗忘的节点,将其回顾为绿色节点,保持所有记忆节点都是绿色状态——这就是记忆管理的方法。

来源:https://www.53ai.com/news/RAG/2024102059840.html

相关热点

继续查看同栏目近期热点。

延伸阅读

补充最近整理过的热点入口。