PaperDefaultAttribute
Attributes · AiDotNet.Attributes
Declares the value a model’s research paper specifies for one options property, with the place in the paper it comes from, so a generated test can check that the options constructor really ships it.
Inheritance: Attribute → PaperDefaultAttribute
For Beginners
A paper says things like “we use a discount factor of 0.99”. This attribute writes that sentence down next to the setting, with the page or table it came from, and the tests then make sure the library’s default really is 0.99.
How It Works
[PaperOptimizer] records a paper’s training recipe on the model class, because a recipe is
one unit: optimizer, learning rate, schedule and clipping only make sense together. Architecture and
algorithm hyperparameters are the opposite - each is an independent claim about one number - so
this attribute sits on the individual property it describes. Keeping the declared value next to the
default it constrains means a reviewer sees both on one line, a renamed property carries its
declaration with it, and no property name is ever spelled as a string.
The paper itself is the [ResearchPaper] of the model the options configure, so it is not
repeated here. Source names WHERE in that paper the value is stated and is required
(ADNOPT003), for the same reason PaperOptimizer.Source is: an uncited number reads as
authoritative and is never re-checked.
Only declare a value the paper actually states. A property the paper is silent on stays undeclared; it is not a defect for a library default to fill a gap the authors left.
What is checked. At build time ADNOPT003 rejects a declaration with no source or with a value
whose type cannot be assigned to the property. At test time a generated test constructs the options
class with its parameterless constructor and requires every declared property to hold exactly the
declared value (numbers are compared after conversion to Double, so a generic
T LearningRate can be declared as 0.001).
Inherited properties. A property declared on a shared base (SequenceModelOptions.VocabSize,
GanOptions.LatentSize) and given its value by each model’s options constructor is declared on that
options class instead, naming the property with nameof so a rename still carries the declaration:
[PaperDefault(nameof(VocabSize), 65024, Source = "Table 1")]. The nearest declaration wins, so a
derived options class can restate a value its base declares.
Example
using AiDotNet.Attributes;
using AiDotNet.Models.Options;
public class MyAgentOptions : ModelOptions
{
[PaperDefault(0.99, Source = "Extended Data Table 1: discount factor")]
public double DiscountFactor { get; set; } = 0.99;
[PaperDefault(new[] { 64, 64 }, Source = "Sec. 5.1: two hidden layers of 64 units")]
public int[] HiddenLayers { get; set; } = { 64, 64 };
}
Constructors
| Constructor | Summary |
|---|---|
PaperDefaultAttribute(object value) |
Declares the paper’s value for this property. |
PaperDefaultAttribute(string property, object value) |
Declares, on an options class, the paper’s value for one of its properties, typically one inherited from a shared base and set by this class’s constructor. |
Properties
| Property | Summary |
|---|---|
object Value { get; } |
The value the paper states for this property. |
string Property { get; } |
The property a class-level declaration is for; null when the attribute sits on the property itself. |
string Source { get; set; } |
Where in the paper the value is stated, for example `“Sec. |