-
Couldn't load subscription status.
- Fork 22
Minor cleanup #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor cleanup #47
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,8 +1,6 @@ | ||||||||||||||||||
| package org.beehive.gpullama3.model.loader; | ||||||||||||||||||
|
|
||||||||||||||||||
| import org.beehive.gpullama3.LlamaApp; | ||||||||||||||||||
| import org.beehive.gpullama3.Options; | ||||||||||||||||||
| import org.beehive.gpullama3.auxiliary.Timer; | ||||||||||||||||||
| import org.beehive.gpullama3.core.model.GGMLType; | ||||||||||||||||||
| import org.beehive.gpullama3.core.model.GGUF; | ||||||||||||||||||
| import org.beehive.gpullama3.core.model.tensor.ArrayFloatTensor; | ||||||||||||||||||
|
|
@@ -21,6 +19,7 @@ | |||||||||||||||||
| import org.beehive.gpullama3.tokenizer.impl.Qwen3Tokenizer; | ||||||||||||||||||
| import org.beehive.gpullama3.tokenizer.impl.Tokenizer; | ||||||||||||||||||
| import org.beehive.gpullama3.tokenizer.vocabulary.Vocabulary; | ||||||||||||||||||
| import org.beehive.gpullama3.tornadovm.TornadoVMMasterPlan; | ||||||||||||||||||
| import uk.ac.manchester.tornado.api.types.arrays.FloatArray; | ||||||||||||||||||
|
|
||||||||||||||||||
| import java.io.IOException; | ||||||||||||||||||
|
|
@@ -40,11 +39,9 @@ public Model loadModel() { | |||||||||||||||||
| Map<String, Object> metadata = gguf.getMetadata(); | ||||||||||||||||||
| String basename = (String) metadata.get("general.basename"); | ||||||||||||||||||
|
|
||||||||||||||||||
| String modelName = "DeepSeek-R1-Distill-Qwen".equals(basename) | ||||||||||||||||||
| ? "DeepSeek-R1-Distill-Qwen" | ||||||||||||||||||
| : "Qwen2.5"; | ||||||||||||||||||
| String modelName = "DeepSeek-R1-Distill-Qwen".equals(basename) ? "DeepSeek-R1-Distill-Qwen" : "Qwen2.5"; | ||||||||||||||||||
|
|
||||||||||||||||||
| try (var ignored = Timer.log("Load " + modelName + " model")) { | ||||||||||||||||||
| try { | ||||||||||||||||||
| // reuse method of Qwen3 | ||||||||||||||||||
| Vocabulary vocabulary = loadQwen3Vocabulary(metadata); | ||||||||||||||||||
| boolean isDeepSeekR1DistillQwen = "DeepSeek-R1-Distill-Qwen".equals(metadata.get("general.basename")); | ||||||||||||||||||
|
|
@@ -55,11 +52,8 @@ public Model loadModel() { | |||||||||||||||||
| contextLength = modelContextLength; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| int numberOfKeyValueHeads = metadata.containsKey("qwen2.attention.head_count_kv") | ||||||||||||||||||
| ? (int) metadata.get("qwen2.attention.head_count_kv") | ||||||||||||||||||
| : (int) metadata.get("qwen2.attention.head_count"); | ||||||||||||||||||
| Qwen2Configuration config = new Qwen2Configuration( | ||||||||||||||||||
| (int) metadata.get("qwen2.embedding_length"), // dim | ||||||||||||||||||
| int numberOfKeyValueHeads = metadata.containsKey("qwen2.attention.head_count_kv") ? (int) metadata.get("qwen2.attention.head_count_kv") : (int) metadata.get("qwen2.attention.head_count"); | ||||||||||||||||||
|
||||||||||||||||||
| int numberOfKeyValueHeads = metadata.containsKey("qwen2.attention.head_count_kv") ? (int) metadata.get("qwen2.attention.head_count_kv") : (int) metadata.get("qwen2.attention.head_count"); | |
| int numberOfKeyValueHeads; | |
| if (metadata.containsKey("qwen2.attention.head_count_kv")) { | |
| numberOfKeyValueHeads = (int) metadata.get("qwen2.attention.head_count_kv"); | |
| } else { | |
| numberOfKeyValueHeads = (int) metadata.get("qwen2.attention.head_count"); | |
| } |
Copilot
AI
Sep 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This constructor call with multiple parameters on a single line is difficult to read and maintain. Consider formatting each parameter on a separate line for better readability.
| vocabulary.size(), modelContextLength, contextLength, false, (float) metadata.get("qwen2.attention.layer_norm_rms_epsilon"), (float) metadata.get("qwen2.rope.freq_base")); | |
| vocabulary.size(), | |
| modelContextLength, | |
| contextLength, | |
| false, | |
| (float) metadata.get("qwen2.attention.layer_norm_rms_epsilon"), | |
| (float) metadata.get("qwen2.rope.freq_base") | |
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This line exceeds typical line length conventions (appears to be over 100 characters). Consider breaking the ternary operator across multiple lines for better readability.