Format of the Queries and Answers for the Molecular Verifier Server
All queries to the Molecular Verifier server and its responses follow specific formats defined using Pydantic models. Below we outline the expected structure for both requests and responses.
MolecularVerifierServerQuery
Bases: BaseModel
Input query model for the Molecular Verifier server.
Represents a complete request to the molecular verifier service, containing metadata for scoring and completions to evaluate.
Attributes:
| Name | Type | Description |
|---|---|---|
metadata |
List[dict[str, Any]]
|
List of metadata dictionaries, one per query item. Each dictionary will be converted to a MolecularVerifierMetadata object for scoring. |
query |
List[str]
|
List of completion strings from the language model. The parser extracts content between these tags based on 'parsing_method' |
prompts |
Optional[List[str]]
|
Optional. Original prompts used to generate the completions. Useful for tracking and debugging. If provided, should have same length as query list. |
Notes: This model also supports single-item requests not in list form. For example:
{
"query": "Here is a molecules: <answer>CC(C)Cc1ccc(cc1)C(C)C(=O)O</answer>",
"prompt": "Generate a molecule that binds to my target protein with high affinity and has more than 3 rotatable bonds.",
"metadata": {
"properties": ["CalcNumRotatableBonds", "sample_228234_model_0"],
"objectives": ["above", "minimize"],
"target": [3.0, 0.0]
}
}
{ "query": ["Here is a molecules: <answer>CC(C)Cc1ccc(cc1)C(C)C(=O)O</answer>"],
"prompt": ["Generate a molecule that binds to my target protein with high affinity and has more than 3 rotatable bonds."],
"metadata": [
{
"properties": ["CalcNumRotatableBonds", "sample_228234_model_0"],
"objectives": ["above", "minimize"],
"target": [3.0, 0.0]
}
]
}
Example:
{
"query": "Here is a molecules: <answer>CC(C)Cc1ccc(cc1)C(C)C(=O)O</answer>",
"prompt": "Generate a molecule that binds to my target protein with high affinity and has more than 3 rotatable bonds.",
"metadata": [
{
"properties": ["CalcNumRotatableBonds", "sample_228234_model_0"],
"objectives": ["above", "minimize"],
"target": [3.0, 0.0]
}
]
}
Source code in mol_gen_docking/server_utils/utils.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
convert_to_lists(v)
classmethod
Automatically convert fields to lists if they are not already.
Ensures that metadata, query, and prompts fields are lists. If a field is not a list, it will be wrapped in a list. None values are left as-is for optional fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Any
|
The field value to potentially convert |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The value as a list, or None if the input is None |
Source code in mol_gen_docking/server_utils/utils.py
validate_equal_lengths()
Validate that all fields have equal length.
Ensures that metadata, query, and prompts lists all have the same length. This validator runs after all fields have been set and converted.
Returns:
| Type | Description |
|---|---|
MolecularVerifierServerQuery
|
The validated instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If field lengths are not equal |
Source code in mol_gen_docking/server_utils/utils.py
MolecularVerifierServerMetadata
Bases: BaseModel
Metadata returned with each scored molecule.
Aggregates detailed scoring information from all verifier types (Generation, Molecular Property, and Reaction). Each field may be populated or empty depending on which verifier was used.
Attributes:
| Name | Type | Description |
|---|---|---|
parsed_answer |
str
|
The parsed answer extracted from the model completion. |
generation_verifier_metadata |
Optional[GenerationVerifierMetadataModel]
|
Metadata from the generation verifier containing:
|
mol_prop_verifier_metadata |
Optional[MolPropVerifierMetadataModel]
|
Metadata from the molecular property verifier containing:
|
reaction_verifier_metadata |
Optional[ReactionVerifierMetadataModel]
|
Metadata from the reaction verifier containing:
|
Source code in mol_gen_docking/server_utils/utils.py
MolecularVerifierServerResponse
Bases: BaseModel
Response from the Molecular Verifier server when the sever is in single-item mode (default).
Contains the computed reward score and detailed metadata for a single evaluated completion.
Attributes:
| Name | Type | Description |
|---|---|---|
reward |
float
|
Overall reward score combining all evaluated properties. Typically normalized to [0.0, 1.0] range when rescaling is enabled. |
error |
Optional[str]
|
Error message if scoring failed. None if successful. |
meta |
MolecularVerifierServerMetadata
|
Metadata dictionary with detailed scoring information. Contains extraction failures, property rewards, and verification results for the completion. |
next_turn_feedback |
Optional[str]
|
Optional feedback for multi-turn conversations. Can be used to guide subsequent model generations. |
Example
Source code in mol_gen_docking/server_utils/utils.py
validate_reward(v)
classmethod
Validate and normalize reward value.
If reward is None or NaN, sets it to 0.0. Ensures reward is a valid float.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Any
|
The reward value to validate |
required |
Returns:
| Type | Description |
|---|---|
float
|
The validated reward value (float), or 0.0 if None/NaN |
Raises:
| Type | Description |
|---|---|
ValueError
|
If reward is not a valid numeric type |
Source code in mol_gen_docking/server_utils/utils.py
BatchMolecularVerifierServerResponse
Bases: BaseModel
Response from the Molecular Verifier server when in batch mode.
Contains the computed reward scores and detailed metadata for each evaluated completion.
Attributes:
| Name | Type | Description |
|---|---|---|
rewards |
List[float]
|
List of individual reward scores, one per evaluated completion in the request. |
error |
Optional[str]
|
Error message if scoring failed. None if successful. |
metas |
List[MolecularVerifierServerMetadata]
|
List of metadata dictionaries with detailed scoring information. Contains extraction failures, property rewards, and verification results for each completion. One metadata object per query item. |
next_turn_feedback |
Optional[str]
|
Optional feedback for multi-turn conversations. Can be used to guide subsequent model generations. |
Example
Source code in mol_gen_docking/server_utils/utils.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
validate_rewards(v)
classmethod
Validate and normalize reward value.
If any reward is None or NaN, sets it to 0.0. Ensures reward is a valid float.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Any
|
The reward value to validate |
required |
Returns:
| Type | Description |
|---|---|
List[float]
|
The validated reward value (float), or 0.0 if None/NaN |
Raises:
| Type | Description |
|---|---|
ValueError
|
If reward is not a valid numeric type |