{"record":{"id":"ee75b68409f2a01e","repo":"stanfordnlp/CoreNLP","slug":"crflogconditionalobjectivefloatfunction-is-not-cli","errorCode":null,"errorMessage":"CRFLogConditionalObjectiveFloatFunction is not clique potential compatible yet","messagePattern":"CRFLogConditionalObjectiveFloatFunction is not clique potential compatible yet","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/crf/CRFLogConditionalObjectiveFloatFunction.java","lineNumber":84,"sourceCode":"    this.backgroundSymbol = backgroundSymbol;\n    this.sigma = (float) sigma;\n    empiricalCounts(data, labels);\n  }\n\n  @Override\n  public int domainDimension() {\n    if (domainDimension < 0) {\n      domainDimension = 0;\n      for (int aMap : map) {\n        domainDimension += labelIndices.get(aMap).size();\n      }\n    }\n    return domainDimension;\n  }\n\n  @Override\n  public CliquePotentialFunction getCliquePotentialFunction(double[] x) {\n    throw new UnsupportedOperationException(\"CRFLogConditionalObjectiveFloatFunction is not clique potential compatible yet\");\n  }\n\n  public float[][] to2D(float[] weights) {\n    float[][] newWeights = new float[map.length][];\n    int index = 0;\n    for (int i = 0; i < map.length; i++) {\n      newWeights[i] = new float[labelIndices.get(map[i]).size()];\n      System.arraycopy(weights, index, newWeights[i], 0, labelIndices.get(map[i]).size());\n      index += labelIndices.get(map[i]).size();\n    }\n    return newWeights;\n  }\n\n  public float[] to1D(float[][] weights) {\n    float[] newWeights = new float[domainDimension()];\n    int index = 0;\n    for (float[] weight : weights) {\n      System.arraycopy(weight, 0, newWeights, index, weight.length);","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/crf/CRFLogConditionalObjectiveFloatFunction.java#L66-L102","documentation":"getCliquePotentialFunction is part of the clique-potential-based CRF training API, but the float-precision objective function was never implemented for it. Any code path that requests a clique potential function from CRFLogConditionalObjectiveFloatFunction gets this UnsupportedOperationException — it is a deliberate not-implemented marker.","triggerScenarios":"Invoking training/decoding code paths that require CliquePotentialFunction (e.g. certain custom potential or factor-based trainers) while using the float variant of the CRF log-conditional objective.","commonSituations":"Switching CRFClassifier to float weights (FloatCRF variants) and then using a trainer or objective that assumes the double-precision clique potential API.","solutions":["Use the double-precision CRFLogConditionalObjectiveFunction, which implements getCliquePotentialFunction.","Avoid trainer/API combinations that call getCliquePotentialFunction with the float objective.","If float precision is required, implement getCliquePotentialFunction by wrapping to2D(weights) in a float CliquePotentialFunction.","Check the Stanford NLP version for updates where float clique-potential support may have been added."],"exampleFix":"// before\nCRFLogConditionalObjectiveFloatFunction func = new CRFLogConditionalObjectiveFloatFunction(...);\ntrainer.setObjective(func); // calls getCliquePotentialFunction -> throws\n// after\nCRFLogConditionalObjectiveFunction func = new CRFLogConditionalObjectiveFunction(data, labels, classIndex, labelIndices, map, \"L2\");","handlingStrategy":"try-catch","validationCode":"if (objective instanceof CRFLogConditionalObjectiveFloatFunction)\n  throw new UnsupportedOperationException(\"float objective does not support clique potentials; use CRFLogConditionalObjectiveFunction\");","typeGuard":"static boolean supportsCliquePotential(Object f) {\n  return !(f instanceof CRFLogConditionalObjectiveFloatFunction);\n}","tryCatchPattern":"try {\n  CliquePotentialFunction cpf = func.getCliquePotentialFunction(x);\n} catch (UnsupportedOperationException e) {\n  func = new CRFLogConditionalObjectiveFunction(data, labels, window, classIndex, labelIndices, map, priorType, backgroundSymbol, sigma, featureVal, gradThreads);\n  CliquePotentialFunction cpf = func.getCliquePotentialFunction(x);\n}","preventionTips":["Check which objective function a trainer requires before enabling float mode.","Only use float CRF variants with code paths that do not need clique potentials.","Consult the library version's changelog for float clique-potential support."],"tags":["unsupported-operation","floating-point","training","crf"],"backgroundTag":"unsupported-operation","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}