@keo-ai/axiom 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/embedding_search/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -210,7 +210,7 @@ EmbeddingSearch 是 Axiom 的 RAG 底座。它封装了 `query → embedding →
|
|
|
210
210
|
| `embedding` | `vector(1024)` | 向量字段,必需,默认列名 `embedding`,可通过 `embeddingColumn` 自定义 |
|
|
211
211
|
| *(任意)* | *(任意)* | 你自己的业务列,可直接用于过滤和返回 |
|
|
212
212
|
|
|
213
|
-
**开 rerank 时的额外要求**:需指定 `rerankKey` 告诉系统哪一列是文本内容(默认 `'
|
|
213
|
+
**开 rerank 时的额外要求**:需指定 `rerankKey` 告诉系统哪一列是文本内容(默认 `'query'`)。
|
|
214
214
|
|
|
215
215
|
```sql
|
|
216
216
|
CREATE EXTENSION IF NOT EXISTS vector;
|
|
@@ -251,7 +251,7 @@ const results = await EmbeddingSearch.query('衣服质量怎么样', {
|
|
|
251
251
|
}, pool);
|
|
252
252
|
|
|
253
253
|
for (const r of results) {
|
|
254
|
-
console.log(r.id, r.
|
|
254
|
+
console.log(r.id, r.query, r.embeddingScore, r.rerankScore);
|
|
255
255
|
}
|
|
256
256
|
```
|
|
257
257
|
|
|
@@ -301,7 +301,7 @@ interface SearchResult {
|
|
|
301
301
|
| `embeddingThreshold` | `number` | `0.8` | embedding 相似度阈值过滤(cosine similarity) |
|
|
302
302
|
| `rerankThreshold` | `number` | `0.1` | rerank 分数阈值过滤 |
|
|
303
303
|
| `embeddingColumn` | `string` | `'embedding'` | 向量列名 |
|
|
304
|
-
| `rerankKey` | `string` | `'
|
|
304
|
+
| `rerankKey` | `string` | `'query'` | 启用 rerank 时,用于重排序的文本列名 |
|
|
305
305
|
| `dimensions` | `number` | `1024` | embedding 输出维度(1 ~ 1024) |
|
|
306
306
|
| `select` | `string[]` | `undefined` | 指定返回哪些列,不传则 `SELECT *` |
|
|
307
307
|
| `filter` | `Record<string, unknown>` | — | 对表独立列做等值/范围过滤 |
|
|
@@ -89,7 +89,7 @@ function rerank(query, documents, topN, apiKey) {
|
|
|
89
89
|
class EmbeddingSearch {
|
|
90
90
|
static query(query, config, pool) {
|
|
91
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const { enableRerank = true, embeddingTopK = 10, finalTopN = 5, embeddingThreshold = 0.8, rerankThreshold = 0.1, tableName, embeddingColumn, rerankKey = '
|
|
92
|
+
const { enableRerank = true, embeddingTopK = 10, finalTopN = 5, embeddingThreshold = 0.8, rerankThreshold = 0.1, tableName, embeddingColumn, rerankKey = 'query', dimensions, filter, select, } = config;
|
|
93
93
|
const idColumn = 'id';
|
|
94
94
|
const actualTopK = enableRerank
|
|
95
95
|
? Math.max(embeddingTopK, finalTopN)
|