Вот код, который я использую для загрузки модель:
Код: Выделить всё
from transformers import AutoModelForCausalLM, BitsAndBytesConfig
# Define the quantization configuration
kwargs = {
"quantization_config": BitsAndBytesConfig(
load_in_4bit=True,
load_in_8bit=False,
bnb_4bit_compute_dtype="float32",
bnb_4bit_quant_storage="uint8",
bnb_4bit_quant_type="fp4",
bnb_4bit_use_double_quant=False,
llm_int8_enable_fp32_cpu_offload=False,
llm_int8_has_fp16_weight=False,
llm_int8_skip_modules=None,
llm_int8_threshold=6.0
)
}
model = AutoModelForCausalLM.from_pretrained(
"ThetaCursed/Ovis1.6-Gemma2-9B-bnb-4bit",
trust_remote_code=True,
**kwargs
).cuda()
Код: Выделить всё
warnings.warn(_BETA_TRANSFORMS_WARNING)
Unused kwargs: ['_load_in_4bit', '_load_in_8bit', 'quant_method'].
Loading checkpoint shards: 100%|██████████| 2/2 [00:06
Подробнее здесь: [url]https://stackoverflow.com/questions/79130264/how-to-load-a-4-bit-quantized-vlm-model-from-hugging-face-with-transformers[/url]