RankedList
KIT · interface · Type contract
One retriever's ordered result, optionally weighted.
Import
ts
import type { RankedList } from '@jangts/agent-core/kits/rank-fusion';js
/** @typedef {import('@jangts/agent-core/kits/rank-fusion').RankedList} RankedList */Other public entry points:@jangts/agent-core/types, @jangts/agent-core/kits, @jangts/agent-core/kits/rank-fusion.
Definition
ts
interface RankedListField structure
| Field | Type | Required | Description |
|---|---|---|---|
sourceId | string | Required | Read-only. Unique source name; duplicate names are rejected because they would double-count. |
ids | readonly string[] | Required | Read-only. Ids in descending relevance; duplicates inside one list are ignored after the first. |
weight | number | undefined | Optional | Read-only. Relative source weight, strictly positive; defaults to 1. |
Examples
- Rank Fusion: fuse multiple retrieval results by rank: Fuse full-text and vector ranks instead of directly adding raw scores with different semantics.
First use the default fusion parameters
Beginner · 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);Add source weights and the smoothing parameter to the same function
Configuration · 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);