Spaces:
Sleeping
Sleeping
Download examples/tests/hf_login.py from LVKinyanjui/QueryYourDocs: direct link, hf CLI and curl.
- Browser
- Download file 476 Bytes
-
https://huggingface.co/spaces/LVKinyanjui/QueryYourDocs/resolve/main/examples/tests/hf_login.py
- Command line
-
hf download hf://spaces/LVKinyanjui/QueryYourDocs/examples/tests/hf_login.py
-
curl -L -o hf_login.py https://huggingface.co/spaces/LVKinyanjui/QueryYourDocs/resolve/main/examples/tests/hf_login.py
476 Bytes
| from huggingface_hub import login | |
| # login() | |
| import transformers, torch | |
| import os | |
| # from huggingface_hub import HfApi | |
| # Get the token from the environment variable | |
| token = os.getenv("HF_TOKEN_READ") | |
| print(token) | |
| # Use the token to authenticate | |
| api = login(token=token) | |
| model_id = "meta-llama/Meta-Llama-3.1-8B-Instruct" | |
| pipeline = transformers.pipeline( | |
| "text-generation", | |
| model=model_id, | |
| model_kwargs={"torch_dtype": torch.bfloat16}, | |
| device_map="auto", | |
| ) |