Chain-of-Recursive-Thoughts进阶技巧:如何自定义思考策略和评估标准
Chain-of-Recursive-Thoughts进阶技巧如何自定义思考策略和评估标准【免费下载链接】Chain-of-Recursive-ThoughtsI made my AI think harder by making it argue with itself repeatedly. It works stupidly well.项目地址: https://gitcode.com/gh_mirrors/ch/Chain-of-Recursive-ThoughtsChain-of-Recursive-Thoughts是一款让AI通过自我反复辩论来深入思考的工具它的工作效果出奇地好。本文将分享如何自定义思考策略和评估标准帮助你充分发挥这款AI工具的潜力让AI思考更加符合你的需求。了解思考策略的核心组件在开始自定义之前我们首先需要了解Chain-of-Recursive-Thoughts中思考策略的核心组件。这些组件在recursive_thinking_ai.py文件中得到了实现它们共同构成了AI的思考框架。思考轮次决定机制思考轮次决定机制是AI思考策略的重要组成部分。它通过分析用户输入的复杂程度自动确定需要进行多少轮思考。在代码中_determine_thinking_rounds方法负责这一功能它会根据问题的复杂程度返回1到5之间的轮次数量。替代方案生成机制替代方案生成机制能够为当前最佳响应生成多个备选方案。_generate_alternatives方法实现了这一功能它会根据当前的最佳响应和用户输入生成具有不同思考角度的替代方案为后续的评估和选择提供素材。响应评估与选择机制响应评估与选择机制是思考策略的核心它负责对当前最佳响应和生成的替代方案进行评估并选择出最优的响应。_evaluate_responses方法实现了这一功能它会根据预设的评估标准对各个响应进行打分并选择得分最高的响应作为新的最佳响应。自定义思考策略的实用方法了解了思考策略的核心组件后我们就可以开始自定义思考策略了。以下是几种实用的自定义方法你可以根据自己的需求选择适合的方法进行调整。调整思考轮次范围默认情况下AI的思考轮次范围是1到5轮。如果你希望AI进行更深入的思考可以适当扩大这个范围。在recursive_thinking_ai.py文件中找到_determine_thinking_rounds方法修改其中的轮次限制即可。例如将轮次范围调整为1到10轮def _determine_thinking_rounds(self, prompt: str) - int: Let the model decide how many rounds of thinking are needed. meta_prompt fGiven this message: {prompt} How many rounds of iterative thinking (1-10) would be optimal to generate the best response? Consider the complexity and nuance required. Respond with just a number between 1 and 10. # ... 其余代码保持不变修改替代方案数量默认情况下AI会为每个思考轮次生成3个替代方案。如果你希望AI考虑更多的可能性可以增加替代方案的数量。在_generate_alternatives方法中修改num_alternatives参数即可。例如将替代方案数量调整为5个def _generate_alternatives(self, base_response: str, prompt: str, num_alternatives: int 5) - List[str]: Generate alternative responses. # ... 其余代码保持不变调整温度参数温度参数控制AI生成响应的创造性和随机性。较高的温度值会使AI生成更加多样化和创造性的响应而较低的温度值则会使AI生成更加保守和确定的响应。在_call_api方法中你可以调整temperature参数来改变AI的思考风格。例如提高初始响应的温度值current_best self._call_api(messages, temperature0.9, streamTrue)优化评估标准的关键步骤评估标准直接影响AI对响应的选择优化评估标准可以使AI的思考结果更加符合你的期望。以下是优化评估标准的关键步骤明确评估维度首先你需要明确评估响应的维度。默认情况下AI会从准确性、清晰度和完整性三个维度进行评估。你可以根据自己的需求添加或修改评估维度。在_evaluate_responses方法中修改评估提示即可。例如添加相关性维度eval_prompt fOriginal message: {prompt} Evaluate these responses and choose the best one: Current best: {current_best} Alternatives: {chr(10).join([f{i1}. {alt} for i, alt in enumerate(alternatives)])} Which response best addresses the original message? Consider accuracy, clarity, completeness, and relevance to the original question. First, respond with ONLY current or a number (1-{len(alternatives)}). Then on a new line, explain your choice in one sentence.调整评估权重除了明确评估维度外你还可以调整各个维度的权重。例如如果你认为准确性比其他维度更重要可以在评估提示中强调准确性的重要性。eval_prompt fOriginal message: {prompt} Evaluate these responses and choose the best one: Current best: {current_best} Alternatives: {chr(10).join([f{i1}. {alt} for i, alt in enumerate(alternatives)])} Which response best addresses the original message? Accuracy is the most important factor, followed by clarity and completeness. First, respond with ONLY current or a number (1-{len(alternatives)}). Then on a new line, explain your choice in one sentence.自定义评估解释评估解释可以帮助你理解AI为什么选择某个响应。你可以自定义评估解释的内容和格式使其更加详细和有用。在_evaluate_responses方法中修改解释部分的提示即可。例如要求AI提供更详细的解释eval_prompt fOriginal message: {prompt} Evaluate these responses and choose the best one: Current best: {current_best} Alternatives: {chr(10).join([f{i1}. {alt} for i, alt in enumerate(alternatives)])} Which response best addresses the original message? Consider accuracy, clarity, and completeness. First, respond with ONLY current or a number (1-{len(alternatives)}). Then on a new line, provide a detailed explanation of your choice, including the strengths and weaknesses of each response.实践案例打造个性化思考流程为了帮助你更好地理解如何自定义思考策略和评估标准以下是一个实践案例展示如何打造个性化的思考流程。案例需求假设你是一名内容创作者需要使用Chain-of-Recursive-Thoughts来生成文章创意。你希望AI能够生成更多样化的创意同时确保创意的实用性和可行性。自定义思考策略调整思考轮次范围为1到8轮让AI进行更深入的思考。将替代方案数量增加到5个增加创意的多样性。提高替代方案生成的温度参数到0.9鼓励AI生成更具创造性的想法。优化评估标准添加创意性和实用性两个评估维度。调整评估权重将创意性和实用性设为最重要的两个维度。要求AI在评估解释中详细说明每个创意的潜在应用场景。实现代码以下是实现上述自定义的关键代码修改# 修改思考轮次范围 def _determine_thinking_rounds(self, prompt: str) - int: meta_prompt fGiven this message: {prompt} How many rounds of iterative thinking (1-8) would be optimal to generate creative article ideas? Consider the complexity and nuance required. Respond with just a number between 1 and 8. # ... 其余代码保持不变 # 修改替代方案数量和温度参数 def _generate_alternatives(self, base_response: str, prompt: str, num_alternatives: int 5) - List[str]: # ... 其余代码保持不变 alternative self._call_api(messages, temperature0.9 i * 0.1, streamTrue) # ... 其余代码保持不变 # 优化评估标准 def _evaluate_responses(self, prompt: str, current_best: str, alternatives: List[str]) - tuple[str, str]: eval_prompt fOriginal message: {prompt} Evaluate these article ideas and choose the best one: Current best: {current_best} Alternatives: {chr(10).join([f{i1}. {alt} for i, alt in enumerate(alternatives)])} Which idea is the most creative and practical? Creative and practical are the most important factors. First, respond with ONLY current or a number (1-{len(alternatives)}). Then on a new line, explain your choice and describe potential application scenarios for the selected idea. # ... 其余代码保持不变通过以上自定义AI将能够生成更多样化、更具创意且实用的文章创意帮助你更好地完成内容创作工作。总结与下一步行动通过本文的介绍你已经了解了如何自定义Chain-of-Recursive-Thoughts的思考策略和评估标准。从调整思考轮次和替代方案数量到优化评估维度和权重这些方法可以帮助你打造个性化的AI思考流程让AI更好地满足你的需求。下一步你可以尝试修改recursive_thinking_ai.py文件中的参数观察AI思考过程的变化。根据自己的具体需求设计独特的评估标准进一步优化AI的思考结果。探索如何将自定义的思考策略和评估标准应用到不同的场景中如写作、编程、决策等。Chain-of-Recursive-Thoughts为AI思考提供了强大的框架通过不断尝试和优化你一定能够充分发挥它的潜力让AI成为你工作和学习的得力助手。要开始使用Chain-of-Recursive-Thoughts请先克隆仓库https://gitcode.com/gh_mirrors/ch/Chain-of-Recursive-Thoughts然后按照项目中的说明进行安装和配置。祝你使用愉快【免费下载链接】Chain-of-Recursive-ThoughtsI made my AI think harder by making it argue with itself repeatedly. It works stupidly well.项目地址: https://gitcode.com/gh_mirrors/ch/Chain-of-Recursive-Thoughts创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考