强化学习的一个网页交互基准。
项目描述
MiniWoB++(迷你比特世界++)库包含超过100个网页交互环境,并提供JavaScript和Python接口,以便程序化地与之交互。Python接口遵循Gymnasium API,并使用Selenium WebDriver在网页浏览器上执行操作。
MiniWoB++是OpenAI MiniWoB基准测试的扩展,并在论文使用工作流程引导探索进行网页界面强化学习中介绍。
文档网站位于miniwob.farama.org。MiniWoB++的开发目前正在继续,以使其符合Farama标准,以适应成熟项目,并在这一点之后长期维护。有关更多详细信息,请参阅项目路线图。如果您想帮忙,可以加入我们的discord服务器:[https://discord.gg/PfR7a79FpQ](https://discord.gg/PfR7a79FpQ)。
安装
MiniWoB++支持Linux和macOS上的Python 3.8及以上版本。
安装MiniWoB++库
要安装MiniWoB++库,请使用pip install miniwob
。
安装Chrome/Chromium和ChromeDriver
我们强烈建议使用Chrome或Chromium作为网页浏览器,因为其他浏览器可能以不同的方式渲染环境。
MiniWoB++ Python接口使用Selenium,它通过WebDriver API与浏览器交互。遵循说明方法之一安装ChromeDriver。最简单的方法是下载与版本匹配的ChromeDriver,解压它,然后将包含chromedriver
可执行文件的目录添加到PATH
环境变量中。
export PATH=$PATH:/path/to/chromedriver
对于Chromium,驱动程序也可能在软件包中可用;例如,在Debian/Ubuntu中。
sudo apt install chromium-driver
示例用法
以下代码在click-test-2
环境中执行确定性操作。
import time
import gymnasium
from miniwob.action import ActionTypes
env = gymnasium.make('miniwob/click-test-2-v1', render_mode='human')
# Wrap the code in try-finally to ensure proper cleanup.
try:
# Start a new episode.
obs, info = env.reset()
assert obs["utterance"] == "Click button ONE."
assert obs["fields"] == (("target", "ONE"),)
time.sleep(2) # Only here to let you look at the environment.
# Find the HTML element with text "ONE".
for element in obs["dom_elements"]:
if element["text"] == "ONE":
break
# Click on the element.
action = env.unwrapped.create_action(ActionTypes.CLICK_ELEMENT, ref=element["ref"])
obs, reward, terminated, truncated, info = env.step(action)
# Check if the action was correct.
print(reward) # Should be around 0.8 since 2 seconds has passed.
assert terminated is True
time.sleep(2)
finally:
env.close()
有关更多信息,请参阅文档。
环境
MiniWoB++库中包含的环境列表可在文档中找到。所有环境共享相同的观察空间,而动作空间可以在环境构建期间进行配置。
引用
引用此项目请使用
@inproceedings{liu2018reinforcement,
author = {Evan Zheran Liu and Kelvin Guu and Panupong Pasupat and Tianlin Shi and Percy Liang},
title = {Reinforcement Learning on Web Interfaces using Workflow-Guided Exploration},
booktitle = {International Conference on Learning Representations ({ICLR})},
url = {https://arxiv.org/abs/1802.08802},
year = {2018},
}