Single step Environment is not deterministic for BaseGenerator Dataset #3233
Tanuj-Taneja1
started this conversation in
General
Replies: 2 comments
-
|
Hi @Wendong-Fan can you help here |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
to reproduce this issue you can just run the code below, also i am using camel version 0.2.75 import asyncio
from camel.datasets import BaseGenerator, DataPoint
from camel.environments import SingleStepEnv
from camel.verifiers import PythonVerifier
class SimpleGenerator(BaseGenerator):
def __init__(self, **kwargs):
super().__init__(**kwargs)
async def generate_new(self, n: int, **kwargs) -> None:
for i in range(n):
datapoint = DataPoint(
question=f"What is {i} + {i}?",
final_answer=str(i * 2),
)
self._data.append(datapoint)
async def main():
generator = SimpleGenerator(buffer=6, seed=1)
verifier = PythonVerifier()
env = SingleStepEnv(dataset=generator, verifier=verifier)
await env.setup()
for i in range(5):
obs = await env.reset(batch_size=2, seed=5)
print(obs)
await env.close()
if __name__ == "__main__":
asyncio.run(main())[Observation(question='What is 0 + 0?', context={}, metadata={}), Observation(question='What is 1 + 1?', context={}, metadata={})]
[Observation(question='What is 2 + 2?', context={}, metadata={}), Observation(question='What is 3 + 3?', context={}, metadata={})]
[Observation(question='What is 4 + 4?', context={}, metadata={}), Observation(question='What is 5 + 5?', context={}, metadata={})]
[Observation(question='What is 0 + 0?', context={}, metadata={}), Observation(question='What is 1 + 1?', context={}, metadata={})]
[Observation(question='What is 2 + 2?', context={}, metadata={}), Observation(question='What is 3 + 3?', context={}, metadata={})]
Since reset uses async_sample which returns the next datapoint in current dataset, we dont get deterministic results If you think this issue is relevant I can create a new issue and contribute in it |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The reset method in
SingleStepEnv(insingle_step.py) does not actually use the provided seed argument when theBaseGeneratordataset is used.Currently, each call to reset invokes the dataset’s
async_samplemethod, which gives next datapoint every time — even if the same seed is passed. This means the environment does not reset deterministically as expected.This should be relatively easy fix.
Also can we rename the BaseGenerator dataset to a more descriptive something like SyntheticDataset or DynamicDataset.
Beta Was this translation helpful? Give feedback.
All reactions