tahamajs's picture
|
download
raw
9.96 kB

๐Ÿค– Language Agent Architecture Pipeline - CA14

๐Ÿ“š Overview

This project implements a comprehensive demonstration of modern language agent architectures, showcasing the evolution from simple tool usage to sophisticated multi-agent collaboration systems. The pipeline includes four key architectures:

  1. ๐Ÿ”— ReAct (Reasoning + Acting): Grounded reasoning through tool interaction
  2. ๐Ÿ”„ Reflexion: Self-improving agents that learn from failures
  3. ๐Ÿง  HippoRAG: Associative memory networks for complex reasoning
  4. ๐ŸŒ Nexus: Multi-agent collaboration and orchestration

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.8+
  • pip
  • Git

Installation & Execution

  1. Clone and Setup:
git clone <repository-url>
cd CA14
chmod +x run.sh
  1. Run Complete Pipeline:
./run.sh

This will:

  • Create a virtual environment
  • Install all dependencies
  • Run comprehensive demonstrations of all 4 agent architectures
  • Generate performance analysis and visualizations
  • Create HTML reports
  • Save all results to organized folders

Manual Execution

  1. Setup Environment:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
  1. Run Individual Components:
# Run main pipeline (ReAct only)
python main.py --config config.json --output results/ --verbose

# Run complete demo with all agents
python demo_all_agents.py

# Generate visualizations
python visualize_results.py

๐Ÿ“ Project Structure

CA14/
โ”œโ”€โ”€ src/                          # Source code
โ”‚   โ”œโ”€โ”€ agents/                   # Agent implementations
โ”‚   โ”‚   โ”œโ”€โ”€ react_agent.py       # ReAct implementation
โ”‚   โ”‚   โ”œโ”€โ”€ reflexion_agent.py   # Reflexion implementation
โ”‚   โ”‚   โ”œโ”€โ”€ hipporag_agent.py    # HippoRAG implementation
โ”‚   โ”‚   โ””โ”€โ”€ nexus_orchestrator.py # Nexus implementation
โ”‚   โ”œโ”€โ”€ core/                    # Core systems
โ”‚   โ”‚   โ”œโ”€โ”€ memory.py           # Memory systems
โ”‚   โ”‚   โ”œโ”€โ”€ communication.py    # Communication protocols
โ”‚   โ”‚   โ””โ”€โ”€ state_management.py # State management
โ”‚   โ””โ”€โ”€ utils/                   # Utilities
โ”‚       โ”œโ”€โ”€ llm_interface.py     # LLM provider interface
โ”‚       โ”œโ”€โ”€ environment.py       # Travel environment
โ”‚       โ””โ”€โ”€ evaluation.py        # Performance evaluation
โ”œโ”€โ”€ config.json                  # Configuration file
โ”œโ”€โ”€ requirements.txt             # Python dependencies
โ”œโ”€โ”€ main.py                      # Main execution script
โ”œโ”€โ”€ demo_all_agents.py          # Complete demo script
โ”œโ”€โ”€ run.sh                      # Complete pipeline script
โ”œโ”€โ”€ visualize_results.py        # Visualization script
โ”œโ”€โ”€ test_pipeline.py            # Test suite
โ””โ”€โ”€ results/                    # Generated results
    โ”œโ”€โ”€ logs/                   # Execution logs
    โ”œโ”€โ”€ data/                   # Raw data files
    โ”œโ”€โ”€ plots/                  # Performance visualizations
    โ”œโ”€โ”€ reports/                # HTML reports
    โ””โ”€โ”€ visualizations/         # Chart outputs

โš™๏ธ Configuration

The config.json file allows customization of:

  • LLM Providers: OpenAI, Anthropic, Local models, Mock
  • Agent Parameters: Max steps, temperature, tokens
  • Environment Settings: Failure rates, availability thresholds
  • Test Cases: Customizable test scenarios
  • Output Options: Result formats and visualizations

Example Configuration

{
  "llm": {
    "primary_provider": "mock",
    "fallback_providers": ["local", "mock"],
    "openai": {
      "model": "gpt-3.5-turbo",
      "api_key": null
    }
  },
  "agents": {
    "react": {
      "max_steps": 10,
      "temperature": 0.3
    }
  }
}

๐Ÿงช Testing & Evaluation

Test Cases

The pipeline includes comprehensive test cases covering:

  • Simple flight booking
  • Complex multi-step trip planning
  • Error handling and recovery
  • Tool usage optimization
  • Multi-agent coordination

Performance Metrics

  • Success Rate: Task completion percentage
  • Execution Time: Average time per task
  • Reasoning Quality: Quality of agent reasoning
  • Tool Usage: Efficiency of tool utilization
  • Error Analysis: Failure pattern analysis

๐Ÿ“Š Results & Visualization

Generated Outputs

  • JSON Results: Detailed execution traces and metrics
  • Performance Plots: Comparative visualizations
  • HTML Reports: Interactive result summaries
  • Log Files: Complete execution logs

