Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .codegraphrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"embeddings": { "model": "bge-large" }
}
23 changes: 15 additions & 8 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { buildGraph } from './builder.js';
import { loadConfig } from './config.js';
import { findCycles, formatCycles } from './cycles.js';
import { openReadonlyOrFail } from './db.js';
import { buildEmbeddings, EMBEDDING_STRATEGIES, MODELS, search } from './embedder.js';
import {
buildEmbeddings,
DEFAULT_MODEL,
EMBEDDING_STRATEGIES,
MODELS,
search,
} from './embedder.js';
import { exportDOT, exportJSON, exportMermaid } from './export.js';
import { setVerbose } from './logger.js';
import {
Expand Down Expand Up @@ -423,12 +429,13 @@ program
.command('models')
.description('List available embedding models')
.action(() => {
const defaultModel = config.embeddings?.model || DEFAULT_MODEL;
console.log('\nAvailable embedding models:\n');
for (const [key, config] of Object.entries(MODELS)) {
const def = key === 'minilm' ? ' (default)' : '';
const ctx = config.contextWindow ? `${config.contextWindow} ctx` : '';
for (const [key, cfg] of Object.entries(MODELS)) {
const def = key === defaultModel ? ' (default)' : '';
const ctx = cfg.contextWindow ? `${cfg.contextWindow} ctx` : '';
console.log(
` ${key.padEnd(12)} ${String(config.dim).padStart(4)}d ${ctx.padEnd(9)} ${config.desc}${def}`,
` ${key.padEnd(12)} ${String(cfg.dim).padStart(4)}d ${ctx.padEnd(9)} ${cfg.desc}${def}`,
);
}
console.log('\nUsage: codegraph embed --model <name> --strategy <structured|source>');
Expand All @@ -442,8 +449,7 @@ program
)
.option(
'-m, --model <name>',
'Embedding model: minilm (default), jina-small, jina-base, jina-code, nomic, nomic-v1.5, bge-large. Run `codegraph models` for details',
'minilm',
'Embedding model (default from config or minilm). Run `codegraph models` for details',
)
.option(
'-s, --strategy <name>',
Expand All @@ -458,7 +464,8 @@ program
process.exit(1);
}
const root = path.resolve(dir || '.');
await buildEmbeddings(root, opts.model, undefined, { strategy: opts.strategy });
const model = opts.model || config.embeddings?.model || DEFAULT_MODEL;
await buildEmbeddings(root, model, undefined, { strategy: opts.strategy });
});

program
Expand Down
2 changes: 1 addition & 1 deletion src/embedder.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const MODELS = {

export const EMBEDDING_STRATEGIES = ['structured', 'source'];

export const DEFAULT_MODEL = 'minilm';
export const DEFAULT_MODEL = 'nomic-v1.5';
const BATCH_SIZE_MAP = {
minilm: 32,
'jina-small': 16,
Expand Down
Loading