Merge pull request #3475 from SillyTavern/ollama-batch Ollama: Add num_batch config value
Signed| @@ -183,6 +183,10 @@ ollama: | ||
| 183 | 183 | # * 0: Unload the model immediately after the request |
| 184 | 184 | # * N (any positive number): Keep the model loaded for N seconds after the request. |
| 185 | 185 | keepAlive: -1 |
| 186 | + # Controls the "num_batch" (batch size) parameter of the generation request | |
| 187 | + # * -1: Use the default value of the model | |
| 188 | + # * N (positive number): Use the specified value. Must be a power of 2, e.g. 128, 256, 512, etc. | |
| 189 | + batchSize: -1 | |
| 186 | 190 | # -- ANTHROPIC CLAUDE API CONFIGURATION -- |
| 187 | 191 | claude: |
| 188 | 192 | # Enables caching of the system prompt (if supported). |
| @@ -304,6 +304,7 @@ export const TOGETHERAI_KEYS = [ | ||
| 304 | 304 | export const OLLAMA_KEYS = [ |
| 305 | 305 | 'num_predict', |
| 306 | 306 | 'num_ctx', |
| 307 | + 'num_batch', | |
| 307 | 308 | 'stop', |
| 308 | 309 | 'temperature', |
| 309 | 310 | 'repeat_penalty', |
| @@ -373,6 +373,10 @@ router.post('/generate', jsonParser, async function (request, response) { | ||
| 373 | 373 | |
| 374 | 374 | if (request.body.api_type === TEXTGEN_TYPES.OLLAMA) { |
| 375 | 375 | const keepAlive = getConfigValue('ollama.keepAlive', -1); |
| 376 | + const numBatch = getConfigValue('ollama.batchSize', -1); | |
| 377 | + if (numBatch > 0) { | |
| 378 | + request.body['num_batch'] = numBatch; | |
| 379 | + } | |
| 376 | 380 | args.body = JSON.stringify({ |
| 377 | 381 | model: request.body.model, |
| 378 | 382 | prompt: request.body.prompt, |