[Python] about llama-2-7b model loading from huggingface even with meta liscence access

Discussão em 'Python' iniciado por Stack, Abril 7, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to access load this model but it gives me same error how to fix this?

    from transformers import AutoTokenizer, AutoModelForCausalLM

    model_id = "meta-llama/Llama-2-7b-hf"

    tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained( model_id, device_map={"": "cpu"}, torch_dtype="float32" )

    prompt = "Explain quantum computing in simple terms." inputs = tokenizer(prompt, return_tensors="pt")

    output = model.generate(**inputs, max_new_tokens=100) print(tokenizer.decode(output[0], skip_special_tokens=True))


    HTTPError Traceback (most recent call last) File c:\Chatbot\huggingface\huggingface\lib\site-packages\huggingface_hub\utils_http.py:409, in hf_raise_for_status(response, endpoint_name) 408 try: --> 409 response.raise_for_status() 410 except HTTPError as e:

    File c:\Chatbot\huggingface\huggingface\lib\site-packages\requests\models.py:1024, in Response.raise_for_status(self) 1023 if http_error_msg: -> 1024 raise HTTPError(http_error_msg, response=self)

    HTTPError: 403 Client Error: Forbidden for url: https://huggingface.co/meta-llama/Llama-2-7b-hf/resolve/main/config.json

    The above exception was the direct cause of the following exception:

    HfHubHTTPError Traceback (most recent call last) File c:\Chatbot\huggingface\huggingface\lib\site-packages\huggingface_hub\file_download.py:1484, in _get_metadata_or_catch_error(repo_id, filename, repo_type, revision, endpoint, proxies, etag_timeout, headers, token, local_files_only, relative_filename, storage_folder) 1483 try: -> 1484 metadata = get_hf_file_metadata( 1485 url=url, proxies=proxies, timeout=etag_timeout, headers=headers, token=token 1486 ) 1487 except EntryNotFoundError as http_error:

    File c:\Chatbot\huggingface\huggingface\lib\site-packages\huggingface_hub\utils_validators.py:114, in validate_hf_hub_args.._inner_fn(*args, **kwargs) 112 kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.name, has_token=has_token, kwargs=kwargs) ... 497 # later on anyway and re-raised if needed 498 elif isinstance(e, HTTPError) and not isinstance(e, EntryNotFoundError):

    OSError: We couldn't connect to 'https://huggingface.co' to load the files, and couldn't find them in the cached files. Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'. Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

    Continue reading...

Compartilhe esta Página