Skip to content

Commit 56b42e0

Browse files
author
hemanth-asirvatham
committed
Prepare GABRIEL 1.1.9
1 parent 559be86 commit 56b42e0

34 files changed

Lines changed: 1281 additions & 312 deletions

AGENTS.md

Lines changed: 265 additions & 0 deletions
Large diffs are not rendered by default.

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
include LICENSE
22
include README.md
3+
include AGENTS.md
34
recursive-include src/gabriel/prompts *.jinja2

README.md

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,24 @@
66

77
You can install the GABRIEL Python library from [PyPI](https://pypi.org/project/openai-gabriel/) with `pip install openai-gabriel` and then `import gabriel`.
88

9+
> **Compatibility note:** `max_output_tokens` is deprecated in GABRIEL. Existing
10+
> calls remain valid, but the value is ignored and emits a `FutureWarning`;
11+
> GABRIEL leaves the output budget to the selected model.
12+
13+
> **Using a coding agent?** Read [`AGENTS.md`](https://github.com/openai/GABRIEL/blob/main/AGENTS.md).
14+
> It is the repository's shared guide to model choice, data shape, scale,
15+
> checkpoints, and quality assurance.
16+
917
Read our blog post [here](https://openai.com/index/scaling-social-science-research/), our paper with validation experiments and applied examples [here](http://www.nber.org/papers/w34834), and submit feedback / bugs / feature requests [here](https://forms.gle/RKnBskuiZ64Wt9D66).
1018

1119
## Table of contents
1220

1321
- [Why GABRIEL?](#why-gabriel)
1422
- [What can you do with GABRIEL?](#what-can-you-do-with-gabriel)
1523
- [Installation](#installation)
24+
- [Using GABRIEL with coding agents](#using-gabriel-with-coding-agents)
1625
- [Quick start](#quick-start)
1726
- [Task highlights](#task-highlights)
18-
- [Detailed usage](#detailed-usage)
1927
- [Multimodal data and web search](#multimodal-data-and-web-search)
2028
- [Custom prompts and model routing](#custom-prompts-and-model-routing)
2129
- [Saving, logging, and resuming](#saving-logging-and-resuming)
@@ -42,7 +50,7 @@ The tutorial notebook walks through these ideas step-by-step—from setting up a
4250
| `gabriel.rate` | Asks GPT to score each text / image / audio / item on natural language attributes. Output = 0-100 rating. | Measure “populist rhetoric” in a speech; “toxicity” of tweets; “luxury” in ad images. |
4351
| `gabriel.rank` | Pairwise comparisons between texts yields ELO-like attribute ratings. Output = grounded, relative z scores for each text. | Rank technologies by “bulkiness” or artworks by “fine brushwork”. |
4452
| `gabriel.classify` | Classifies texts / images / audio / items on whether provided labels apply. Output = one or more classes per item. | Tag news articles, product photos, or interview clips into topical categories. |
45-
| `gabriel.extract` | Structured fact extraction on each item. Output = string / numeric values. | For each product, provide the “company”, “CEO”, and “year of invention”. |
53+
| `gabriel.extract` | Structured fact or entity extraction. One source can return one row or expand into several extracted-entity rows. | Extract every product and its name, price, description, and color from each catalog page. |
4654
| `gabriel.discover` | Discovers natural language features which discriminate two classes of data. | Identify what distinguishes 5 star vs. 1 star reviews or successful vs. failed startups. |
4755

4856
### B) Clean data
@@ -60,7 +68,7 @@ The tutorial notebook walks through these ideas step-by-step—from setting up a
6068
| --- | --- | --- |
6169
| `gabriel.codify` | Passage coding: highlights snippets in text that match qualitative codes. | Flag sentences about “economic insecurity” in speeches; “stressors” mentioned in interview. |
6270
| `gabriel.compare` | Identifies similarities / differences between paired items. Output = list of differences. | Contrast op-eds from different districts; compare two ad campaigns. |
63-
| `gabriel.bucket` | Builds taxonomies from many terms. Output = bucket/cluster labels. | Group technologies, artworks, or HR complaints into emergent categories. |
71+
| `gabriel.bucket` | Proposes a compact taxonomy from many terms. Output = bucket names and definitions, not row-level assignments. | Develop candidate categories for technologies, artworks, or HR complaints, then review and apply them downstream. |
6472
| `gabriel.seed` | Enforces a representative distribution / diversity of seeds. | Initialize unique personas that match US population distribution. |
6573
| `gabriel.poll` | Seeds personas, expands them into full biographies, and surveys them. | Simulate a synthetic opinion poll on policy, values, and open-ended attitudes. |
6674
| `gabriel.ideate` | Generates many novel scientific theories and filters the cream of the crop. | Procure novel theories on inflation for potential research. |
@@ -87,9 +95,42 @@ Before running a GABRIEL call, declare your GPT API key:
8795

8896
```bash
8997
export OPENAI_API_KEY="sk-..."
90-
# or os.environ['OPENAI_API_KEY'] = "sk-..." inside a Jupyter notebook
9198
```
9299

100+
In Colab, store the key in **Secrets** under `OPENAI_API_KEY` and read it with
101+
`google.colab.userdata`; do not paste a real key into notebook source, chat,
102+
screenshots, or Git. The tutorial shows the complete setup.
103+
104+
## Using GABRIEL with coding agents
105+
106+
The repository's [`AGENTS.md`](https://github.com/openai/GABRIEL/blob/main/AGENTS.md)
107+
is a concise operating guide for coding agents. It
108+
explains task selection, model routing, checkpointing, multimodal inputs, and QA.
109+
Agents should also read `gabriel_tutorial_notebook.ipynb` closely before designing
110+
a workflow; it is the broadest guide to what the library can do.
111+
Three rules are especially important:
112+
113+
- **Verify model slugs live.** At this documentation's last review, the exact general
114+
models were `gpt-5.6-sol`, `gpt-5.6-terra`, and `gpt-5.6-luna`, and audio used
115+
`gpt-audio-1.5`. Model IDs change; check the
116+
[official model catalog](https://developers.openai.com/api/docs/models) and
117+
[pricing](https://developers.openai.com/api/docs/pricing), plus the models
118+
actually provisioned for your organization or gateway, instead of guessing or
119+
copying an old example. Luna is often a sensible starting point for many
120+
applications and large-scale work. For unusually subtle, knowledge-heavy, multi-constraint,
121+
or writing-sensitive work, pilot Terra and Sol on representative examples and
122+
use the smallest model that reliably meets the research standard.
123+
- **Generally keep `n_parallels=650`, including for small tests.** It is a ceiling, not a fixed worker
124+
count. GABRIEL ramps up, reads rate-limit signals, retries transient failures,
125+
and lowers actual concurrency when needed. Temporary retries and a few slow
126+
stragglers are normal: while the run is progressing, let it finish. Raising
127+
the ceiling can help a large workload when provisioned limits support more
128+
throughput; lowering it may help a known deployment constraint or persistent
129+
failure. A small test does not require a lower ceiling.
130+
- **Pilot, checkpoint, then scale.** Test a representative sample, inspect raw
131+
responses and output shape, and keep `reset_files=False` to resume a compatible
132+
run. Use a new `save_dir` when the model, prompt, fields, or labels change.
133+
93134
## Quick start
94135

95136
The tutorial notebook walks through many complete projects; here’s the minimal rating flow the notebook starts with. Paste this into Colab or a notebook cell so you can use `await` directly:
@@ -123,7 +164,8 @@ rate_results = await gabriel.rate(
123164
column_name="entity",
124165
attributes=attributes,
125166
save_dir=os.path.join(PATH, "toy_rate"),
126-
model="gpt-5.4-mini",
167+
model="gpt-5.6-luna",
168+
n_parallels=650, # normally leave this default unchanged
127169
n_runs=1,
128170
modality="entity",
129171
reset_files=True,
@@ -141,13 +183,13 @@ The tutorial notebook covers full projects end-to-end. The list below matches it
141183
- **`gabriel.rate`** – assign 0–100 scores per attribute across text, entities, images, audio, or web-sourced context.
142184
- **`gabriel.rank`** – pairwise tournaments that surface relative winners with grounded z-scores.
143185
- **`gabriel.classify`** – single- or multi-label tagging with label definitions and consensus columns.
144-
- **`gabriel.extract`**turn passages or multimodal product cards into tidy tables with optional schemas.
186+
- **`gabriel.extract`**extract typed fields or multiple entities from each passage, page, image, PDF, or audio item; one source may intentionally produce several rows.
145187
- **`gabriel.discover`** – contrast two labeled corpora to learn discriminating features.
146188

147189
### Qualitative coding and review
148190
- **`gabriel.codify`** highlights snippets that match qualitative codes and pairs with **`gabriel.view`** for UI-based auditing.
149191
- **`gabriel.compare`** contrasts paired items (drafts, policies, campaigns) with concise differences/similarities.
150-
- **`gabriel.bucket`** groups terms/entities into emergent taxonomies that feed back into rate/classify flows.
192+
- **`gabriel.bucket`** proposes bucket names and definitions from a large term universe; review that taxonomy, then use `classify` or another mapping step when row-level assignments are needed.
151193

152194
### Data prep and cleanup
153195
- **`gabriel.load`** converts folders of media into spreadsheets with clean IDs and file paths.
@@ -163,15 +205,32 @@ The tutorial notebook covers full projects end-to-end. The list below matches it
163205

164206
Set `modality` to `text`, `entity`, `pdf`, `image`, `audio`, or `web` on any measurement helper. Pair `gabriel.load` with folders of media to build the right DataFrame, and use `web_search=True` when GPT should gather context before rating or extracting. The tutorial’s county-level example shows how to chain web search → rating → mapping in one flow.
165207

208+
For image understanding, pass `image_detail="low"`, `"high"`, `"original"`,
209+
or `"auto"`; this is distinct from image-generation `quality`. Audio inputs need
210+
an audio-capable model and are routed through Chat Completions rather than the
211+
Responses API. At this documentation's 2026-07-13 review, use
212+
`gpt-audio-1.5`; `gpt-audio-mini` is deprecated. Verify the current audio slug
213+
before running an old example. Treat GABRIEL's pre-run cost estimate as rough
214+
for audio, tool calls, and very long contexts; consult live API pricing for the
215+
applicable modality and processing tier.
216+
166217
## Custom prompts and model routing
167218

168219
- Add clarifications with `additional_instructions` (e.g., mandate mutually exclusive labels).
169220
- Swap in your own Jinja `template_path` while keeping retries and checkpoints.
170221
- Drop to `gabriel.whatever` for fully custom prompts, attachments, or routing logic.
222+
- Treat every model name in an example as a dated snapshot; verify the exact current slug and endpoint support before overriding a default.
171223

172224
## Saving, logging, and resuming
173225

174-
Each run expands `save_dir` (tilde and environment variables supported), writes structured outputs (`file_name` CSV/Parquet), and saves raw model payloads under `responses/` with metadata for auditability. Leave `reset_files=False` to resume partially completed runs; delete the folder or pass `reset_files=True` to start fresh. `gabriel.view` reads these outputs for quick spot checks, and helpers like `gabriel.utils.mapmaker.MapMaker` can consume the same files for downstream visualization.
226+
Each run expands `save_dir` (tilde and environment variables supported), writes
227+
cleaned outputs, and checkpoints raw calls in task-specific files such as
228+
`*_raw_responses.csv`. Leave `reset_files=False` to resume a compatible partial
229+
run. When the research specification changes, use a fresh directory or pass
230+
`reset_files=True` intentionally so old responses are not mixed with a new
231+
prompt. Keep large generated outputs and private datasets outside the source
232+
repository. `gabriel.view` reads results for quick spot checks, and helpers like
233+
`gabriel.utils.mapmaker.MapMaker` can consume the same files downstream.
175234

176235
## Development and testing
177236

0 commit comments

Comments
 (0)