-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
9cb8272
to
645b6d6
Compare
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return random.choices(arr, k=num) | |
return random.sample(arr, k=num) |
I think we should not pick the same thing twice.
# strip quotations | ||
line = line.strip("\"'") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover_prompts: deque = None, | |
leftover_prompts: deque | None = None, |
Please don't hate me for this :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I... I... :D
if len(new_prompts) > total_prompts: | ||
# Save extra prompts for next batch | ||
leftover_prompts.extend(new_prompts[total_prompts:]) |
There was a problem hiding this comment.
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.
No description provided.