Skip to content
English

RankedList ​

KIT · interface · 类型合同

One retriever's ordered result, optionally weighted.

导入 ​

ts
import type { RankedList } from '@jangts/agent-core/kits/rank-fusion';
js
/** @typedef {import('@jangts/agent-core/kits/rank-fusion').RankedList} RankedList */

其他公开入口:@jangts/agent-core/types、@jangts/agent-core/kits、@jangts/agent-core/kits/rank-fusion。

定义 ​

ts
interface RankedList

字段结构 ​

字段类型必需说明
sourceIdstring必需只读。Unique source name; duplicate names are rejected because they would double-count.
idsreadonly string[]必需只读。Ids in descending relevance; duplicates inside one list are ignored after the first.
weightnumber | undefined可省略只读。Relative source weight, strictly positive; defaults to 1.

使用示例 ​

先用默认融合参数 ​

入门 · Node.js

ts
import { reciprocalRankFusion } from '@jangts/agent-core/kits/rank-fusion';
const result = reciprocalRankFusion([
  { sourceId: 'text', ids: ['workflow', 'model'] },
  { sourceId: 'vector', ids: ['model', 'workflow'] },
], { limit: 5 });
console.log(result);
js
import { reciprocalRankFusion } from '@jangts/agent-core/kits/rank-fusion';
const result = reciprocalRankFusion([
    { sourceId: 'text', ids: ['workflow', 'model'] },
    { sourceId: 'vector', ids: ['model', 'workflow'] },
], { limit: 5 });
console.log(result);

相同函数增加来源权重与平滑参数 ​

配置 · Node.js

ts
import { reciprocalRankFusion } from '@jangts/agent-core/kits/rank-fusion';
const result = reciprocalRankFusion([
  { sourceId: 'text', ids: ['workflow', 'model'], weight: 2 },
  { sourceId: 'vector', ids: ['model', 'workflow'], weight: 1 },
], { limit: 2, k: 30 });
console.log(result[0].contributions);
js
import { reciprocalRankFusion } from '@jangts/agent-core/kits/rank-fusion';
const result = reciprocalRankFusion([
    { sourceId: 'text', ids: ['workflow', 'model'], weight: 2 },
    { sourceId: 'vector', ids: ['model', 'workflow'], weight: 1 },
], { limit: 2, k: 30 });
console.log(result[0].contributions);

相关策略源码 ​

接口参考、使用示例与开发指南。