aviary.labbench
LAB-Bench environments implemented with aviary, allowing agents to perform question answering on scientific tasks.
Installation
To install the LAB-Bench environment, run:
pip install 'fhaviary[labbench]'
Usage
In labbench/env.py, you will find:
GradablePaperQAEnvironment: an PaperQA-backed environment that can grade answers given an evaluation function.ImageQAEnvironment: anGradablePaperQAEnvironmentsubclass for QA where image(s) are pre-added.
And in labbench/task.py, you will find:
TextQATaskDataset: a task dataset designed to pull down FigQA, LitQA2, or TableQA from Hugging Face, and create oneGradablePaperQAEnvironmentper question.ImageQATaskDataset: a task dataset that pairs withImageQAEnvironmentfor FigQA or TableQA.
Here is an example of how to use them:
import os
from ldp.agent import SimpleAgent
from ldp.alg import Evaluator, EvaluatorConfig, MeanMetricsCallback
from paperqa import Settings
from aviary.env import TaskDataset
async def evaluate(folder_of_litqa_v2_papers: str | os.PathLike) -> None:
settings = Settings(paper_directory=folder_of_litqa_v2_papers)
dataset = TaskDataset.from_name("litqa2", settings=settings)
metrics_callback = MeanMetricsCallback(eval_dataset=dataset)
evaluator = Evaluator(
config=EvaluatorConfig(batch_size=3),
agent=SimpleAgent(),
dataset=dataset,
callbacks=[metrics_callback],
)
await evaluator.evaluate()
print(metrics_callback.eval_means)
Image Question-Answer
This is an environment/dataset for giving PaperQA a Docs object with
the image(s) for one LAB-Bench question.
It's designed to be a comparison with zero-shotting the question to a LLM,
but instead of a singular prompt the image is put through the PaperQA agent loop.
from typing import cast
import litellm
import pytest
from ldp.agent import Agent
from ldp.alg import (
Evaluator,
EvaluatorConfig,
MeanMetricsCallback,
StoreTrajectoriesCallback,
)
from paperqa.settings import AgentSettings, IndexSettings
from aviary.envs.labbench import (
ImageQAEnvironment,
ImageQATaskDataset,
LABBenchDatasets,
)
@pytest.mark.asyncio
async def test_image_qa(tmp_path) -> None:
litellm.num_retries = 8 # Mitigate connection-related failures
settings = ImageQAEnvironment.make_base_settings()
settings.agent = AgentSettings(
agent_type="ldp.agent.SimpleAgent",
index=IndexSettings(paper_directory=tmp_path),
# TODO: add image support for paper_search
tool_names={"gather_evidence", "gen_answer", "complete", "reset"},
agent_evidence_n=3, # Bumped up to collect several perspectives
)
dataset = ImageQATaskDataset(dataset=LABBenchDatasets.TABLE_QA, settings=settings)
t_cb = StoreTrajectoriesCallback()
m_cb = MeanMetricsCallback(eval_dataset=dataset, track_tool_usage=True)
evaluator = Evaluator(
config=EvaluatorConfig(
batch_size=256, # Use batch size greater than FigQA size and TableQA size
max_rollout_steps=18, # Match aviary paper's PaperQA setting
),
agent=cast(Agent, await settings.make_ldp_agent(settings.agent.agent_type)),
dataset=dataset,
callbacks=[t_cb, m_cb],
)
await evaluator.evaluate()
print(m_cb.eval_means)
References
[1] Skarlinski et al. Language agents achieve superhuman synthesis of scientific knowledge. ArXiv:2409.13740, 2024.
[2] Laurent et al. LAB-Bench: Measuring Capabilities of Language Models for Biology Research. ArXiv:2407.10362, 2024.
Metadata
Release files for aviary.labbench 0.37.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aviary_labbench-0.37.0.tar.gz | 1.5 MB | Without provenance | Details for aviary_labbench-0.37.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aviary_labbench-0.37.0-py3-none-any.whl | Python 3 | none | any | Details for aviary_labbench-0.37.0-py3-none-any.whl |
Total release size: 1.5 MB
Release files / aviary_labbench-0.37.0.tar.gz
| Download URL | aviary_labbench-0.37.0.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0d12dcd26efff9c3366443f3ec4311fb4fd49baea7c690baa3217fda462abba
|
|
BLAKE2b-256 checksum How to use checksums |
423f73231ec6302353b0ed7c6858c36371d0bea9366316d8c67cee6bdf61d8e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / aviary_labbench-0.37.0-py3-none-any.whl
| Download URL | aviary_labbench-0.37.0-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d6782b62d5fd44b45a7ac5933f90c47cb9da97aa33a7aca4971936c4458e1cd
|
|
BLAKE2b-256 checksum How to use checksums |
78b956f2e184916fd518f3b56912e794b70adbcd29594f383eafa73cd56e20bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for aviary.labbench 0.37.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.