Fubar Folio Protect yourself and those you love with knowledge

OpenAI with the manuals

Search the shipped OpenAI index with your own key. The pack never ships a key.

How to use the Fubar Folio manuals with OpenAI

This route uses the pack’s precomputed OpenAI embeddings, so you embed only your search query. The manual vectors stay on your computer and are not uploaded to a hosted vector store. You supply your own OpenAI API key. Fubar Folio does not ship a key, and this guide will not ask you to paste one into a file, ticket, or chat.

A Fubar Folio product from White Hat IT Services, by Trevor Kimball. Questions: hello@fubarfolio.com


1. Unpack the AI-text pack (if you have not already)

This is the same archive the other AI guides use: fubarfolio-manuals-ai-text-2026-11-23.tar.gz. The unpacked folder fubarfolio-manuals-ai-text-2026-11-23/ is the library root.

# macOS / Linux
tar -xzf fubarfolio-manuals-ai-text-2026-11-23.tar.gz -C ~/FubarFolio
cd ~/FubarFolio/fubarfolio-manuals-ai-text-2026-11-23
python3 verify_manifest.py

Windows steps are in 03-ollama-with-manuals.html.

What this route uses:

Path Role
indexes/openai/openai_search.py Query script
indexes/openai/text-embedding-3-small.f32.npy Precomputed vectors
indexes/openai/text-embedding-3-small.index.json Matching id index
data/include/ and data/flagged/ JSONL text used to print snippets
figures/figure_search.py Optional figure search

The OpenAI index has 74,051 sections (text-embedding-3-small, 1,536 dimensions, L2-normalized). That is two fewer than the 74,053 chunks in the Claude and Ollama indexes. Two raw-text page chunks have no OpenAI embedding and are left out on purpose.

flowchart LR
  Q[Your query] --> K[Your OPENAI_API_KEY]
  K --> API["api.openai.com/v1/embeddings\nmodel text-embedding-3-small"]
  API --> V[Query vector]
  V --> S[openai_search.py compares locally]
  IDX[Shipped 74,051 vectors stay on disk] --> S
  S --> H[Top matching sections + snippets]

2. Python and dependencies

You need Python 3.9 or newer, plus numpy (numpy>=1.26 in requirements.txt). openai_search.py talks to the OpenAI HTTP API using the Python standard library, so you do not need the openai Python package for text search.

From the library root:

macOS / Linux

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Windows

python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt

3. Set your API key in the environment, never in the pack

Create a key in your own OpenAI account. Then set it for the current terminal session only.

macOS / Linux

export OPENAI_API_KEY=your-key-here

Windows (current Command Prompt session)

set OPENAI_API_KEY=your-key-here

Windows (current PowerShell session)

$env:OPENAI_API_KEY = "your-key-here"

Do not:

  • Put the key in a command you will paste into email, chat, or a ticket.
  • Commit it to a git repo, or put it in indexes/openai/ or any other file inside the pack.
  • Share a screenshot that shows the key.

The script reads only the OPENAI_API_KEY environment variable. If it is missing, the script exits and tells you to set it.


4. Search

From the library root:

python3 indexes/openai/openai_search.py "how to request a casualty evacuation 9-line"

Usage, from the script:

openai_search.py "query" [k]

k defaults to 5. By default the script runs search v3. It combines local keyword search with the precomputed 512-dimension vectors, over both the manual text and an index of questions each section answers (indexes/d2q/). Near-identical editions are collapsed into one hit (also_in). An OpenAI model then re-orders the top 30 with a manual-aware prompt (about $0.0014 per query; the model is set by OPENAI_RERANK_MODEL, default gpt-6-luna).

Next comes the answer picker, which is on by default when a key is set, starting with the 2026-11-23 pack. gpt-6.1-terra reads the top 8 results and moves the passage that best answers your question to first place. It costs about $0.005 per query and takes about 1.2 seconds. On a 600-question sample of the held-out test set, the first result answered the question 87.0% of the time with the picker vs 78.5% without, judged by an AI grader (gpt-6.1-terra). A second grader, Claude Sonnet, gave 88.0% vs 79.5% on 200 of them. After discounting partial answers, the figures were about 78% vs 71%.

