-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
133 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const Self = @This(); | ||
|
||
const std = @import("std"); | ||
|
||
arg_iterator: std.process.ArgIterator, | ||
model_path: []const u8, | ||
|
||
const Option = enum { temperature, top_p, random_seed, n_steps, prompt }; | ||
|
||
pub fn init(allocator: std.mem.Allocator) !Self { | ||
var arg_iterator = try std.process.argsWithAllocator(allocator); | ||
|
||
errdefer arg_iterator.deinit(); | ||
|
||
_ = arg_iterator.next().?; | ||
|
||
const model_path = arg_iterator.next() orelse try help(1); | ||
|
||
while (arg_iterator.next()) |arg| { | ||
try help(if (std.mem.eql(u8, arg, "--help")) 0 else 1); | ||
} | ||
|
||
return Self{ .arg_iterator = arg_iterator, .model_path = model_path }; | ||
} | ||
|
||
pub fn deinit(self: *Self) void { | ||
self.arg_iterator.deinit(); | ||
} | ||
|
||
fn help(exit_status: u8) !noreturn { | ||
const console = if (exit_status == 0) | ||
std.io.getStdOut().writer() | ||
else | ||
std.io.getStdErr().writer(); | ||
|
||
try console.print("Usage: llama2-converter <model_path> [options]\n\n", .{}); | ||
|
||
try console.print("Options:\n", .{}); | ||
try console.print(" --help\n", .{}); | ||
|
||
std.process.exit(exit_status); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const std = @import("std"); | ||
const Checkpoint = @import("checkpoint.zig"); | ||
const ConverterArgs = @import("converter_args.zig"); | ||
|
||
pub fn main() !void { | ||
const allocator = std.heap.page_allocator; | ||
|
||
var args = try ConverterArgs.init(allocator); | ||
|
||
defer args.deinit(); | ||
|
||
const checkpoint = try Checkpoint.init(allocator, args.model_path); | ||
|
||
defer checkpoint.deinit(); | ||
|
||
try checkpoint.writeV1(allocator, args.model_path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters