Skip to content

The agent engineering platform.

fix: more robust check whether the HF model is quantized (#11891)

eryk-dsai5019f59724b2
diff --git a/libs/langchain/langchain/llms/huggingface_pipeline.py b/libs/langchain/langchain/llms/huggingface_pipeline.py
index 291fb5a69d..4c77a71c01 100644
--- a/libs/langchain/langchain/llms/huggingface_pipeline.py
+++ b/libs/langchain/langchain/llms/huggingface_pipeline.py
@@ -109,9 +109,8 @@ class HuggingFacePipeline(BaseLLM):
) from e
if (
- model.is_quantized
- or model.model.is_loaded_in_4bit
- or model.model.is_loaded_in_8bit
+ getattr(model, "is_loaded_in_4bit", False)
+ or getattr(model, "is_loaded_in_8bit", False)
) and device is not None:
logger.warning(
f"Setting the `device` argument to None from {device} to avoid "