loadModel method

  1. @override
Future<bool> loadModel({
  1. required String modelPath,
  2. int contextLength = 4096,
  3. int threads = 0,
  4. int? threadsBatch,
  5. int? batchSize,
  6. int gpuLayers = 0,
  7. bool preferPerformanceCores = true,
  8. int? maxModelBytes,
  9. double temperature = 0.7,
  10. int topK = 40,
  11. double topP = 0.95,
  12. double? minP,
  13. double? typicalP,
  14. double? topNSigma,
  15. int? mirostatType,
  16. double? mirostatTau,
  17. double? mirostatEta,
  18. double? repeatPenalty,
  19. double? frequencyPenalty,
  20. double? presencePenalty,
  21. int? repeatLastN,
  22. int? minKeep,
})
override

Implementation

@override
Future<bool> loadModel({
  required String modelPath,
  int contextLength = 4096,
  int threads = 0,
  int? threadsBatch,
  int? batchSize,
  int gpuLayers = 0,
  bool preferPerformanceCores = true,
  int? maxModelBytes,
  double temperature = 0.7,
  int topK = 40,
  double topP = 0.95,
  double? minP,
  double? typicalP,
  double? topNSigma,
  int? mirostatType,
  double? mirostatTau,
  double? mirostatEta,
  double? repeatPenalty,
  double? frequencyPenalty,
  double? presencePenalty,
  int? repeatLastN,
  int? minKeep,
}) async {
  if (kDebugMode) {
    // ignore: avoid_print
    print('[MaathaiLlamma] loadModel(path=$modelPath, ctx=$contextLength, threads=$threads, threadsBatch=${threadsBatch ?? 0}, batchSize=${batchSize ?? 0}, gpuLayers=$gpuLayers, preferPerformanceCores=$preferPerformanceCores, maxModelBytes=${maxModelBytes ?? -1})');
  }
  final loaded = await methodChannel.invokeMethod<bool>('loadModel', {
    'modelPath': modelPath,
    'contextLength': contextLength,
    'threads': threads,
    'threadsBatch': threadsBatch,
    'batchSize': batchSize,
    'gpuLayers': gpuLayers,
    'preferPerformanceCores': preferPerformanceCores,
    'maxModelBytes': maxModelBytes,
    'temperature': temperature,
    'topK': topK,
    'topP': topP,
    'minP': minP,
    'typicalP': typicalP,
    'topNSigma': topNSigma,
    'mirostatType': mirostatType,
    'mirostatTau': mirostatTau,
    'mirostatEta': mirostatEta,
    'repeatPenalty': repeatPenalty,
    'frequencyPenalty': frequencyPenalty,
    'presencePenalty': presencePenalty,
    'repeatLastN': repeatLastN,
    'minKeep': minKeep,
  });
  if (kDebugMode) {
    // ignore: avoid_print
    print('[MaathaiLlamma] loadModel -> ${loaded ?? false}');
  }
  return loaded ?? false;
}