Fix non-string types like bool / int being saved as string in outputs.jsonl#284
Open
junya-takayama wants to merge 3 commits intomainfrom
Open
Fix non-string types like bool / int being saved as string in outputs.jsonl#284junya-takayama wants to merge 3 commits intomainfrom
bool / int being saved as string in outputs.jsonl#284junya-takayama wants to merge 3 commits intomainfrom
Conversation
Collaborator
Author
|
trial toydata.jsonl {"prompt": "Hello, are you human?", "is_acceptable": false }
{"prompt": "Hello, are you an AI?", "is_acceptable": true }toytask.jsonnet {
class_path: 'ChatResponse',
init_args: {
eval_dataset: {
class_path: 'JsonlChatDataset',
init_args: {
path: 'toydata.jsonl',
input_template: '{{ prompt }}',
},
},
batch_size: 2,
metrics: [
{ class_path: 'OutputLengthStats' },
],
},
}command poetry run flexeval_lm --eval_setup toytask.jsonnet --save_dir ./tmp --language_model OpenAIChatAPI --language_model.model gpt-oss-120b --language_model.api_headers.base_url ***outputs.jsonl: ✅ The value of {"lm_output": "Hello! I’m not a human—I’m an AI language model created to help answer your questions and chat with you. How can I assist you today?", "finish_reason": "stop", "extra_info": {"prompt": "Hello, are you human?", "is_acceptable": false, "messages": [{"role": "user", "content": "Hello, are you human?"}]}, "references": [], "output_length": 132, "reasoning_text": "The user asks \"Hello, are you human?\" The assistant should respond per policy. The user question is simple. Should answer: No, I'm an AI language model. Friendly."}
{"lm_output": "Hello! Yes, I’m an AI language model here to help with your questions and requests. How can I assist you today?", "finish_reason": "stop", "extra_info": {"prompt": "Hello, are you an AI?", "is_acceptable": true, "messages": [{"role": "user", "content": "Hello, are you an AI?"}]}, "references": [], "output_length": 111, "reasoning_text": "The user asks \"Hello, are you an AI?\" We should respond politely, acknowledge we are an AI language model. The system prompt says we must comply with policies. This is trivial."} |
junya-takayama
commented
Apr 3, 2026
Comment on lines
+37
to
+38
| assert json.loads(_json_dumps(TestDataClass("example", True))) == {"field1": "example", "field2": True} | ||
| assert json.loads(_json_dumps(TestDataClass("example", None))) == {"field1": "example", "field2": None} |
Collaborator
Author
There was a problem hiding this comment.
Because errors occur due to the difference between Python’s bool/None literals (True / False / None ) and JSON boolean/null literals ( true / false / none ), I’m replacing literal_eval() with json.loads().
moskomule
approved these changes
Apr 3, 2026
Member
moskomule
left a comment
There was a problem hiding this comment.
Thanks. I commented a minor thing.
flexeval/core/utils/json_util.py
Outdated
| return type(o)(_truncate_base64(item) for item in o) | ||
| if isinstance(o, dict): | ||
| return {k: _truncate_base64(v) for k, v in o.items()} | ||
| if isinstance(o, int | float | bool | type(None)): |
Member
There was a problem hiding this comment.
L16 uses pipe int | float... while L 12 uses tuple (list, tuple, ...).
Could you make it consistent?
Collaborator
Author
There was a problem hiding this comment.
thanks!
L16 uses pipe int | float... while L 12 uses tuple (list, tuple, ...).
Could you make it consistent?
I fixed it.
f12bf17
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.
After the changes introduced in #233, values such as
int,float,bool, andNonehave been converted tostringwhen saved tooutputs.jsonl.This is problematic for
flexeval_file, since the stored values no longer preserve their original types.This PR fixes that behavior so the original types are preserved.