Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…xtract() The top-level temperature argument was only merged into provider kwargs in the model_id branch. With a pre-built ModelConfig or model instance it was silently ignored, so requests carried no temperature parameter and generation ran at the server default, breaking the documented 'set to 0.0 for deterministic output' contract. - config= branch: merge an explicit temperature via dataclasses.replace, explicit kwarg wins over a config-supplied value, and the caller's ModelConfig is never mutated. - model= branch: emit a UserWarning instead of silently ignoring the argument, matching the existing use_schema_constraints warning. - Four cases added to ExtractParameterPrecedenceTest. Fixes google#529
|
@googlebot I signed it! |
62a7987 to
9b7896b
Compare
|
Your branch is 1 commits behind git fetch origin main
git merge origin/main
git pushNote: Enable "Allow edits by maintainers" to allow automatic updates. |
|
Your branch is 4 commits behind git fetch origin main
git merge origin/main
git pushNote: Enable "Allow edits by maintainers" to allow automatic updates. |
|
Your branch is 7 commits behind git fetch origin main
git merge origin/main
git pushNote: Enable "Allow edits by maintainers" to allow automatic updates. |
Description
extract()accepts a top-leveltemperatureargument documented as "Set to 0.0for deterministic output", but the value is only merged into provider kwargs in
the
model_idbranch ofextraction.py. When a caller passes a pre-builtconfig=(factory.ModelConfig) ormodel=(a language model instance), theargument is silently ignored: the request carries no
temperatureparameter atall (the OpenAI provider omits it when the value is
None), so generation runsat the server default temperature.
We found this with a batch-invariant vLLM deployment: raw API probes at
temperature 0 were byte-identical across runs, while extractions through
langextract differed run to run. A wire capture showed the request parameters
were
{"model", "n", "response_format"}with no temperature despitetemperature=0.0being passed.This PR:
config=branch: merges an explicittemperatureinto the config viadataclasses.replace, so the caller'sModelConfigis never mutated. Anexplicit kwarg wins over a config-supplied value; with no explicit kwarg the
config value is untouched.
model=branch: emits aUserWarninginstead of silently ignoring theargument (a constructed model has no provider-agnostic temperature setter, and
silently mutating caller-configured state seemed worse). This mirrors the
existing
use_schema_constraintswarning in the same branch.temperature,config, andmodeldocstrings with theprecedence rule.
Fixes #529
Choose one: Bug fix
How Has This Been Tested?
Added
tests/extract_precedence_test.pywith four tests covering theprecedence rules: explicit kwarg wins over a config-supplied value, a
config-supplied value survives when no kwarg is passed, the caller's
ModelConfigis not mutated, and themodel=branch warns. Ran the new fileand the full suite:
All pass. The original symptom was also re-verified end to end against our
batch-invariant vLLM deployment: with the patch, extractions at
temperature=0.0are byte-identical across runs, matching the raw API probes.Checklist:
Code of conduct.
Contributing
page, and I either signed the Google
Individual CLA
or am covered by my company's
Corporate CLA.
issue(s) and we have agreed upon the general approach.
issue(s) that documentation elsewhere needs updating.
Google's Python Style Guide
and ran
pylintover the affected code.