Skip to content

About

Low-latency browser decision agent adapted from Laya, with data flywheel, RLCD training, Jev/CDP execution and live evaluation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Laya Web Agent

将通用动态选择模型 Laya 改造成低延迟网页决策 Agent 的完整工程实践:网页状态采集、动作空间构建、训练数据闭环、RLCD 微调、浏览器执行和端到端评估。

This is an independent portfolio/research derivative. It is not the official Laya repository and is not affiliated with the upstream authors.

Highlights

  • 将开放式网页动作生成改写为受约束的 operation + target 动态选择问题
  • 构建 15,729 个去重决策 case,拆分为 32,688 个训练 item
  • 接通 DOM/CDP 观察、Laya 批量决策、Jev 动作路由和确定性浏览器执行
  • RUN1:operation accuracy 从原始 Laya 零样本的 2.7% 提升到 94.3%,target accuracy 为 82.3%
  • RUN1:16 类任务、48 次真实浏览器运行成功 32 次,端到端成功率 66.7%
  • 平均单次模型决策延迟约 89.3 ms
  • 通过后续扩量实验定位了 DONE 奖励投机、多数据源冲突和 offline-to-online gap

原始 Laya 与本项目的区别

能力 原始 Laya 本项目
任务 通用 typed decision 网页操作决策
输入 状态、问题、动态候选 网页目标、URL、可见文本、历史、DOM 动作候选
输出 候选概率 operation 与对应 target
执行 不包含 Jev + CDP 确定性执行
数据 通用决策数据 网页采集、Mind2Web、真实 DONE、rollout、DAgger
评估 离线决策指标 离线准确率 + 真实浏览器任务成功率

System Architecture

flowchart TD
    G[User Goal] --> B[Chrome / CDP]
    B --> S[DOM Snapshot]
    S --> A[Action Space Builder]
    A --> Q[Question Builder]
    Q --> O[Operation Question]
    Q --> T[Target Questions]
    O --> L[Laya Decision Model]
    T --> L
    L --> R[Operation + Matching Target]
    R --> E[Deterministic Executor]
    E --> B
Loading

模型负责语义判断,程序负责动作约束和确定性执行。模型不会自由生成不存在的元素 ID,只能从当前页面真实可执行动作中选择。

Decision Formulation

每一步同时构建一组相互独立的问题:

  1. operation:下一步应执行 CLICK / TYPE_TEXT / SELECT / SCROLL / DONE 中的哪一种;
  2. target:针对每一种有候选元素的 operation,应该操作哪个元素。

这些问题在一次 HTTP 请求中批量推理。target 问题包含其假设的 operation,但不会读取 operation 问题的隐藏状态或预测结果。返回后由确定性路由器选取与最终 operation 匹配的 target。

Data Loop

网页采集
  → 可见交互元素抽取
  → 可执行动作空间
  → 目标生成 / 公开轨迹导入
  → teacher 或规则标注
  → 执行验证与清洗
  → operation / target item
  → 训练
  → 真实浏览器 rollout
  → 失败状态回流

最终统一数据由以下来源组成:

Source Cases
Reverse-generated goals 4,768
RUN1 replay 1,057
Real DONE states 697
Step-2 negatives 820
Mind2Web 7,362
DAgger corrections 335
Scripted rollout 690
Unique total 15,729

更强模型只用于部分数据生成或纠错;核心在线决策由微调后的 Laya 完成。

Model and Training

主实验沿用 Laya 的结构和 RLCD recipe:

ModernBERT-large encoder
  + question-type embedding
  + 2-layer Transformer decision head
  → candidate logits

联合损失:

$$L = L_{CE} + L_{PG}$$

策略梯度项对候选 logits 做 4 组高斯扰动,并使用 proper-scoring reward:

$$R(q,y)=\sum_i y_i\log q_i + 0.75\frac{y^Tq}{\lVert q\rVert_2}$$

同一道题的 reward 做组内标准化后用于 REINFORCE。这里的网页任务都是 choice,RPS 项不参与。该方法具有 group-relative 优化思想,但不是标准 GRPO:没有 token rollout、old-policy ratio、PPO clipping 或 reference-model KL。

**重要限制:**当前实验没有完成严格的 CE-only 消融,因此整体提升不能单独归因于高斯扰动或 RLCD。

Results

Run Operation Target Live browser
Original Laya, zero-shot 2.7% — initial tasks failed
RUN1 94.3% 82.3% 32/48 (66.7%)
RUN14, larger unified mix 90.5% 73.7% 25/48 (52.1%)
RUN14 holdout — — 11/30 (36.7%)

RUN1 与 RUN14 的离线评测集并不完全相同,不能将所有离线数字直接横向比较。RUN14 的意义是完成了更大规模统一重训与 holdout 闭环;结果也说明网页 Agent 训练中数据一致性和 on-policy 覆盖比简单扩量更重要。

Main Difficulties

  • **领域迁移:**原始 Laya 不理解网页状态和动作语义,零样本 operation accuracy 仅 2.7%。
  • **动态 DOM:**页面重渲染会让候选失效,因此加入稳定 node 身份、页面 fingerprint 和 stale-page 重观察。
  • **候选过宽:**target 超过约 12 个时采用 coarse-to-fine 分组选择。
  • **DONE reward hacking:**模型可能提前预测 DONE;通过真实 landing state、mid-task negatives 和失败回流缓解。
  • **数据扩量退化:**静态数据、公开轨迹、合成数据与 on-policy 状态之间存在策略分布冲突。
  • **离线/在线差距:**单步准确率不能替代端到端浏览器成功率。

Repository Layout

code/                 training, serving and evaluation implementation
experiments/          unified-data and closed-loop scripts added during this work
patches/              local changes against upstream repositories
reports/              evidence-backed RUN1/RUN14 reports
docs/                 architecture, data and experiment notes
data/examples/        sanitized schema examples only

Large datasets, browser profiles, credentials and model checkpoints are intentionally excluded.

Reproduction Scope

The repository publishes the auditable code path and experiment evidence. Full reproduction additionally requires:

  • a CUDA-capable GPU with enough memory for the selected Laya checkpoint;
  • Chromium started with a CDP endpoint;
  • upstream Laya and Jev dependencies;
  • Mind2Web access and locally generated browser cases;
  • a locally hosted teacher only when regenerating synthetic/DAgger labels.

See code/finetune/README.md and reports/ for the exact pipeline and recorded results.

Attribution

This work builds on:

See THIRD_PARTY_NOTICES.md. Upstream code retains its original license terms. New documentation and experiment glue in this repository are released under Apache-2.0.

Security

Do not commit .env files, API keys, SSH credentials, browser profiles, cookies or private browsing traces. The repository contains only sanitized examples.

About

Low-latency browser decision agent adapted from Laya, with data flywheel, RLCD training, Jev/CDP execution and live evaluation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages