Skip to content

feat: enable drafting with knowledge#998

Merged
RolandMinrui merged 40 commits intomainfrom
knowledge_drafting
Jul 9, 2025
Merged

feat: enable drafting with knowledge#998
RolandMinrui merged 40 commits intomainfrom
knowledge_drafting

Conversation

@RolandMinrui
Copy link
Contributor

@RolandMinrui RolandMinrui commented Jun 27, 2025

Description

Motivation and Context

How Has This Been Tested?

  • If you are adding a new feature, test on your own test scripts.

Screenshots of Test Results (if appropriate):

  1. Your own tests:

Types of changes

  • Fix bugs
  • Add new feature
  • Update documentation

📚 Documentation preview 📚: https://RDAgent--998.org.readthedocs.build/en/998/

@RolandMinrui RolandMinrui marked this pull request as draft June 27, 2025 09:14
coding_fail_reanalyze_threshold: int = 3

debug_timeout: int = 600
debug_timeout: int = 900
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to change it back and change it with env.

- Step 1: If submission format has issues, prioritize fixing them before proceeding. If the format is correct and it's the first valid submission ever (there has never been valid submissions in the past), set `"Replace Best Result": "yes"`. If the format is correct and this is not the first valid submission, proceed to Step 2.
- Step 2: If evaluation alignment issues are identified (validation approach does not follow competition requirements), address these methodological discrepancies immediately.
- Step 3: If new results significantly worse than SOTA, or repeated hyperparameter adjustments yield no improvement, it might be time to rethink or shift focus.
- Step 4: If the result is only slightly better than the SOTA, but the code modifications are extensive (e.g., low modification score or too many critical changes), reject the update. Prefer small-step improvements with minimal changes. Set `"Replace Best Result": "no"` and explain in `"Reasoning"` starting with `[Code Change Too Large]`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this PR focus on drafting?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want other changes can be evaluated alone, we can create a seperate PR.



class DSDraftExpGen(ExpGen):
class CodingSketch(BaseModel):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have to duplicate this. We can import it directly



# TODO: merge the two version draft in the further
def draft_exp_in_pipeline(scen: Scenario, trace: DSTrace) -> None | DSDraftExpGenV2:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use router to implement this feature

@jingyuanlm jingyuanlm force-pushed the knowledge_drafting branch from 747dee1 to 9329487 Compare July 7, 2025 08:57
)


print('debug')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean the code.


from filelock import FileLock
from fuzzywuzzy import fuzz # type: ignore[import-untyped]
#from fuzzywuzzy import fuzz # type: ignore[import-untyped]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this ?

@@ -0,0 +1 @@
print('sss') No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean code

@@ -0,0 +1,17 @@

from dev.feedback import DSExperiment2Feedback
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can have better folder structure.
Let's discussion this later

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feedback/

  • init.py
  • draft.py


return hypothesis_feedback

class DSDraftExperiment2Feedback(DSExperiment2Feedback):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated code


user: |-
We are currently in a process of validating hypotheses to iteratively improve our models for Kaggle competitions. Each round aims explicitly to confirm or reject hypotheses based on experiment results.
We prioritize minimal, incremental code changes that lead to measurable improvements.**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this PR focus on drafting?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

design a module.

Include + self customized.

self.trace = DSTrace(scen=scen)
self.summarizer = DSExperiment2Feedback(scen)

#self.summarizer = DSExperiment2Feedback(scen)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#self.summarizer = DSExperiment2Feedback(scen)

# Drafting Stage
if draft_exp := draft_exp_in_decomposition(self.scen, trace):
return draft_exp
# if draft_exp := draft_exp_in_decomposition(self.scen, trace):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can keep the orginal code and leave the TODO comments.

) -> DSExperiment:

pipeline = DS_RD_SETTING.coder_on_whole_pipeline
if not pipeline and (draft_exp := draft_exp_in_decomposition(self.scen, trace)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not break original logic if not necessary

return self.base_exp_gen.gen(trace)


class DraftRouterExpGenV2(ExpGen):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have already two version of router alreadY?

@@ -0,0 +1,17 @@

from dev.feedback import DSExperiment2Feedback
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feedback/

  • init.py
  • draft.py


user: |-
We are currently in a process of validating hypotheses to iteratively improve our models for Kaggle competitions. Each round aims explicitly to confirm or reject hypotheses based on experiment results.
We prioritize minimal, incremental code changes that lead to measurable improvements.**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

design a module.

Include + self customized.

**[DataPreprocess] → [EDA] → [FeatureEngineer] → [Model] → [Tuning] → [Ensemble]**

### Resource Note
**You have access to a 40GB V100 GPU.**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard code.


### Resource Note
**You have access to a 40GB V100 GPU.**
You are **not restricted to lightweight models**. You may use medium to large pretrained architectures (e.g., EfficientNet-B3/B5, ConvNeXt-Tiny, Swin-S) **if they fit within the training time budget**.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not so strict.


- During [Model] or [Tuning], always estimate and test the largest **batch size** that fits into available memory to **maximize throughput**.
- Use `nvidia-smi` or code-level profiling to find the optimal **batch size / num_workers**.
- If runtime is a constraint, assume a **budget of 1.5–2 hours total for training + inference** in the first version.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard code




# knowledge:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

)
else:
return None
# TODO: merge the two version draft in the further
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this. It has been in router.

return self.base_exp_gen.gen(trace)


"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it.

"""Hypothesis generation class"""

summarizer: str = "rdagent.scenarios.data_science.dev.feedback.DSExperiment2Feedback"
summarizer_version: str = "exp_feedback" # exp_feedback or exp_feedback_draft
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

summarizer_init_kwargs: dict = {.....}

self.trace = DSTrace(scen=scen)
self.summarizer = DSExperiment2Feedback(scen)

self.summarizer = import_class(PROP_SETTING.summarizer)(scen=scen, version=PROP_SETTING.summarizer_version)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    self.summarizer = import_class(PROP_SETTING.summarizer)(scen=scen, **)

from rdagent.utils.agent.tpl import T


class CodingSketch(BaseModel):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import from utils

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after merge master

@RolandMinrui RolandMinrui marked this pull request as ready for review July 9, 2025 08:30
@RolandMinrui RolandMinrui merged commit 8e385eb into main Jul 9, 2025
9 checks passed
@RolandMinrui RolandMinrui deleted the knowledge_drafting branch July 9, 2025 10:36
licong01-cloud pushed a commit to licong01-cloud/RD-Agent that referenced this pull request Dec 13, 2025
* add pipeline for drafting v2

* fix the pipeline and add general knowledge

* debug

* fix bug

* fix bug

* change draft version1

* add function calling to task gen

* fix circular import bug

* change draft version3

* exp1_test

* feat: add DraftRouterExpGen and make summarizer configurable

* Update rdagent/scenarios/data_science/proposal/exp_gen/proposal.py

* change code structure

* stashed changes

* test

* test1

* revert conf.py

* add runtime enviornment info to general knowledge

* remove redundant code

* clean code

* remove files

* reformat

* fix bug

* fix bug

* simplify code

* fix minor bug

* fix bug and reformat

* revert config

* remove unused prompt

* add general knowledge

* fix ci

---------

Co-authored-by: Xu <v-xuminrui@microsoft.com>
Co-authored-by: jingyuanlm <842442862@qq.com>
Co-authored-by: Young <afe.young@gmail.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants