stanfordnlp/CoreNLP · error · IllegalArgumentException

unnormalizedConditionalLogProbGivenFirst requires of one…

Error message

unnormalizedConditionalLogProbGivenFirst requires of one less than clique size ( ) but was 

What it means

unnormalizedConditionalLogProbGivenFirst is like conditionalLogProbGivenFirst but skips normalization by the full-table log probability. It imposes the same constraint: `of` must have exactly windowSize-1 labels, because together with the `given` first label it must fill the entire windowSize clique before the table can be indexed.

Solutions

  1. Construct `of` as exactly windowSize-1 label ids derived from the FactorTable's windowSize.
  2. When reusing query arrays across tables, rebuild them per table instead of sharing.
  3. Prefer higher-level scoring APIs (e.g. the CRF's scoresOf) that build windows internally.

Example fix

// before
int[] of = new int[]{5}; // assumes order-1
ft.unnormalizedConditionalLogProbGivenFirst(2, of);

// after
int[] of = new int[ft.windowSize - 1];
of[0] = 3; of[1] = 5; // fill windowSize-1 labels
ft.unnormalizedConditionalLogProbGivenFirst(2, of);
Defensive patterns

Strategy: validation

Validate before calling

// Java
int[] of = new int[ft.windowSize - 1]; // correct size by construction
// ... fill of ...
if (of.length != ft.windowSize - 1) throw new AssertionError();
double lp = ft.unnormalizedConditionalLogProbGivenFirst(given, of);

Try / catch

// Java
try {
  lp = ft.unnormalizedConditionalLogProbGivenFirst(given, of);
} catch (IllegalArgumentException e) {
  // resize `of` to windowSize-1 and recompute
  of = Arrays.copyOf(of, ft.windowSize - 1);
  lp = ft.unnormalizedConditionalLogProbGivenFirst(given, of);
}

Prevention

When it happens

Trigger: Calling unnormalizedConditionalLogProbGivenFirst(int given, int[] of) with of.length != windowSize-1; per the call graph this is reachable from scoresOf and the class main method, so custom scoring code that builds `of` manually is the usual path.

Common situations: Custom scorer/rescorer code that builds label windows with the wrong order; switching between FactorTable instances of different window sizes while reusing the same query arrays; test fixtures written against a different clique size.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/07bc866f5ba36d8c. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/ie/crf/FactorTable.java:335

    // compute P(given)
    // double probGiven = logProbFront(given);
    double probGiven = unnormalizedLogProbFront(given);

    // compute P(given, of) / P(given)
    return probAll - probGiven;
  }

  /**
   * Computes the probability of the sequence OF being at the end of the table
   * given that the first tag in table is GIVEN. given is at the beginning, of is
   * at the end.
   *
   * @return the probability of the sequence of being at the end of the table
   */
  public double unnormalizedConditionalLogProbGivenFirst(int given, int[] of) {
    if (of.length != windowSize - 1) {
      throw new IllegalArgumentException("unnormalizedConditionalLogProbGivenFirst requires of one less than clique size (" +
              windowSize + ") but was " + Arrays.toString(of));
    }
    // compute P(given, of)
    // double probAll = logProb(labels);
    double probAll = unnormalizedLogProb(given, of, windowSize - 1);

    // compute P(given)
    // double probGiven = logProbFront(given);
    // double probGiven = unnormalizedLogProbFront(given);

    // compute P(given, of) / P(given)
    // return probAll - probGiven;
    return probAll;
  }

  /**
   * Computes the probability of the tag OF being at the beginning of the table
   * given that the tag sequence GIVEN is at the end of the table. given is at

View on GitHub (pinned to 1b7edd19c4)