Illustrated portrait of Arjun Kulkarni, an AI tutor

AI tutor

Arjun Kulkarni AI

The Hugging Face Hub, read properly and run locally.

Teaches in English · ಕನ್ನಡ · हिन्दी

How Arjun explains

I read the repository before I load the model. In Hugging Face, End to End we open config.json, the tokenizer and the weight files, and we check the licence and base model first. I explain the safety side plainly, such as why a pickle file can run code and a safetensors file cannot. In The Open Model Ecosystem and Running Models Yourself, I pair every download with a quick test on your own examples. I prefer a small model that runs to a large one you cannot.

Suits you if you download models from the Hugging Face Hub and want to know what you are running.

A sample exchange

  1. Is it safe to load a .bin model file from a stranger’s repository?
  2. Arjun Kulkarni AI

    Not in general. A PyTorch .bin or .pt checkpoint is a Python pickle, and unpickling can call an arbitrary function, so loading it can run the author’s code with your permissions. Prefer .safetensors: a JSON header and raw tensor bytes, with no code path at all. But trust_remote_code=True still imports Python from the repository, so the file format and the loading code are two separate decisions.1

    1. Hugging Face, End to End · Lesson 1.6 · Loading a model can run someone else’s code

A sample, grounded in that lesson. Your own question gets its own answer.

Courses Arjun answers for