exportSmolLM2 function
Implementation
Future<void> exportSmolLM2({
required String configPath,
required String tokenizerPath,
required String modelPath,
required String outputPath,
QuantType quantType = QuantType.q16,
}) async {
print('=== SmolLM2 Export ===');
print('Paths:');
print(' config: $configPath');
print(' tokenizer: $tokenizerPath');
print(' model: $modelPath');
print(' output: $outputPath');
print(' quantize: ${quantType.name}');
print('Loading config...');
final config = HFConfig.fromJson(
jsonDecode(await File(configPath).readAsString()),
);
print('Loading tokenizer...');
final tokenizer = await HFTokenizer.load(tokenizerPath);
print('Loading tensors...');
final repo = await TensorRepositoryLoader.load(modelPath);
final sink = File(outputPath).openWrite();
final bw = DataWriter(sink);
final exporter = SmolLM2Exporter(
config: config,
tokenizer: tokenizer,
repo: repo,
writer: TensorBinaryWriter(bw),
);
await exporter.export(quantType);
await sink.flush();
await sink.close();
}