Reducing Token Usage on Specific Variables
Concerned about token usage on a variable? If extraction is slow or costs are higher than expected, the retrieval setting is often the first place to look. Here are some options to consider:
Hybrid + Pre-filtering
Before the AI reads a note, this setting scans it for lines that contain terms relevant to your variable. These are drawn from the variable name, instructions, answer options, and clinical synonyms and abbreviations Brim derives from them. The AI then reads only those lines plus a line of surrounding context, rather than all available notes. If no matching lines are found, Brim skips the AI call entirely and records the default value, so you're never spending tokens on notes that can't contain the answer.
This makes extraction faster, cheaper, and often more accurate. A note trimmed from hundreds of lines down to a dozen gives the AI less noise to wade through. When a variable runs on long or repetitive notes (e.g., daily nursing logs, medication administration records, or progress notes spanning months), pre-filtering can cut the text passed to the model by 50% or more. Brim also pulls in nearby negation cues phrases like "denies," "no evidence of," or "ruled out" so the AI can correctly identify when something was explicitly absent rather than present.
Top-ranked lines (optional): For an additional layer of trimming, you can set a Top-ranked lines limit on the variable. Brim scores each kept line by how likely it is to contain the answer factoring in how many search terms appear and whether the line contains a value matching your variable's type (a date, a number, a yes/no) and passes only the top N lines to the AI. Smaller limits mean lower cost; larger limits are safer but include more text.
When to use it:
- Notes are long or have many repeated entries (e.g., vitals charted every 4 hours)
- The variable has a clear, consistent keyword signal (e.g., "HbA1c," "INR," "blood pressure")
- Extraction is slow or hitting token limits on large patient records
Trade-off: This setting can miss mentions that are semantically relevant but use atypical phrasing. For example, a note saying "glycemic control was poor" might not surface if the keyword filter is anchored to "HbA1c" or "glucose." For variables where phrasing varies widely, plain Hybrid is safer.
To use Hybrid + Pre-filtering: Navigate to your variable, click edit variable, scroll down to "Advanced Settings," and find the "Index Type" row. Choose "Hybrid + Pre-filtering" from the dropdown and click "Save."

Conditional Generation: Skip running a variable entirely when it isn't relevant. In the "References" section of your variable settings, you can set conditions based on note date, note title, or the value of another variable so Brim only generates a value when your criteria are met. This avoids unnecessary LLM calls on notes where the variable wouldn't apply, saving both tokens and time.
This is especially useful when certain variables only matter in specific clinical contexts. For example, you might only run "Metastasis Site" when "Evidence of Cancer" = True, or restrict an oncology variable from running on primary care notes entirely. Conditions can be combined with AND/OR logic for more complex rules, giving you precise control over when each variable fires.
For more in depth steps for Conditional Generation please review the article here.

