1

I have created a RAG (Retrieval-augmented generation) pipeline and using it with a 4-bit quantized openllama 13b loaded directly from hugging face and without fine-tuning the model.

  1. At first I need to save the model into local. But after using torch.save(model.state_dict(), 'path') to save the model, the model saved as adapter model and I can not load it from local again as well as can not able to push into hugging face.
  2. How can I use this configuration into hugging face to make inference API in the hugging face interface?

Here is the code of loading quantized model:

bnb_config = transformers.BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type='nf4',
    bnb_4bit_use_double_quant=True,
    bnb_4bit_compute_dtype=bfloat16
)
hf_auth = '*'
model_config = transformers.AutoConfig.from_pretrained(
    model_id,
    use_auth_token=hf_auth
)
model = transformers.AutoModelForCausalLM.from_pretrained(
    model_id,
    trust_remote_code=True,
    config=model_config,
    quantization_config=bnb_config,
    device_map='auto',
    use_auth_token=hf_auth
)
model.eval()
No Flag
  • 11
  • 3

0 Answers0