Replies: 2 comments 1 reply
-
🤖 Hi @hafsalm, great to see you again! I hope you're doing well. The "n_tokens <= n_batch" error you're encountering typically occurs when the number of tokens specified for a batch exceeds the total number of tokens available. In the context of LangChainJS and the node-llama-cpp package, this could be related to the To resolve this issue, you need to ensure that the Here's a simple way to check and limit the async _call(
prompt: string,
// @ts-expect-error - TS6133: 'options' is declared but its value is never read.
options?: this["ParsedCallOptions"]
): Promise<string> {
try {
const totalTokens = /* the total number of tokens in your model */;
const maxTokens = this?.maxTokens && this?.maxTokens <= totalTokens ? this?.maxTokens : totalTokens;
const promptOptions = {
maxTokens,
temperature: this?.temperature,
topK: this?.topK,
topP: this?.topP,
trimWhitespaceSuffix: this?.trimWhitespaceSuffix,
};
const completion = await this._session.prompt(prompt, promptOptions);
return completion;
} catch (e) {
throw new Error("Error getting prompt completion.");
}
} In this code, Please note that the I hope this helps! Let me know if you have any other questions. SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
Hi, +1. I also have this issue and the provided solution doesn't work for me. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm using the node-llama-cpp package in my project and I've encountered an error that I'm having trouble resolving. The error message is n_tokens <= n_batch.
From what I understand, this error typically occurs when the number of tokens exceeds the batch size. However, I'm not sure how to fix this in my code. Could anyone provide some guidance on what might be causing this error and how to resolve it?
Here's my code(It's a langjs runnable sequence, works well with Ollama, but not working with LlamaCpp):
Beta Was this translation helpful? Give feedback.
All reactions