keyword

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package keyword 是 hce 的轻量字面/关键词倒排索引。

用途:补足 dense vector 的字面命中盲区——例如代码 chunk 里只是顺带含 `@RepeatSubmit` 注解,但 chunk 主语义被淹没,纯向量召不回。 倒排索引按 token → chunk_id 维护内存映射,search 时与 vector 结果合并。

索引数据**不持久化**:服务端启动后第一次 search 该 codebase 时按需 lazy 重建 (从 Milvus 拉所有 chunks)。后续 IndexFiles 写入时同步增量更新。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index 单个 codebase 的内存倒排

func NewIndex

func NewIndex() *Index

NewIndex 创建空索引

func (*Index) Add

func (i *Index) Add(chunkID, content string)

Add 索引一个 chunk

func (*Index) Lookup

func (i *Index) Lookup(query string) map[string]int

Lookup 用查询字符串找命中 chunk_id 及 TF 加权得分(mini-BM25)。 返回值为 chunk_id → 累计 TF(token 在 chunk 出现次数加总);越大越相关。 例如 chunk 里 @RepeatSubmit 出现 4 次,query 是 "@RepeatSubmit"(拆 3 个子 token), 得分 = 4 * 3 = 12,远高于单次出现的 3。

func (*Index) Remove

func (i *Index) Remove(chunkID string)

Remove 删除一个 chunk

func (*Index) Size

func (i *Index) Size() int

Size 返回索引中 chunk 数量(诊断用)

Jump to

Keyboard shortcuts

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