Viewing Results

  1. HTML Report: Open results/reports/index.html
  2. Performance Plots: Check visualizations/ folder
  3. Raw Data: Examine results/*/demonstration_results.json

๐Ÿ”ง Advanced Usage

Custom Agent Development

from src.agents.react_agent import ReActAgent
from src.utils.llm_interface import LLMInterface
from src.utils.environment import TravelEnvironment

# Initialize components
llm = LLMInterface(primary_provider="mock")
env = TravelEnvironment()
tools = create_travel_tools(env)

# Create agent
agent = ReActAgent(tools=tools, llm_interface=llm)

# Execute task
result = agent.execute("Plan a trip to Paris")
print(f"Success: {result.success}")
print(f"Answer: {result.final_answer}")

Adding New Tools

def custom_tool(param1: str, param2: str) -> str:
    """Custom tool description"""
    # Tool implementation
    return f"โœ… Custom result: {param1} + {param2}"

# Add to tools dictionary
tools["custom_tool"] = custom_tool

๐Ÿ› Troubleshooting

Common Issues

  1. Import Errors: Ensure all dependencies are installed

    pip install -r requirements.txt
    
  2. LLM Provider Issues: Check API keys and network connectivity

    export OPENAI_API_KEY="your-key"
    export ANTHROPIC_API_KEY="your-key"
    
  3. Memory Issues: Reduce batch size or use smaller models

    {
      "local": {
        "model_name": "gpt2",
        "device": "cpu"
      }
    }
    
  4. Permission Errors: Ensure script is executable

    chmod +x run.sh
    

Debug Mode

Run with verbose logging:

python main.py --verbose --config config.json

๐Ÿ“š Theoretical Background

ReAct Framework

  • Paper: "ReAct: Synergizing Reasoning and Acting in Language Models"
  • Key Innovation: Interleaving reasoning and acting in a loop
  • Advantages: Interpretable, grounded reasoning

Reflexion Architecture

  • Paper: "Reflexion: Language Agents with Verbal Reinforcement Learning"
  • Key Innovation: Self-improvement through reflection
  • Advantages: Learning from failures, iterative improvement

HippoRAG System

  • Paper: "HippoRAG: Neurobiologically Inspired Long-Term Associative Memory"
  • Key Innovation: Dual-memory architecture (neocortex + hippocampus)
  • Advantages: Multi-hop reasoning, associative connections

Nexus Framework

  • Concept: Hierarchical multi-agent collaboration
  • Key Innovation: Specialized agents with intelligent coordination
  • Advantages: Scalability, fault tolerance, specialization

๐ŸŽฏ Key Features

โœ… What Works

  • Complete Agent Implementations: All 4 architectures fully implemented
  • Comprehensive Testing: Multiple test scenarios for each agent
  • Performance Visualization: Charts and graphs for analysis
  • HTML Reports: Interactive result summaries
  • Mock LLM Provider: Works without external API keys
  • Travel Environment: Realistic simulation environment
  • Memory Systems: Episodic, semantic, and associative memory
  • Multi-Agent Communication: Message passing and coordination

๐Ÿ”ง Current Limitations

  • Mock LLM Only: Real LLM providers require API keys
  • Limited Domain: Currently focused on travel planning
  • Simple Environment: Simulated rather than real-world APIs
  • Basic Evaluation: Could benefit from more sophisticated metrics

๐Ÿ“ˆ Performance Results

Based on recent test runs:

  • ReAct Agent: 100% success rate, ~0.25s average execution time
  • Reflexion Agent: 100% success rate, self-improvement demonstrated
  • HippoRAG Agent: 90%+ confidence scores, associative reasoning working
  • Nexus Multi-Agent: 100% success rate, effective coordination

๐Ÿš€ Future Enhancements

  1. Real LLM Integration: Add support for OpenAI GPT-4, Claude, etc.
  2. Extended Domains: Support for more complex planning scenarios
  3. Advanced Memory: Implement more sophisticated memory systems
  4. Performance Optimization: Improve execution speed and efficiency
  5. Production Deployment: Add Docker support and cloud deployment
  6. Enhanced Evaluation: Add more sophisticated performance metrics

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Implement your changes
  4. Add tests and documentation
  5. Submit a pull request

๐Ÿ“„ License

This project is part of the Advanced AI Systems Course and is intended for educational purposes.

๐Ÿ™ Acknowledgments

  • OpenAI for GPT models
  • Anthropic for Claude models
  • Hugging Face for Transformers library
  • The research community for foundational papers

๐Ÿ“ž Support

For questions or issues:

  • Create an issue in the repository
  • Check the troubleshooting section
  • Review the logs in results/logs/

Note: This implementation is designed for educational and research purposes. For production use, additional security, scalability, and reliability measures should be implemented.

๐ŸŽ‰ Quick Demo

To see the pipeline in action immediately:

# Clone and run
git clone <repo-url>
cd CA14
chmod +x run.sh
./run.sh

# Open results
open results/reports/index.html

The entire pipeline will complete in under 2 minutes and generate comprehensive results showing all four agent architectures in action!

Xet Storage Details

Size:
9.96 kB
ยท
Xet hash:
26cbf930cf1cc2844c815f0b01f213dbbb70ef081ddd984381e601448217cb11

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.