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

IndexError in critique_and_refine Method #12

Open
cn-knight opened this issue Dec 22, 2024 · 0 comments
Open

IndexError in critique_and_refine Method #12

cn-knight opened this issue Dec 22, 2024 · 0 comments

Comments

@cn-knight
Copy link

IndexError in critique_and_refine Method
Error: IndexError: list index out of range occurs in the critique_and_refine method while accessing refined_prompts[0] after applying regex matching.
Cause: The regex pattern DatasetSpecificProcessing.TEXT_DELIMITER_PATTERN fails to find any matches in the response content generated by chat_completion. This results in an empty list, causing the out-of-range access.
Impact: The project fails to complete the prompt refinement step, halting the execution of get_best_prompt.
Steps to Reproduce:
Call the method gp.get_best_prompt(use_examples=True, run_without_train_examples=False, generate_synthetic_examples=False).
Observe the failure during the execution of the critique_and_refine method in core_logic.py.
Suggested Fix:
Add a validation check to handle cases where regex matches are empty:
python
Copy code
matches = re.findall(DatasetSpecificProcessing.TEXT_DELIMITER_PATTERN, refined_prompts)
if not matches:
raise ValueError(
"Regex pattern did not match any content in refined_prompts. Check if the prompt generation or regex pattern is correct."
)
refined_prompts = matches[0]
Debug the raw response content (refined_prompts) to confirm its format and ensure compatibility with the regex pattern.
Additional Notes:
The issue seems related to incorrect or incomplete responses generated by chat_completion.
Ensure that the regex pattern (DatasetSpecificProcessing.TEXT_DELIMITER_PATTERN) matches the format of the refined_prompts content.
Verify the behavior of the chat_completion function and confirm that it generates a valid output for refinement.

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

No branches or pull requests

1 participant