Context creation options
OptionalloadOptions: LoadOptionsOptional binary loading options (GPU variant selection)
Promise resolving to SessionContext instance
const ctx = await createContext({
modelPath: './model.gguf',
nCtx: 2048,
nThreads: 4
});
try {
const tokens = await ctx.tokenize("Hello");
await ctx.decode(tokens, 0);
const token = ctx.sample({ temperature: 0.7 });
} finally {
ctx.dispose();
}
Create a new inference context
Loads the appropriate native binary (with automatic GPU fallback) and creates an inference context for the specified model.