Save and load UQ Ensemble [Viren]#72
Merged
Merged
Conversation
Mihir3
pushed a commit
to Mihir3/uqlm
that referenced
this pull request
Jul 7, 2025
…ren virenbajaj4@gmail.com * WIP save and load uqe * with tests * format with ruff * add env variable support and test * update env var names * add dot env to dependencies * ruff format * simplified llm config save and load * reset to old commit * change llm env args * remove dotenv dependency * remove endpoints from * remove endpoints from config - tests * format --------- Co-authored-by: Viren Bajaj <bajajv@aetna.com> Co-authored-by: Viren <virenbajaj4@gmail.com>
nklswld
pushed a commit
to nklswld/uqlm_white_box_scorer
that referenced
this pull request
Nov 7, 2025
…ren virenbajaj4@gmail.com * WIP save and load uqe * with tests * format with ruff * add env variable support and test * update env var names * add dot env to dependencies * ruff format * simplified llm config save and load * reset to old commit * change llm env args * remove dotenv dependency * remove endpoints from * remove endpoints from config - tests * format --------- Co-authored-by: Viren Bajaj <bajajv@aetna.com> Co-authored-by: Viren <virenbajaj4@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Save/Load Configuration Functionality to UQEnsemble
Summary
This PR adds the ability to save and load UQEnsemble configurations, enabling users to persist tuned weights, thresholds, and component configurations for reproducible experiments and model deployment.
Changes Made
New Methods Added
save_llm_config(): Helper function to extract and serialize LLM configuration parametersload_llm_config(): Helper function to recreate LLM instances from saved configurationsave_config(): Instance method to save ensemble configuration to JSON fileload_config(): Class method to create UQEnsemble instance from saved configurationKey Features
Parameter Exclusion
The system excludes the following from saved configurations:
internal_attrsset (e.g.,config_specs,lc_attributes,model_config)endpoint_attrsset (e.g.,base_url,endpoint,azure_endpoint,api_base)Environment Variables
API credentials must be set in environment variables for the load to work properly. The LLM modules automatically read standard environment variable names such as:
AZURE_OPENAI_API_KEY,AZURE_OPENAI_ENDPOINTfor Azure OpenAIGOOGLE_APPLICATION_CREDENTIALSfor Google Vertex AIConfiguration Format
The saved JSON includes:
weights: Ensemble component weights (typically from tuning)thresh: Decision thresholdcomponents: List of scorer components (named strings or serialized LLM references)llm_config: Main LLM configuration for recreationllm_scorers: Configurations for LLM-based scorer componentsExample Configuration
{ "weights": [ 0.22517161424882978, 0.5256472050407895, 0.20544462057286958, 0.04343460765924121, 0.00030195247826969915 ], "thresh": 0.85, "components": [ "exact_match", "noncontradiction", "normalized_probability", "judge_1", "judge_2" ], "llm_config": { "class_name": "ChatVertexAI", "module": "langchain_google_vertexai.chat_models", "convert_system_message_to_human": false, "default_metadata": [], "endpoint_version": "v1beta1", "full_model_name": "projects/anbc-dev-csr-va/locations/us-central1/publishers/google/models/gemini-1.5-flash", "location": "us-central1", "logprobs": true, "max_retries": 6, "model_family": "2", "model_name": "gemini-1.5-flash", "n": 1, "perform_literal_eval_on_string_raw_content": true, "project": "anbc-dev-csr-va", "request_parallelism": 5, "streaming": false, "verbose": false }, "llm_scorers": { "judge_1": { "class_name": "ChatVertexAI", "module": "langchain_google_vertexai.chat_models", "convert_system_message_to_human": false, "default_metadata": [], "endpoint_version": "v1beta1", "full_model_name": "projects/anbc-dev-csr-va/locations/us-central1/publishers/google/models/gemini-1.5-flash", "location": "us-central1", "logprobs": true, "max_retries": 6, "model_family": "2", "model_name": "gemini-1.5-flash", "n": 1, "perform_literal_eval_on_string_raw_content": true, "project": "anbc-dev-csr-va", "request_parallelism": 5, "streaming": false, "verbose": false }, "judge_2": { "class_name": "AzureChatOpenAI", "module": "langchain_openai.chat_models.azure", "deployment_name": "gpt-4o", "model_version": "", "openai_api_type": "azure", "openai_api_version": "2024-02-15-preview", "streaming": false, "temperature": 1.0, "verbose": false } } }Usage
Benefits
Technical Notes
Dependencies