Skip to content

Commit 002ac5a

Browse files
committed
Refactor main to delegate single instruction execution to runSingleInstruction, improving code clarity and reuse.
1 parent 1d4b5bc commit 002ac5a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/main/java/org/beehive/gpullama3/LlamaApp.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ private static Sampler createSampler(Model model, Options options) {
137137
return selectSampler(model.configuration().vocabularySize(), options.temperature(), options.topp(), options.seed());
138138
}
139139

140+
private static void runSingleInstruction(Model model, Sampler sampler, Options options) {
141+
String response = model.runInstructOnce(sampler, options);
142+
System.out.println(response);
143+
if (SHOW_PERF_INTERACTIVE) {
144+
LastRunMetrics.printMetrics();
145+
}
146+
}
147+
140148
/**
141149
* Entry point for running the LLaMA-based model with provided command-line arguments.
142150
*
@@ -148,19 +156,15 @@ private static Sampler createSampler(Model model, Options options) {
148156
* @throws IOException
149157
* if model loading or file operations fail.
150158
*/
151-
public static void main(String[] args) throws IOException {
159+
static void main(String[] args) throws IOException {
152160
Options options = Options.parseOptions(args);
153161
Model model = loadModel(options);
154162
Sampler sampler = createSampler(model, options);
155163

156164
if (options.interactive()) {
157165
model.runInteractive(sampler, options);
158166
} else {
159-
String response = model.runInstructOnce(sampler, options);
160-
System.out.println(response);
161-
if (SHOW_PERF_INTERACTIVE) {
162-
LastRunMetrics.printMetrics();
163-
}
167+
runSingleInstruction(model, sampler, options);
164168
}
165169
}
166170
}

0 commit comments

Comments
 (0)