How alibaba-nlp/webagent works
Project Type & Purpose
• This is a mixed ML/engineering repository combining:
• WebDancer: an agentic search-reasoning model (training pipeline + demo UI).
• WebWalker: a benchmark/multi-agent framework for web traversal (API + evaluation).
• It provides data (datasets/ assets), model deployment scripts, demo interfaces, and evaluation tooling.
File Structure
Top-level folders:
• WebDancer/
• assets, datasets (sample_qa.jsonl, sample_traj.jsonl)
• demos/ (agents, GUI, LLM adapters, tools, utils)
• scripts/ (deploy_model.sh, run_demo.sh)
• requirements.txt, readme.md
• WebWalker/
• assets/
• src/ (agent.py, app.py, evaluate.py, prompts.py, rag_system.py, utils.py)
• requirements.txt, README.md
• Shared: LICENSE, README.md, .gitignore, assets/
Extract Key Architectural Insights from the README
• Core pipelines: data construction → trajectory sampling → supervised fine-tuning → RL.
• Demo uses Gradio for interactive UI.
• Model served via sglang after downloading from Hugging Face.
• WebWalker runs a retrieval-augmented generation (RAG) system plus evaluation scripts.
Main Components & Layers
A. User Interfaces
1. CLI scripts (bash run_demo.sh, deploy_model.sh)
2. Gradio Web UI (WebDancer/demos/gui/web_ui.py + HTML decorators)
3. WebWalker API/App (WebWalker/src/app.py)
B. Orchestration & Business Logic
1. Agent modules (WebDancer/demos/agents, WebWalker/src/agent.py)
2. LLM adapters (WebDancer/demos/llm/oai.py, qwen_dashscope.py)
3. Tool wrappers (search, visit, cache in demos/tools)
4. RAG system (WebWalker/src/rag_system.py)
5. Prompt templates (prompts.py)
C. Model & Compute
1. WebDancer model (downloaded from Hugging Face, loaded via sglang)
2. Training pipelines (not in code but implied by README)
3. LLM inference (OpenAI/Qwen, via API keys)
D. Data Storage
1. Datasets folder (sample QA, trajectories)
2. Assets (images, logos, roadmap)
E. External Services
1. Google Search API
2. Jina API
3. Dashscope API
4. Hugging Face model hub
Relationships & Data-flow
• Users launch run_demo.sh → starts Gradio server → user inputs query.
• Web UI calls Agent orchestrator → Agent loads model via sglang → Agent issues search via Google/Jina/Dashscope tools → fetches web pages → LLM processes steps (ReAct) → returns answer.
• WebWalker’s app.py exposes endpoints for benchmarking LLM agents → orchestrates RAG retrieval and agent execution → evaluation script (evaluate.py) computes metrics on WebWalkerQA.
• Underneath, prompt templates guide both pipelines; cache_utils speeds up repeated calls.
Architectural Patterns & Principles
• Layered architecture: UI → orchestration/agents → model/inference → external tools.
• Modular separation: WebDancer vs WebWalker, and within each, split agents, tools, adapters.
• Plugin-style LLM adapters (easy to swap OpenAI/Qwen).
• Data-centric training pipeline (four-stage: data → SFT → RL).
Final Checklist
[ ] Clear labels on all components
[ ] External services distinctly grouped
[ ] Note API keys & configuration files (requirements.txt, scripts)