🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
chore: o1datagen renaming and algorithm description adding (#1382)
正经人王同学b36c344b2a77
diff --git a/README.md b/README.mdindex b1b883deb..64e18e21e 100644--- a/README.md+++ b/README.md@@ -325,8 +325,8 @@ Practical guides and tutorials for implementing specific functionalities in CAME| **[Customer Service Discord Bot with Agentic RAG](https://docs.camel-ai.org/cookbooks/customer_service_Discord_bot_with_agentic_RAG.html)** | Learn how to build a robust customer service bot for Discord using Agentic RAG. || **[Create AI Agents that work with your PDFs using Chunkr & Mistral AI](https://docs.camel-ai.org/cookbooks/agent_with_chunkr_for_pdf_parsing.html)** | Learn how to create AI agents that work with your PDFs using Chunkr and Mistral AI. || **[Data Gen with Real Function Calls and Hermes Format](https://docs.camel-ai.org/cookbooks/data_gen_with_real_function_calls_and_hermes_format.html)** | Explore how to generate data with real function calls and the Hermes format. |-| **[O1 Data Generation with CAMEL and Upload Data to Huggingface](https://docs.camel-ai.org/cookbooks/O1datagen_with_CAMEL_And_Upload_Data_To_Huggingface.html)** | Uncover how to generate O1 data with CAMEL and seamlessly upload it to Huggingface. |-| **[O1datagen with CAMEL And Sft Qwen With Unsolth And Upload Data And Model To Huggingface](https://docs.camel-ai.org/cookbooks/O1datagen_with_CAMEL_And_Sft_Qwen_With_Unsolth_And_Upload_Data_And_Model_To_Huggingface.html)** | Discover how to generate O1 data using CAMEL and SFT Qwen with Unsolth, and seamlessly upload your data and model to Huggingface. |+| **[CoT data Generation with CAMEL and Upload Data to Huggingface](https://docs.camel-ai.org/cookbooks/CoTdatagen_with_CAMEL_And_Upload_Data_To_Huggingface.html)** | Uncover how to generate O1 data with CAMEL and seamlessly upload it to Huggingface. |+| **[CoTdatagen with CAMEL And Sft Qwen With Unsolth And Upload Data And Model To Huggingface](https://docs.camel-ai.org/cookbooks/CoTdatagen_with_CAMEL_And_Sft_Qwen_With_Unsolth_And_Upload_Data_And_Model_To_Huggingface.html)** | Discover how to generate O1 data using CAMEL and SFT Qwen with Unsolth, and seamlessly upload your data and model to Huggingface. || **[Customer Service Discord Bot with Agentic RAG supports local model deployment](https://docs.camel-ai.org/cookbooks/customer_service_Discord_bot_using_local_model_with_agentic_RAG.html)** | Learn how to build a robust customer service bot for Discord using Agentic RAG which supports local deployment. |## Utilize Various LLMs as Backendsdiff --git a/camel/datagen/__init__.py b/camel/datagen/__init__.pyindex b5efe677a..aabc9131e 100644--- a/camel/datagen/__init__.py+++ b/camel/datagen/__init__.py@@ -12,10 +12,10 @@# limitations under the License.# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========-from .o1datagen import O1DataGenerator+from .cotdatagen import CoTDataGeneratorfrom .self_instruct import SelfInstructPipeline__all__ = [- "O1DataGenerator",+ "CoTDataGenerator","SelfInstructPipeline",]diff --git a/camel/datagen/o1datagen.py b/camel/datagen/cotdatagen.pysimilarity index 95%rename from camel/datagen/o1datagen.pyrename to camel/datagen/cotdatagen.pyindex 79b28ebf4..a98148abc 100644--- a/camel/datagen/o1datagen.py+++ b/camel/datagen/cotdatagen.py@@ -22,7 +22,7 @@ from camel.agents import ChatAgentfrom camel.logger import get_logger# Get a logger for this module-logger = get_logger('o1datagenerator')+logger = get_logger('CoTDataGenerator')class AgentResponse(BaseModel):@@ -60,11 +60,17 @@ class VerificationResponse(BaseModel):)-class O1DataGenerator:+class CoTDataGenerator:r"""Class for generating and managing data through chat agent interactions.- handling the generation of data by a chat agent, managing golden answers,- and maintaining a solution tree for correct solution steps.+ This module implements a sophisticated Chain of Thought data generation+ system that combines several key algorithms to produce high-quality+ reasoning paths. Methods implemented:++ 1. Monte Carlo Tree Search (MCTS)+ 2. Binary Search Error Detection+ 3. Dual-Agent Verification System+ 4. Solution Tree ManagementArgs:chat_agent (Optional[ChatAgent]): Optional single agent@@ -89,7 +95,7 @@ class O1DataGenerator:golden_answers: Dict[str, str],search_limit: int = 100,):- r"""Initialize the O1DataGenerator.+ r"""Initialize the CoTDataGenerator.This constructor supports both single-agent and dual-agent modes:1. Single-agent mode (legacy): Pass a single chat_agent that will be@@ -131,7 +137,7 @@ class O1DataGenerator:self.search_limit = search_limitself.solution_tree: Dict[str, Dict[str, Union[str, int]]] = {}logger.info(- "O1DataGenerator initialized with search_limit=%d", search_limit+ "CoTDataGenerator initialized with search_limit=%d", search_limit)def get_answer(self, question: str, context: str = "") -> str:@@ -203,6 +209,13 @@ class O1DataGenerator:) -> float:r"""Perform Monte Carlo Tree Search to find the best solution.+ Process:+ a. Selection: Choose promising partial solutions based on previous+ scores+ b. Expansion: Generate new solution steps using the generator agent+ c. Simulation: Evaluate solution quality using similarity scores+ d. Backpropagation: Update solution tree with new findings+Args:question (str): The question to solve.partial_solution (str): The current partial solution.diff --git a/docs/cookbooks/O1datagen_with_CAMEL_And_Sft_Qwen_With_Unsolth_And_Upload_Data_And_Model_To_Huggingface.ipynb b/docs/cookbooks/Cotdatagen_with_CAMEL_And_Sft_Qwen_With_Unsolth_And_Upload_Data_And_Model_To_Huggingface.ipynbsimilarity index 99%rename from docs/cookbooks/O1datagen_with_CAMEL_And_Sft_Qwen_With_Unsolth_And_Upload_Data_And_Model_To_Huggingface.ipynbrename to docs/cookbooks/Cotdatagen_with_CAMEL_And_Sft_Qwen_With_Unsolth_And_Upload_Data_And_Model_To_Huggingface.ipynbindex 95a94be84..92561753f 100644--- a/docs/cookbooks/O1datagen_with_CAMEL_And_Sft_Qwen_With_Unsolth_And_Upload_Data_And_Model_To_Huggingface.ipynb+++ b/docs/cookbooks/Cotdatagen_with_CAMEL_And_Sft_Qwen_With_Unsolth_And_Upload_Data_And_Model_To_Huggingface.ipynb@@ -7,7 +7,7 @@"id": "d80bea45"},"source": [- "# O1datagen with CAMEL And Sft Qwen With Unsolth And Upload Data And Model To Huggingface"+ "# Cotdatagen with CAMEL And Sft Qwen With Unsolth And Upload Data And Model To Huggingface"]},{@@ -17,7 +17,7 @@"id": "MgAnJZTCCNDl"},"source": [- "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1R3o7FcQQx77mskNf9czrJkAnzKruQhqb?usp=sharing) (Use the colab share link)"+ "You can also check this cookbook in colab [here](https://drive.google.com/file/d/1AnpeyVcYpCTa8oN1Po20fIXya-pv9A1Q/view?usp=sharing) (Use the colab share link)"]},{@@ -29,12 +29,12 @@"source": ["\n","\n",- "This notebook demonstrates how to set up and leverage CAMEL's **O1DataGenerator** for generating high-quality question-answer pairs like o1 thinking data, fine-tuning a language model using Unsloth, and uploading the results to Hugging Face.\n",+ "This notebook demonstrates how to set up and leverage CAMEL's **CotDataGenerator** for generating high-quality question-answer pairs like o1 thinking data, fine-tuning a language model using Unsloth, and uploading the results to Hugging Face.\n","\n","In this notebook, you'll explore:\n","\n","- **CAMEL**: A powerful multi-agent framework that enables SFT data generation and multi-agent role-playing scenarios, allowing for sophisticated AI-driven tasks.\n",- "- **O1DataGenerator**: A tool for generating like o1 thinking data.\n",+ "- **CotDataGenerator**: A tool for generating like o1 thinking data.\n","- **Unsloth**: An efficient library for fine-tuning large language models with LoRA (Low-Rank Adaptation) and other optimization techniques.\n","- **Hugging Face Integration**: Uploading datasets and fine-tuned models to the Hugging Face platform for sharing.\n"]@@ -112,7 +112,7 @@"import os\n","from datetime import datetime\n","import json\n",- "from camel.datagen.o1datagen import O1DataGenerator"+ "from camel.datagen.cotdatagen import CoTDataGenerator"]},{@@ -402,7 +402,7 @@"lines_to_next_cell": 2},"source": [- "## Create an instance of O1DataGenerator"+ "## Create an instance of CotDataGenerator"]},{@@ -414,8 +414,8 @@},"outputs": [],"source": [- "# Create an instance of O1DataGenerator\n",- "testo1 = O1DataGenerator(chat_agent, golden_answers=qa_data)"+ "# Create an instance of CoTDataGenerator\n",+ "testo1 = CoTDataGenerator(chat_agent, golden_answers=qa_data)"]},{@@ -873,7 +873,7 @@" # Use HuggingFaceDatasetManager to create the dataset card\n"," manager.create_dataset_card(\n"," dataset_name=dataset_name,\n",- " description=\"Question-Answer dataset generated by CAMEL O1DataGene\", # Dataset description\n",+ " description=\"Question-Answer dataset generated by CAMEL CoTDataGenerator\", # Dataset description\n"," license=\"mit\", # Dataset license\n"," language=[\"en\"], # Dataset language\n"," size_category=\"<1MB\", # Dataset size category\n",@@ -2411,10 +2411,10 @@},"source": ["\n",- "Through this notebook demonstration, we showcased how to use the O1DataGenerator from the CAMEL framework to generate high-quality question-answer data and efficiently fine-tune language models using the Unsloth library. The entire process covers the end-to-end workflow from data generation, model fine-tuning, to model deployment, demonstrating how to leverage modern AI tools and platforms to build and optimize question-answering systems.\n",+ "Through this notebook demonstration, we showcased how to use the CotDataGenerator from the CAMEL framework to generate high-quality question-answer data and efficiently fine-tune language models using the Unsloth library. The entire process covers the end-to-end workflow from data generation, model fine-tuning, to model deployment, demonstrating how to leverage modern AI tools and platforms to build and optimize question-answering systems.\n","\n","## Key Takeaways:\n",- "Data Generation: Using O1DataGenerator from CAMEL, we were able to generate high-quality question-answer data similar to o1 thinking. This data can be used for training and evaluating question-answering systems.\n",+ "Data Generation: Using CotDataGenerator from CAMEL, we were able to generate high-quality question-answer data similar to o1 thinking. This data can be used for training and evaluating question-answering systems.\n","\n","Model Fine-Tuning: With the Unsloth library, we were able to fine-tune large language models with minimal computational resources. By leveraging LoRA (Low-Rank Adaptation) technology, we only needed to update a small portion of the model parameters, significantly reducing the resources required for training.\n","\n",diff --git a/docs/cookbooks/O1datagen_with_CAMEL_And_Upload_Data_To_Huggingface.ipynb b/docs/cookbooks/Cotdatagen_with_CAMEL_And_Upload_Data_To_Huggingface.ipynbsimilarity index 99%rename from docs/cookbooks/O1datagen_with_CAMEL_And_Upload_Data_To_Huggingface.ipynbrename to docs/cookbooks/Cotdatagen_with_CAMEL_And_Upload_Data_To_Huggingface.ipynbindex b95042227..cfb172828 100644--- a/docs/cookbooks/O1datagen_with_CAMEL_And_Upload_Data_To_Huggingface.ipynb+++ b/docs/cookbooks/Cotdatagen_with_CAMEL_And_Upload_Data_To_Huggingface.ipynb@@ -7,7 +7,7 @@"id": "d80bea45"},"source": [- "# O1 Data Generation with CAMEL and Upload Data to Huggingface"+ "# Cot Data Generation with CAMEL and Upload Data to Huggingface"]},{@@ -17,7 +17,7 @@"id": "MgAnJZTCCNDl"},"source": [- "You can also check this cookbook in colab [here](https://drive.google.com/file/d/1oGFFuhaiQgGPieT4BwbfAWEdV-L5cJQz/view?usp=sharing) (Use the colab share link)"+ "You can also check this cookbook in colab [here](https://drive.google.com/file/d/1HW2g7Thb5l0gM-GfAtbmolJJa3-3HmBt/view?usp=sharing) (Use the colab share link)"]},{@@ -29,12 +29,12 @@"source": ["\n","\n",- "This notebook demonstrates how to set up and leverage CAMEL's **O1DataGenerator** for generating high-quality question-answer pairs like o1 thinking data, uploading the data to Hugging Face.\n",+ "This notebook demonstrates how to set up and leverage CAMEL's **CotDataGenerator** for generating high-quality question-answer pairs like o1 thinking data, uploading the data to Hugging Face.\n","\n","In this notebook, you'll explore:\n","\n","- **CAMEL**: A powerful multi-agent framework that enables SFT data generation and multi-agent role-playing scenarios, allowing for sophisticated AI-driven tasks.\n",- "- **O1DataGenerator**: A tool for generating like o1 thinking data.\n",+ "- **CotDataGenerator**: A tool for generating like o1 thinking data.\n","\n","- **Hugging Face Integration**: Uploading datasets to the Hugging Face platform for sharing\n"]@@ -87,7 +87,7 @@"import os\n","from datetime import datetime\n","import json\n",- "from camel.datagen.o1datagen import O1DataGenerator"+ "from camel.datagen.cotdatagen import CoTDataGenerator"]},{@@ -129,11 +129,11 @@"execution_count": null,"id": "c90eae14","metadata": {- "id": "c90eae14",- "lines_to_next_cell": 2,"colab": {"base_uri": "https://localhost:8080/"},+ "id": "c90eae14",+ "lines_to_next_cell": 2,"outputId": "2d75236b-5361-42d8-aa8b-b6e3bed3d0c4"},"outputs": [@@ -279,16 +279,16 @@"execution_count": null,"id": "0XuYttZgwupa","metadata": {- "id": "0XuYttZgwupa","colab": {"base_uri": "https://localhost:8080/"},+ "id": "0XuYttZgwupa","outputId": "da8f7655-1af4-4499-afd9-9e59758fc17e"},"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["/content\n"]@@ -321,8 +321,8 @@},"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["JSON data successfully saved to qa_data.json\n"]@@ -378,7 +378,7 @@"lines_to_next_cell": 2},"source": [- "## Create an instance of O1DataGenerator"+ "## Create an instance of CotDataGenerator"]},{@@ -390,8 +390,8 @@},"outputs": [],"source": [- "# Create an instance of O1DataGenerator\n",- "testo1 = O1DataGenerator(chat_agent, golden_answers=qa_data)"+ "# Create an instance of CoTDataGenerator\n",+ "testo1 = CoTDataGenerator(chat_agent, golden_answers=qa_data)"]},{@@ -442,8 +442,8 @@},"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["Question: What is the coefficient of $x^2y^6$ in the expansion of $\\left(\\frac{3}{5}x-\\frac{y}{2}\\right)^8$? Express your answer as a common fraction\n","AI's thought process and answer:\n",@@ -621,8 +621,8 @@},"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["The generated answers have been exported to: generated_answers_20241227_111615.json\n"]@@ -700,8 +700,8 @@},"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["Transformation complete. Output saved to: transformed_qa_20241227_111622.json\n"]@@ -828,7 +828,7 @@" # Use HuggingFaceDatasetManager to create the dataset card\n"," manager.create_dataset_card(\n"," dataset_name=dataset_name,\n",- " description=\"Question-Answer dataset generated by CAMEL O1DataGene\", # Dataset description\n",+ " description=\"Question-Answer dataset generated by CAMEL CoTDataGenerator\", # Dataset description\n"," license=\"mit\", # Dataset license\n"," language=[\"en\"], # Dataset language\n"," size_category=\"<1MB\", # Dataset size category\n",@@ -896,10 +896,10 @@"execution_count": null,"id": "_QHHkipbY7kJ","metadata": {- "id": "_QHHkipbY7kJ","colab": {"base_uri": "https://localhost:8080/"},+ "id": "_QHHkipbY7kJ","outputId": "f88df1b1-268e-4a42-821c-486ac4dfa872"},"outputs": [@@ -929,8 +929,8 @@},"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["Enter your HuggingFace username: zjrwtxtechstudio\n","Enter dataset name (press Enter to use default): o1data88\n",@@ -963,23 +963,23 @@},{"cell_type": "markdown",- "source": [- "### final example preview"- ],+ "id": "2nLsMgSnzp6l","metadata": {"id": "2nLsMgSnzp6l"},- "id": "2nLsMgSnzp6l"+ "source": [+ "### final example preview"+ ]},{"cell_type": "markdown",- "source": [- ""- ],+ "id": "d1nFtlFFzldR","metadata": {"id": "d1nFtlFFzldR"},- "id": "d1nFtlFFzldR"+ "source": [+ ""+ ]},{"cell_type": "markdown",@@ -1000,10 +1000,10 @@"source": ["\n","\n",- "This cookbook demonstrates the process of using **CAMEL's O1DataGenerator** to create high-quality question-answer pairs, similar to o1 thinking data. The notebook covers the following steps:\n",+ "This cookbook demonstrates the process of using **CAMEL's CotDataGenerator** to create high-quality question-answer pairs, similar to o1 thinking data. The notebook covers the following steps:\n","\n","1. **Setup**: Installation of the `camel-ai` library and configuration of the OpenAI API key.\n",- "2. **Data Generation**: Utilization of the `O1DataGenerator` to generate answers for predefined questions using llm model.\n",+ "2. **Data Generation**: Utilization of the `CotDataGenerator` to generate answers for predefined questions using llm model.\n","3. **Data Transformation**: Conversion of the generated Q&A data into a format compliant with the Alpaca training data schema.\n","4. **Upload to Hugging Face**: Integration with Hugging Face to upload the transformed dataset, including the creation of a dataset card and metadata.\n","\n",@@ -1054,4 +1054,4 @@},"nbformat": 4,"nbformat_minor": 5-}\ No newline at end of file+}diff --git a/docs/index.rst b/docs/index.rstindex 7d03e5dc6..8beccf5ca 100644--- a/docs/index.rst+++ b/docs/index.rst@@ -78,8 +78,8 @@ Main Documentationcookbooks/customer_service_Discord_bot_using_local_model_with_agentic_RAG.ipynbcookbooks/data_gen_with_real_function_calls_and_hermes_format.ipynbcookbooks/agent_with_chunkr_for_pdf_parsing.ipynb- cookbooks/O1datagen_with_CAMEL_And_Upload_Data_To_Huggingface.ipynb- cookbooks/O1datagen_with_CAMEL_And_Sft_Qwen_With_Unsolth_And_Upload_Data_And_Model_To_Huggingface.ipynb+ cookbooks/CoTdatagen_with_CAMEL_And_Upload_Data_To_Huggingface.ipynb+ cookbooks/CoTdatagen_with_CAMEL_And_Sft_Qwen_With_Unsolth_And_Upload_Data_And_Model_To_Huggingface.ipynb.. toctree:::maxdepth: 1