Implement model (and some factor) coder with evolving (#52)

* store code into FBImplementation

* fix path related bugs

* fix a bug

* fix factor related small bugs

* re-submit all model related code

* new code to model coder

* finish the model evolving code

---------

Co-authored-by: xuyang1 <xuyang1@microsoft.com>
This commit is contained in:
Xu Yang
2024-07-10 15:45:43 +08:00
committed by GitHub
parent 63f7bf23da
commit 22e1aa3330
24 changed files with 1243 additions and 291 deletions
@@ -30,7 +30,6 @@ class ModelCodeWriter(TaskGenerator[ModelExperiment]):
description=t.description,
formulation=t.formulation,
variables=t.variables,
execute_desc=mti.execute_desc(),
)
system_prompt = sys_prompt_tpl.render()
@@ -1,8 +1,8 @@
code_implement_sys: -|
You are an assistant whose job is to answer user's question."
code_implement_user: -|
code_implement_sys: |-
You are an assistant whose job is to answer user's question.
code_implement_user: |-
With the following given information, write a python code using pytorch and torch_geometric to implement the model.
This model is in the graph learning field, only have one layer.
The input will be node_feature [num_nodes, dim_feature] and edge_index [2, num_edges] (It would be the input of the forward model)
@@ -13,6 +13,15 @@ code_implement_user: -|
3. model formulation:{{formulation}}
4. model variables:{{variables}}.
You must complete the forward function as far as you can do.
\# Execution
Your implemented code will be exectued in the follow way
{{execute_desc}}
Execution Your implemented code will be executed in the follow way:
The the implemented code will be placed in a file like [uuid]/model.py
We'll import the model in the implementation in file `model.py` after setting the cwd into the directory
- from model import model_cls (So you must have a variable named `model_cls` in the file)
- So your implemented code could follow the following pattern
```Python
class XXXLayer(torch.nn.Module):
...
model_cls = XXXLayer
```
- initialize the model by initializing it `model_cls(input_dim=INPUT_DIM)`
- And then verify the model by comparing the output tensors by feeding specific input tensor.