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

Optimize and fix prompt generation #6

Merged
merged 5 commits into from
Oct 24, 2024

Conversation

mzukowski-reef
Copy link
Contributor

No description provided.

@mzukowski-reef mzukowski-reef force-pushed the optimize-and-fix-prompt-generation branch from 9cb8272 to 645b6d6 Compare September 23, 2024 22:16
@@ -4,17 +4,17 @@

class PromptGeneratingPrompt:
def random_select(self, arr: list[str], num: int = 5) -> str:
random.shuffle(arr)
return ", ".join(arr[:num]) + ", etc"
return random.choices(arr, k=num)
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
return random.choices(arr, k=num)
return random.sample(arr, k=num)

I think we should not pick the same thing twice.

Comment on lines +19 to +20
# strip quotations
line = line.strip("\"'")
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't that mess up lines, where a quote mark is at the start/end of the line, and the other quote in the middle of the line? The strip will only remote the quote at the start/end, not the quote in the middle.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't care - we care ONLY about the lines that are single line prompt - and ends with ? - if result is broken or "not perfect" - it will be ignored

@@ -19,7 +20,10 @@ def generate_prompts(
max_new_tokens: int = 2000,
temperature: float = 1.0,
filepath: str = "prompts.txt",
leftover_prompts: deque = None,
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
leftover_prompts: deque = None,
leftover_prompts: deque | None = None,

Please don't hate me for this :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I... I... :D

Comment on lines +64 to +66
if len(new_prompts) > total_prompts:
# Save extra prompts for next batch
leftover_prompts.extend(new_prompts[total_prompts:])
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need the original value of total_prompts that was passed in the function. We are subtracting the number of prompts generated from this variable.

@mzukowski-reef mzukowski-reef merged commit 3ad9885 into master Oct 24, 2024
2 checks passed
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