Skip to content

Commit 3a5b36f

Browse files
committed
Update README
1 parent d950c9a commit 3a5b36f

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

README.md

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,28 @@ You can modify the list of models by adding a new file, `models/{model_name}.jl`
1717
Ideally, `model_name` would be self-explanatory, i.e. it would serve to illustrate exactly one feature and the name would indicate this.
1818
However, if necessary, you can add further explanatory comments inside the model definition file.
1919

20+
The basic structure of this file should look like this, where `model_name` is replaced accordingly:
21+
22+
```julia
23+
#=
24+
You can add any explanatory comments here if necessary
25+
=#
26+
27+
# Imports if necessary
28+
using MyOtherPackage: some_function
29+
30+
# Define data if necessary
31+
data = ...
32+
33+
@model function model_name(data, ...)
34+
# Define your model here
35+
...
36+
end
37+
38+
# Instantiate the model
39+
model = model_name(data, ...)
40+
```
41+
2042
**Dependencies**
2143

2244
Inside this file, you do not need to call `using Turing` or any of the AD backends.
@@ -29,27 +51,29 @@ However, you will have to make sure to import any other packages that your model
2951

3052
Each file in `models/` is evaluated within its own module, so you can declare data variables, etc. without worrying about name clashes.
3153

32-
Once you have defined your model as `@model function model_name(...)`, you will need to create a model object.
33-
As the final line in the file, the creation of the Turing model object using `model = model_name(...)`.
54+
Models can be defined as usual with `@model function model_name(...)`.
55+
56+
The last line in the file should be the creation of the Turing model object using `model = model_name(...)`.
3457
(It is mandatory for the model object to be called `model`.)
3558

3659
**Inclusion in `main.jl`**
3760

38-
Finally, inside `main.jl`, call `@include_model category_heading model_name`.
39-
Both `category_heading` and `model_name` should be strings.
40-
41-
`category_heading` is a string that is used to determine which table the model appears under on the website.
61+
Finally, inside `main.jl`, add a call to `@include_model category_heading model_name`.
62+
**Both `category_heading` and `model_name` should be strings.**
4263

43-
Note that for CI to run properly, `model_name` **must** be consistent between the following:
64+
`category_heading` is used to determine which table the model appears under on the website.
65+
This should be self-explanatory if you look at the [current website](https://turinglang.org/ADTests).
4466

45-
- The name of the model itself i.e. `@model function model_name(...)`
46-
- The filename i.e. `models/model_name.jl`
47-
- The name of the model in `main.jl` i.e. `@include_model "Category Heading" "model_name"`
67+
> [!IMPORTANT]
68+
> Note that for CI to run properly, `model_name` **must** be consistent between the following:
69+
>
70+
> - The name of the model itself i.e. `@model function model_name(...)`
71+
> - The filename i.e. `models/model_name.jl`
72+
> - The name of the model in `main.jl` i.e. `@include_model "Category Heading" "model_name"`
4873
49-
> [!NOTE]
50-
> This setup does admittedly feel a bit complicated.
51-
> Unfortunately I could not find a simpler way to get all the components (Julia, Python, web app) to work together in an automated fashion.
52-
> Hopefully it is a small price to pay for the ability to just add a new model and have it be automatically included on the website.
74+
(This setup does admittedly feel a bit complicated.
75+
Unfortunately I could not find a simpler way to get all the components (Julia, Python, web app) to work together in an automated fashion.
76+
Hopefully it is a small price to pay for the ability to just add a new model and have it be automatically included on the website.)
5377

5478
## I want to edit the website!
5579

0 commit comments

Comments
 (0)