Skip to content

Commit 9aed4da

Browse files
committed
Improve batch embedding throughput for faster indexing
1 parent f10b6ed commit 9aed4da

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Changelog
22

33

4+
## [1.3.2] - 2026-01-16
5+
6+
### Changed
7+
- **Embeddings**: Batch embedding now uses a single Transformers.js pipeline call per batch for higher throughput.
8+
- **Dependencies**: Bump `@modelcontextprotocol/sdk` to 1.25.2.
9+
410
## [1.3.1] - 2026-01-05
511

612
### Fixed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codebase-context",
3-
"version": "1.3.1",
3+
"version": "1.3.2",
44
"description": "MCP server that helps AI agents understand your codebase - patterns, libraries, architecture, monorepo support",
55
"type": "module",
66
"main": "./dist/lib.js",
@@ -87,7 +87,7 @@
8787
},
8888
"dependencies": {
8989
"@lancedb/lancedb": "^0.4.0",
90-
"@modelcontextprotocol/sdk": "^1.25.1",
90+
"@modelcontextprotocol/sdk": "^1.25.2",
9191
"@typescript-eslint/typescript-estree": "^7.0.0",
9292
"@xenova/transformers": "^2.17.0",
9393
"fuse.js": "^7.0.0",

pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/embeddings/transformers.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ export class TransformersEmbeddingProvider implements EmbeddingProvider {
7575

7676
for (let i = 0; i < texts.length; i += batchSize) {
7777
const batch = texts.slice(i, i + batchSize);
78-
const batchEmbeddings = await Promise.all(batch.map((text) => this.embed(text)));
7978

80-
embeddings.push(...batchEmbeddings);
79+
const output = await this.pipeline(batch, {
80+
pooling: 'mean',
81+
normalize: true
82+
});
83+
embeddings.push(...(output.tolist() as number[][]));
8184

8285
if (texts.length > 100 && (i + batchSize) % 100 === 0) {
8386
console.error(`Embedded ${Math.min(i + batchSize, texts.length)}/${texts.length} chunks`);

0 commit comments

Comments
 (0)