bigram

package
v0.0.0-...-1c978d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package bigram 是 session 的内置词法召回器(retriever: bigram):字符 bigram 重叠打分,对中文友好、无 embedding 依赖的保底实现。语义召回请 注册向量后端。空导入(或经 agent-kit/std)即注册。

打分与片段(brain-loop U1.2/U1.3/U1.4a):相关度 = Jaccard 归一(消除长 消息的原始计数虚高)× 近因因子(对话相关性随距离衰减);命中片段取 **匹配点周围的窗口**而非消息前缀(前缀常不含匹配到的词,定位对了却答非 所问)。retriever_config 可配 snippet_len(片段 rune 上限)与 max_chars (召回总字符预算,0 = 不限)。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Search(msgs []*schema.Message, query string, topK int) []string

Search 用默认参数检索(包级便捷入口,测试与无配置路径用)。

func SearchOpts

func SearchOpts(msgs []*schema.Message, query string, topK int, opts Options) []string

SearchOpts 在历史消息中按相关度检索并返回格式化片段。相关度 = Jaccard × 近因;只看 user/assistant 消息;原始重叠 < minRawOverlap 视为未命中。

Types

type Options

type Options struct {
	SnippetLen   int  // 片段 rune 上限(默认 defaultSnippetLen)
	MaxChars     int  // 召回总字符预算,0 = 不限
	IncludeTools bool // U1.4d:纳入执行记录([执行记录] system 摘要),默认关
}

Options 是召回的可配参数。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL