You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+67-8Lines changed: 67 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,16 +6,24 @@
6
6
7
7
You can install the GABRIEL Python library from [PyPI](https://pypi.org/project/openai-gabriel/) with `pip install openai-gabriel` and then `import gabriel`.
8
8
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
+
9
17
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).
10
18
11
19
## Table of contents
12
20
13
21
-[Why GABRIEL?](#why-gabriel)
14
22
-[What can you do with GABRIEL?](#what-can-you-do-with-gabriel)
15
23
-[Installation](#installation)
24
+
-[Using GABRIEL with coding agents](#using-gabriel-with-coding-agents)
16
25
-[Quick start](#quick-start)
17
26
-[Task highlights](#task-highlights)
18
-
-[Detailed usage](#detailed-usage)
19
27
-[Multimodal data and web search](#multimodal-data-and-web-search)
20
28
-[Custom prompts and model routing](#custom-prompts-and-model-routing)
21
29
-[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
42
50
|`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. |
43
51
|`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”. |
44
52
|`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. |
46
54
|`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. |
47
55
48
56
### B) Clean data
@@ -60,7 +68,7 @@ The tutorial notebook walks through these ideas step-by-step—from setting up a
60
68
| --- | --- | --- |
61
69
|`gabriel.codify`| Passage coding: highlights snippets in text that match qualitative codes. | Flag sentences about “economic insecurity” in speeches; “stressors” mentioned in interview. |
62
70
|`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. |
64
72
|`gabriel.seed`| Enforces a representative distribution / diversity of seeds. | Initialize unique personas that match US population distribution. |
65
73
|`gabriel.poll`| Seeds personas, expands them into full biographies, and surveys them. | Simulate a synthetic opinion poll on policy, values, and open-ended attitudes. |
66
74
|`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:
87
95
88
96
```bash
89
97
export OPENAI_API_KEY="sk-..."
90
-
# or os.environ['OPENAI_API_KEY'] = "sk-..." inside a Jupyter notebook
91
98
```
92
99
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
+
93
134
## Quick start
94
135
95
136
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:
n_parallels=650, # normally leave this default unchanged
127
169
n_runs=1,
128
170
modality="entity",
129
171
reset_files=True,
@@ -141,13 +183,13 @@ The tutorial notebook covers full projects end-to-end. The list below matches it
141
183
-**`gabriel.rate`** – assign 0–100 scores per attribute across text, entities, images, audio, or web-sourced context.
142
184
-**`gabriel.rank`** – pairwise tournaments that surface relative winners with grounded z-scores.
143
185
-**`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.
145
187
-**`gabriel.discover`** – contrast two labeled corpora to learn discriminating features.
146
188
147
189
### Qualitative coding and review
148
190
-**`gabriel.codify`** highlights snippets that match qualitative codes and pairs with **`gabriel.view`** for UI-based auditing.
149
191
-**`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.
151
193
152
194
### Data prep and cleanup
153
195
-**`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
163
205
164
206
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.
165
207
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
+
166
217
## Custom prompts and model routing
167
218
168
219
- Add clarifications with `additional_instructions` (e.g., mandate mutually exclusive labels).
169
220
- Swap in your own Jinja `template_path` while keeping retries and checkpoints.
170
221
- 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.
171
223
172
224
## Saving, logging, and resuming
173
225
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.
0 commit comments