examples/rlm: Add a structured RLM example - #122
Conversation
Show how Computer Workspaces, generated JavaScript, and a bounded trusted model module can implement map/reduce over long context. Compare direct context, JavaScript-only execution, and Structured RLM on official Oolong tasks with observable scoring and usage.
|
|
Thanks for your interest in Cloudflare Computer. This repository does not accept unsolicited pull requests. Please use one of the accepted contribution paths instead:
If a maintainer asked you to open this pull request, they can add the |
commit: |
Keep successful JavaScript executions visible when their returned shape cannot be scored. Sanitize invalid output into a metadata-only summary and explain the semantic capability mismatch in the comparison UI.
Summary
This adds an end-to-end example of building a recursive language model (RLM) with Cloudflare Computer.
The example keeps long context in a Computer Workspace, uses bounded model calls for semantic interpretation, and uses generated JavaScript for validation and aggregation. This pattern is useful for tasks that need to classify, extract, or compare information across more data than should be placed in one model prompt.
What this adds
The example runs the same official Oolong task through three strategies: direct context, generated JavaScript with Workspace access, and a Structured RLM with Workspace access plus
ws:model.The RLM uses the public
WorkerJavaScriptBackendand native executor tool. Generated code receives a read-only Workspace and one trusted model interface:This lets a generated module map model calls across Workspace partitions and reduce their structured results with ordinary JavaScript:
The UI compares the three approaches side by side and shows the generated module, model workers, token use, duration, and Oolong score. The RLM starts first, then overlaps its map work with both baselines to keep the comparison responsive.
Usage
Open the Vite URL and run Classify 2,433 records. Workers AI is remote, and a complete comparison can use more than 200,000 model tokens.
The example README covers the architecture, core source files, capability bounds, additional tasks, data provenance, and optional deployment.