From 4e387e114228b7ffed87a9113507b04d02f7a1c6 Mon Sep 17 00:00:00 2001 From: Mark Harfouche Date: Wed, 6 Aug 2025 08:36:54 -0400 Subject: [PATCH] Address deprecation in fromstring to frombuffer Deprecated since numpy 1.14 according to https://github.com/numpy/numpy/pull/28254 This should be the correct fix for https://github.com/huggingface/transformers.js/issues/1343 And after this is merged, one can likely just revert this https://github.com/huggingface/transformers.js/pull/1351 --- scripts/float16.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/float16.py b/scripts/float16.py index 0be170f33..a5beb5c66 100644 --- a/scripts/float16.py +++ b/scripts/float16.py @@ -135,7 +135,7 @@ def convert_tensor_float_to_float16(tensor, min_positive_val=1e-7, max_finite_va # convert raw_data (bytes type) if tensor.raw_data: # convert n.raw_data to float - float32_list = np.fromstring(tensor.raw_data, dtype="float32") + float32_list = np.frombuffer(tensor.raw_data, dtype="float32") # convert float to float16 float16_list = convert_np_to_float16( float32_list, min_positive_val, max_finite_val