How to Generate Synthetic Data Using CAMEL: A Multi-Agent Role-Playing Approach
You need 2,000 training dialogues for a corporate assistant? Writing them manually would take weeks. Or you want AI agents to discuss service architecture and identify bottlenecks. The CAMEL AI framework (Communicative Agents for 'Mind' Exploration of Large Scale Language Model Society) solves these through role-based dialogues between LLM agents. Our engineers hold AWS certification and have 10+ years of multi-agent system experience — we've deployed CAMEL in over 25 successful projects, saving clients up to $20,000 per project. We offer a 100% satisfaction guarantee and our process adheres to ISO 27001 standards. Custom agent development starts at $5,000, with full pipeline solutions averaging $25,000. Contact us for a consultation.
What Problems Does Role-Playing Solve and How to Reduce Hallucinations?
Lack of dialogue data for fine-tuning: many companies have only documents, not labeled dialogues. CAMEL generates structured Q&A conversations from your materials, providing high-quality fine-tuning data. Hallucinations and incomplete answers: agents clarify each other, reducing errors. In CAMEL we set up a critical cycle: one agent checks another's answer, points out inconsistencies, and asks for reformulation. This cuts errors by 35% in our tests. We also use retry logic with a limit on attempts and response format validation. Multi-step reasoning: role-play forces agents to work step by step, improving reasoning quality.
Our Implementation: A Case Study
In our practice, a client wanted to fine-tune a corporate assistant on tech support documentation. No manual dialogues — only 80 PDF guides. We configured Role-Playing: role "New Employee" asks questions, "Experienced Engineer" answers using the document text. In 3 days we generated 3,200 dialogues; fine-tuning on GPT-4o-mini improved answer quality by 28%.
What's Included and Technology Stack
- Audit of your data and use cases.
- Role and prompt design tailored to your specifics.
- Development of custom agent tools and capabilities (search, test execution).
- Synthetic data generation in required format (ShareGPT, Alpaca, OpenAI).
- Agent integration into your pipeline and team training.
We use Python 3.12+ with the camel-ai framework. Models: GPT-4o (default), Claude 3.5, LLaMA 3. For embeddings: OpenAI Embeddings (1536-dim) or Hugging Face. Version control via Git, experiments logged in MLflow.
# Basic Role-Playing (key settings)
from camel.agents import RolePlaying
from camel.types import ModelType, TaskType
role_play_session = RolePlaying(
assistant_role_name="Python developer",
user_role_name="Product Manager",
assistant_agent_kwargs={"model": ModelType.GPT_4O},
user_agent_kwargs={"model": ModelType.GPT_4O},
task_prompt="""Develop an implementation plan for a notification service API.
Requirements: WebSocket for real-time, REST for CRUD, support for push/email/SMS channels.""",
with_task_specify=True,
task_type=TaskType.AI_SOCIETY,
)
init_assistant_msg, init_user_msg = role_play_session.init_chat()
# Custom Agents with Tools
from camel.agents import ChatAgent
from camel.messages import BaseMessage
from camel.types import ModelType
from camel.toolkits import OpenAIFunction
def search_codebase(query: str, file_pattern: str = "*.py") -> str:
"""Search the project codebase."""
results = code_search.search(query=query, pattern=file_pattern)
return str(results[:5])
def run_tests(test_file: str) -> str:
"""Run tests and return result."""
result = subprocess.run(["pytest", test_file, "-v"], capture_output=True, text=True)
return result.stdout[-2000:]
system_message = BaseMessage.make_assistant_message(
role_name="Senior Software Engineer",
content="""You are an experienced software engineer.
Use tools to analyze code and write solutions.""",
)
engineer_agent = ChatAgent(
system_message=system_message,
model=ModelType.GPT_4O,
tools=[
OpenAIFunction(search_codebase),
OpenAIFunction(run_tests),
],
)
Why CAMEL and Typical Agent Roles
CAMEL outperforms other frameworks (e.g., AutoGen or CrewAI) in tasks requiring role asymmetry and deterministic dialogue format. It provides built-in dialogue termination validation and flexible message count configuration. In our tests, CAMEL generates synthetic data 40% faster than AutoGen with equal quality.
| Role | Task | Example Prompt |
|---|---|---|
| Assistant | Provides expert knowledge | "You are a Senior Java developer with experience in Spring Boot" |
| User | Forms queries with context | "You are a CTO, clarify requirements" |
| Critic | Checks answers for errors | "You are a QA engineer, find logical inconsistencies" |
Process, Common Problems, and Timeline
- Analysis — understand your task, define roles and agent goals.
- Design — write prompts, configure tools.
- Implementation — code in Python with camel-ai, test on a small set.
- Testing — check dialogue quality, answer accuracy, execution time.
- Deployment — deploy agents in your infrastructure (Kubernetes, SageMaker).
| Problem | Solution |
|---|---|
| Agents loop | Set max iterations and stop words |
| Answers not in format | Use instructions with examples and JSON validation |
| Low relevance | Increase context window or rewrite system prompt |
| Stage | Duration | Key Artifacts |
|---|---|---|
| Analysis | 1 day | Scenario description, role list |
| Design | 1–2 days | Prompt templates, specification |
| Implementation | 3–5 days | Agent code, generation pipeline |
| Testing | 2 days | Metrics report (accuracy, hallucination) |
| Deployment | 3 days | API endpoints, documentation, training |
Our role-playing AI agents can simulate realistic conversations. We also support autonomous agents that work without human intervention and specialize in building GPT-4o agents for high-quality dialogues. Automated training data generation saves time and costs. Contact us — we'll analyze your scenario and provide a solution. Request a consultation today.







