result

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compress

func Compress(limit int, llm goChatCore.Client, hits []core.Hit) ([]core.Hit, error)

Compress 先按分数排序取 top N,再对每条 Content 调用 LLM 压缩。

func Dedup

func Dedup(hits []core.Hit) ([]core.Hit, error)

Dedup 对搜索结果语义去重 使用 MinHash 算法估算文本 Jaccard 相似度,对同 DocID 下相似度超过阈值的 chunk 进行合并 合并规则:同 DocID 下,内容相似度 >= threshold 的保留分数最高的,丢弃其余

func RRF

func RRF(sources ...FusionSource) ([]core.Hit, error)

Merge 对多个源执行 RRF 融合,返回按融合分数降序排列的结果。 k 为 RRF 平滑参数,默认值 60(推荐范围 5~100,越大对低排名结果越宽容)。

func RRFWithK

func RRFWithK(k int, sources ...FusionSource) ([]core.Hit, error)

RRFWithK 使用自定义 k 参数的 RRF 融合。

func Rerank

func Rerank(query *query.SemanticQuery, hits []core.Hit) ([]core.Hit, error)

Reranker 实现基于向量相似度的结果重排(Re-Ranking)。

RAG 中的 Re-Ranking 指的是对初步检索结果用更精确的方式重新打分排序, 而不是简单地按初始检索分数排列。

本实现使用 SemanticQuery 中已预计算的查询向量与每条检索结果的 内容向量进行余弦相似度比较,以此作为重排依据。 查询向量由 SemanticQuery.Vector() 直接获取,不重复编码。

Rerank 用查询向量与每条 Hit 的内容向量计算余弦相似度作为新分数,按此分数降序排列。

Types

type FusionSource

type FusionSource struct {
	Name   string     // 源标识(如 "vector"、"keyword"、"graph")
	Hits   []core.Hit // 该源的搜索结果,顺序 = 排名
	Weight float32    // 源权重,0 表示 1.0
}

FusionSource 代表单个搜索源返回的原始结果。 字段 Hits 的顺序即该源内部的排名顺序。

func NewSource

func NewSource(name string, weight float32, hits []core.Hit) *FusionSource

Jump to

Keyboard shortcuts

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