Optional flags: --pick off (or FUBAR_PICK=0) skips the picker; --pick-provider claude uses Claude Sonnet with your ANTHROPIC_API_KEY instead (about $0.0135 per query); --no-rerank (or FUBAR_RERANK=0) skips the re-rank; --mode keyword runs keyword search only (no key, no network); --v2 runs the previous hybrid search (add --rerank for its re-rank); --legacy runs the original whole-section vector search; and --json.

If a call fails, the script falls back and prints which tier it used. If the picker fails, it keeps the re-ranked order. If the re-rank fails, it uses search v3 without re-rank. If the query embedding fails, it uses keyword search.

In the strict retrieval test (finding the exact source section for each question), the default put that section first for 55.0% of the 600-question sample and in the top 5 for 83.7% (51.8% first with --pick off). On all 2,695 held-out questions, measured before the picker, the section was in the top 5 for 79.2% with --no-rerank and 75.2% with --mode keyword (previous hybrid: 78.2%; original search: 50%).

For a short answer with page citations, run python3 indexes/ask.py "your question". It needs the key and was graded correct for 90.3% of 600 test questions, measured before the picker. You can also run python3 openai_search.py "..." from inside indexes/openai/.

[sketch — not a screenshot]

$ python3 indexes/openai/openai_search.py "how to request a 9-line medevac" 5
Q: how to request a 9-line medevac
  0.812  some-manual-id#c0001  some-manual-id  p12-13  Section name
    (up to 400 characters of the matching passage)

Your query text is sent to https://api.openai.com/v1/embeddings with model text-embedding-3-small. The re-rank (and ask.py) also sends excerpts of the top passages to https://api.openai.com/v1/responses. The answer picker sends your question with excerpts of the top 8 passages (up to 2,000 characters each) there too, or to Anthropic with --pick-provider claude. Use --pick off to skip the picker and --no-rerank to skip the re-rank. The comparison against the 74,051 shipped vectors happens on your machine.


5. Rough cost per query

OpenAI’s published price for text-embedding-3-small is $0.02 per 1 million tokens (model page; also see the pricing page). Prices change, so check those pages for the current figure.

A short question is typically a few dozen tokens, so embedding a single search costs a small fraction of a cent. The default re-rank and answer picker add the per-query costs listed in section 4. You are not charged again for the 74,051 manual vectors. Those were computed before the pack was built.


6. Optional: search figures

The AI-text pack also includes a figure index (38,033 figures from the same 718 manuals). The images themselves are in the separate Figures pack (fubarfolio-manuals-figures-2026-11-17.tar), under figures/<manual_id>/.... The search script prints an image_path you can use to find the file after you unpack that pack.

Keyword search (offline, no API key, standard library only):

python3 figures/figure_search.py "litter carry"
python3 figures/figure_search.py "tourniquet application"

Semantic search (embeds the query with your key; default k is 10):

python3 figures/figure_search.py "how to tie a prusik" --semantic

Flags, from the script:

Flag Meaning
-k N How many hits (default 10)
--semantic Vector search instead of keyword
--manual <manual_id> Limit to one manual
--include-only Skip rights-flagged titles
--no-usmc Skip Marine Corps reserved-graphics titles

Note: --semantic uses the openai Python package (from openai import OpenAI), which is not listed in requirements.txt. Keyword search does not need that package. For semantic figure search, install it in the same virtualenv (pip install openai). It also reads OPENAI_API_KEY from the environment. Figure captions and machine-written descriptions can contain errors. Treat them as search aids, not as a substitute for the image or the manual page.

[sketch — not a screenshot]

$ python3 figures/figure_search.py "litter carry"
  1.234  ATP x-xx  p.41  Litter-carry illustration
          figures/some-manual-id/some-image.webp  [figure] (short description)

Sources

  • Pack files: indexes/openai/openai_search.py, figures/figure_search.py, requirements.txt, library README.md
  • OpenAI, text-embedding-3-small (includes the $0.02 / 1M tokens price): https://developers.openai.com/api/docs/models/text-embedding-3-small
  • OpenAI, pricing: https://developers.openai.com/api/docs/pricing