Skip to content

Commit 7f2cf8b

Browse files
committed
Fix all 69 Javadoc warnings by adding missing comments
Add class-level Javadoc to RopeScalingType; add per-constant comments to CacheType, GpuSplitMode, RopeScalingType, and Sampler; add constructor Javadoc to InferenceParameters and Pair; add field comment to JsonParameters.serializer; add @return tags to ModelMeta.getVocabType and getNVocab; add native-method Javadoc to LlamaModel.applyTemplate(String). https://claude.ai/code/session_01CghtTrLwfpzFEeZMoEzNqM
1 parent 890c561 commit 7f2cf8b

9 files changed

Lines changed: 65 additions & 5 deletions

File tree

src/main/java/net/ladenthin/llama/InferenceParameters.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ public final class InferenceParameters extends JsonParameters {
5757
private static final String PARAM_REASONING_FORMAT = "reasoning_format";
5858
private static final String PARAM_REASONING_BUDGET_TOKENS = "reasoning_budget_tokens";
5959

60+
/**
61+
* Creates inference parameters with the given prompt.
62+
*
63+
* @param prompt the prompt to start generation with
64+
*/
6065
public InferenceParameters(String prompt) {
6166
// we always need a prompt
6267
setPrompt(prompt);

src/main/java/net/ladenthin/llama/JsonParameters.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ abstract class JsonParameters {
1616
// The JNI code for a proper Java-typed data object is comparatively too complex and hard to maintain.
1717
final Map<String, String> parameters = new HashMap<>();
1818

19+
/** Serializer for converting Java values to JSON-safe strings. */
1920
protected final ParameterJsonSerializer serializer = new ParameterJsonSerializer();
2021

2122
@Override

src/main/java/net/ladenthin/llama/LlamaModel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ public LlamaOutput rerank(String query, String... documents) {
200200
public String applyTemplate(InferenceParameters parameters) {
201201
return applyTemplate(parameters.toString());
202202
}
203+
/**
204+
* @param parametersJson JSON-serialized inference parameters
205+
* @return the formatted chat template string
206+
*/
203207
public native String applyTemplate(String parametersJson);
204208

205209
/**

src/main/java/net/ladenthin/llama/ModelMeta.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ public final class ModelMeta {
2020
this.node = node;
2121
}
2222

23-
/** Vocabulary type identifier (e.g. SPM = 2, BPE = 1). */
23+
/**
24+
* @return vocabulary type identifier (e.g. SPM = 2, BPE = 1)
25+
*/
2426
public int getVocabType() {
2527
return node.path("vocab_type").asInt(0);
2628
}
2729

28-
/** Total number of tokens in the model vocabulary. */
30+
/**
31+
* @return total number of tokens in the model vocabulary
32+
*/
2933
public int getNVocab() {
3034
return node.path("n_vocab").asInt(0);
3135
}

src/main/java/net/ladenthin/llama/Pair.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,36 @@
22

33
import java.util.Objects;
44

5+
/**
6+
* A generic immutable key-value pair.
7+
*
8+
* @param <K> the key type
9+
* @param <V> the value type
10+
*/
511
public class Pair<K, V> {
612

713
private final K key;
814
private final V value;
9-
15+
16+
/**
17+
* @param key the key
18+
* @param value the value
19+
*/
1020
public Pair(K key, V value) {
1121
this.key = key;
1222
this.value = value;
1323
}
14-
24+
25+
/**
26+
* @return the key
27+
*/
1528
public K getKey() {
1629
return key;
1730
}
18-
31+
32+
/**
33+
* @return the value
34+
*/
1935
public V getValue() {
2036
return value;
2137
}

src/main/java/net/ladenthin/llama/args/CacheType.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@
55
*/
66
public enum CacheType implements CliArg {
77

8+
/** 32-bit float. */
89
F32("f32"),
10+
/** 16-bit float. */
911
F16("f16"),
12+
/** 16-bit brain float. */
1013
BF16("bf16"),
14+
/** 8-bit quantization, scheme 0. */
1115
Q8_0("q8_0"),
16+
/** 4-bit quantization, scheme 0. */
1217
Q4_0("q4_0"),
18+
/** 4-bit quantization, scheme 1. */
1319
Q4_1("q4_1"),
20+
/** 4-bit non-linear importance quantization. */
1421
IQ4_NL("iq4_nl"),
22+
/** 5-bit quantization, scheme 0. */
1523
Q5_0("q5_0"),
24+
/** 5-bit quantization, scheme 1. */
1625
Q5_1("q5_1");
1726

1827
private final String argValue;

src/main/java/net/ladenthin/llama/args/GpuSplitMode.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
*/
66
public enum GpuSplitMode implements CliArg {
77

8+
/** No split; use a single GPU. */
89
NONE("none"),
10+
/** Split by transformer layer across GPUs. */
911
LAYER("layer"),
12+
/** Split by tensor row across GPUs. */
1013
ROW("row");
1114

1215
private final String argValue;

src/main/java/net/ladenthin/llama/args/RopeScalingType.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
package net.ladenthin.llama.args;
22

3+
/**
4+
* RoPE (Rotary Position Embedding) scaling type for {@code --rope-scaling}.
5+
*/
36
public enum RopeScalingType implements CliArg {
47

8+
/** No scaling type specified; use the model default. */
59
UNSPECIFIED("unspecified"),
10+
/** No RoPE scaling applied. */
611
NONE("none"),
12+
/** Linear RoPE scaling. */
713
LINEAR("linear"),
14+
/** YaRN (Yet Another RoPE extensioN) scaling. */
815
YARN2("yarn"),
16+
/** LongRoPE scaling for extended context. */
917
LONGROPE("longrope"),
18+
/** Maximum value sentinel. */
1019
MAX_VALUE("maxvalue");
1120

1221
private final String argValue;

src/main/java/net/ladenthin/llama/args/Sampler.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@
55
*/
66
public enum Sampler implements CliArg {
77

8+
/** DRY (Don't Repeat Yourself) repetition penalty sampler. */
89
DRY("dry"),
10+
/** Top-K sampling: keep only the K most likely tokens. */
911
TOP_K("top_k"),
12+
/** Top-P (nucleus) sampling: keep tokens whose cumulative probability exceeds P. */
1013
TOP_P("top_p"),
14+
/** Typical-P sampling: keep tokens whose local typicality exceeds P. */
1115
TYP_P("typ_p"),
16+
/** Min-P sampling: remove tokens below a minimum probability threshold. */
1217
MIN_P("min_p"),
18+
/** Temperature scaling applied to logits before sampling. */
1319
TEMPERATURE("temperature"),
20+
/** XTC (eXclude Top Choices) sampler. */
1421
XTC("xtc"),
22+
/** Infill-specific sampler for fill-in-the-middle tasks. */
1523
INFILL("infill"),
24+
/** Repetition, frequency, and presence penalties sampler. */
1625
PENALTIES("penalties");
1726

1827
private final String argValue;

0 commit comments

Comments
 (0)