For the complete documentation index, see llms.txt. This page is also available as Markdown.

Retrieving Results

Retrieve evaluation results — paginated, bulk, and concurrent fetching patterns.

Examples for fetching evaluation results using the LayerLens Python SDK, including pagination, bulk fetching, and concurrent retrieval.

Paginated Results

Walk through results page by page with full control over page size.

import asyncio

from layerlens import AsyncStratix

async def main():
 client = AsyncStratix()

 models = await client.models.get()
 benchmarks = await client.benchmarks.get()

 evaluation = await client.evaluations.create(model=models[0], benchmark=benchmarks[0])
 evaluation = await client.evaluations.wait_for_completion(
 evaluation, interval_seconds=10, timeout_seconds=600
 )

 if evaluation.is_success:
 print("Fetching all results with pagination...")

 all_results = []
 page = 1
 page_size = 50

 while True:
 print(f"Fetching page {page} (page size: {page_size})...")

 results_data = await client.results.get_by_id(
 evaluation_id=evaluation.id, page=page, page_size=page_size
 )

 if not results_data or not results_data.results:
 print("No more results to fetch")
 break

 all_results.extend(results_data.results)

 if page == 1:
 total_count = results_data.pagination.total_count
 total_pages = results_data.pagination.total_pages
 print(f"Total results: {total_count:,}")
 print(f"Total pages: {total_pages}")

 print(f"Page {page}: Retrieved {len(results_data.results)} results")
 print(f"Running total: {len(all_results):,} results")

 if page >= results_data.pagination.total_pages:
 print("Reached last page")
 break

 page += 1

 print(f"\nTotal results collected: {len(all_results):,}")

 if all_results:
 correct_answers = sum(1 for r in all_results if r.score > 0.5)
 accuracy = correct_answers / len(all_results)
 avg_score = sum(r.score for r in all_results) / len(all_results)

 print(f"Overall accuracy: {accuracy:.1%} ({correct_answers:,}/{len(all_results):,})")
 print(f"Average score: {avg_score:.3f}")

 print(f"\nFirst 3 results:")
 for i, result in enumerate(all_results[:3], 1):
 print(f" {i}. Score: {result.score:.3f}, Subset: {result.subset}")
 print(f" Prompt: {result.prompt[:100]}...")
 print(f" Response: {result.result[:100]}...")

if __name__ == "__main__":
 asyncio.run(main())

All Results Without Pagination

Use get_all() to fetch every result in a single call. Simpler but loads everything into memory.

Fetch Results for Multiple Evaluations Concurrently

Use asyncio.gather to load results for several evaluations in parallel.

Using the Evaluation Object Helpers

Results can also be fetched directly from an Evaluation object when a client is attached:

See Also

Last updated

Was this helpful?