Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use auto gen seed when using LLM cache #441

Merged
merged 15 commits into from
Oct 21, 2024
Merged

feat: use auto gen seed when using LLM cache #441

merged 15 commits into from
Oct 21, 2024

Conversation

XianBW
Copy link
Collaborator

@XianBW XianBW commented Oct 18, 2024

Description

By two configs in RD_AGENT_SETTINGS, you can control the behavior of returning answers to the same question when LLM caching is enabled.
- use_auto_chat_cache_seed_gen: bool = False
- init_chat_cache_seed: int = 42

Behavior

Under setting: use_chat_cache=True, dump_chat_cache=True;
Given one question: Q, ask LLM 2 times;

Responses list is: (R1 ≠ R2 ≠ R3 ≠ R4 ≠ R5)

  • use_auto_chat_cache_seed_gen=False: [R1, R1]
  • use_auto_chat_cache_seed_gen=True, init_chat_cache_seed=42: [R2, R3]
  • use_auto_chat_cache_seed_gen=True, init_chat_cache_seed=10: [R4, R5]

Motivation and Context

How Has This Been Tested?

  • Pass the test by running: pytest test/oai/test_completion.py under directory of RD-Agent.
    • test_chat_cache
    • test_chat_cache_multiprocess

Screenshots of Test Results (if appropriate):

  1. Pipeline test:
  2. Your own tests:

Types of changes

  • Fix bugs
  • Add new feature
  • Update documentation

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

results = [
pool.apply_async(_subprocess_wrapper(f, APIBackend.cache_seed_gen.get_next_seed()), args=args)
pool.apply_async(_subprocess_wrapper, args=(f, random.randint(0, 10000), args)) # noqa: S311
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use get_next_seed;
We may use other random seed mechanism if we want to solve the confliction with random.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why should we use # noqa: S311?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

S311, i don't think we need this encryption requirements

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please use get_next_seed; We may use other random seed mechanism if we want to solve the confliction with random.

APIBackend cannot be called here because a circular import occurs

Copy link
Contributor

Choose a reason for hiding this comment

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

Import it in the function to avoid circular import

return random.randint(0, 10000) # noqa: S311


cache_seed_gen = CacheSeedGen()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use upper case and add more specific prefix.
For example LLM_CACHE_SEED_GEN

@XianBW XianBW merged commit ca15365 into main Oct 21, 2024
8 checks passed
@XianBW XianBW deleted the cache_seed branch October 21, 2024 03:32
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.

2 participants