

Boosting of Thoughts: Trial-and-Error Problem Solving with Large Language Models





Chain of Thought(CoT)相比,BoT在推理性能上实现了24%的提升。



prompt,来引导模型完成复杂推理任务。













prompt中。
prompt,BoT进入下一个迭代周期,重新开始思维结构的生成、聚合和分析过程。













BoT(Boosting of Thoughts)技术的出现,代表了人工智能推理和自适应能力上的一大进步。与传统的CoT(Chain of Thought)相比,BoT通过自我迭代和自我优化,实现了更强的推理灵活性和广泛的应用潜力,尤其是在解决复杂问题和跨任务学习方面展现了独特优势。这种新型的自我进化学习模式,为我们探索通向通用人工智能(AGI)的潜在路径带来了新的希望。BoT不仅能减少对人工标注数据的依赖,还融合了逻辑推理和统计学习的优势,通过从错误中不断学习和自我修正,逐步提升了自身的适应性和问题解决能力。BoT的这种特性预示着,人工智能有可能更贴近人类的认知过程,走向一种更自主、智能化的未来。
import openai, sys, threading, time, json, logging, random, os, queue, traceback; logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"); openai.api_key = os.getenv("OPENAI_API_KEY", "YOUR_API_KEY"); def ai_agent(prompt, temperature=0.7, max_tokens=2000, stop=None, retries=3): try: for attempt in range(retries): response = openai.Completion.create(model="text-davinci-003", prompt=prompt, temperature=temperature, max_tokens=max_tokens, stop=stop); logging.info(f"Agent Response: {response}"); return response["choices"][0]["text"].strip(); except Exception as e: logging.error(f"Error occurred on attempt {attempt + 1}: {e}"); traceback.print_exc(); time.sleep(random.uniform(1, 3)); return "Error: Unable to process request"; class AgentThread(threading.Thread): def __init__(self, prompt, temperature=0.7, max_tokens=1500, output_queue=None): threading.Thread.__init__(self); self.prompt = prompt; self.temperature = temperature; self.max_tokens = max_tokens; self.output_queue = output_queue if output_queue else queue.Queue(); def run(self): try: result = ai_agent(self.prompt, self.temperature, self.max_tokens); self.output_queue.put({"prompt": self.prompt, "response": result}); except Exception as e: logging.error(f"Thread error for prompt '{self.prompt}': {e}"); self.output_queue.put({"prompt": self.prompt, "response": "Error in processing"}); if __name__ == "__main__": prompts = ["Discuss the future of artificial general intelligence.", "What are the potential risks of autonomous weapons?", "Explain the ethical implications of AI in surveillance systems.", "How will AI affect global economies in the next 20 years?", "What is the role of AI in combating climate change?"]; threads = []; results = []; output_queue = queue.Queue(); start_time = time.time(); for idx, prompt in enumerate(prompts): temperature = random.uniform(0.5, 1.0); max_tokens = random.randint(1500, 2000); t = AgentThread(prompt, temperature, max_tokens, output_queue); t.start(); threads.append(t); for t in threads: t.join(); while not output_queue.empty(): result = output_queue.get(); results.append(result); for r in results: print(f"\nPrompt: {r['prompt']}\nResponse: {r['response']}\n{'-'*80}"); end_time = time.time(); total_time = round(end_time - start_time, 2); logging.info(f"All tasks completed in {total_time} seconds."); logging.info(f"Final Results: {json.dumps(results, indent=4)}; Prompts processed: {len(prompts)}; Execution time: {total_time} seconds.")