{"course":{"slug":"hugging-face","title":"Hugging Face, End to End","url":"https://addaly.com/learn/hugging-face","level":"intermediate","track":"create"},"lesson":{"slug":"pinning-and-keeping-up","title":"Still working next year","url":"https://addaly.com/learn/hugging-face/pinning-and-keeping-up","position":75,"of":75,"minutes":9,"answer":"Four things move independently under a working system (the model's main branch, the libraries, the platform defaults and your own corpus) so pin every from_pretrained to a revision, pin dependency versions.","keyIdea":"Four things move independently under a working system (the model's `main` branch, the libraries, the platform defaults and your own corpus) so pin every `from_pretrained` to a revision, pin dependency versions, read deprecation warnings as dated outage notices, and mirror any model you genuinely cannot lose."},"body":{"format":"markdown","text":"## Four things move under you\n\nA system built on the Hub has four independent moving parts, and each has broken somebody's production:\n\n1. **The model.** `main` gets a new commit. Weights change, a tokenizer is fixed, a template is corrected.\n2. **The libraries.** transformers, torch, gradio and datasets all ship breaking changes between major versions.\n3. **The platform.** Space SDK defaults, hardware tiers, provider availability.\n4. **Your own data.** The corpus your vectors were built from drifts away from the vectors.\n\nPinning the first two is nearly free. The other two need a habit.\n\n## Pin the model\n\n```python\nREV = \"06f233fe06e710322aca913c1bc4249a0d71fce1\"\n\nmodel = AutoModelForCausalLM.from_pretrained(MODEL, revision=REV)\ntok = AutoTokenizer.from_pretrained(MODEL, revision=REV)\n```\n\n> Figure: A system that worked in March and failed in October. Timeline: March, Everything works. Nothing is pinned: not the model, not the libraries, not the Space SDK version.; May, The model's main branch gets a corrected tokenizer. Retrieval quality drops slightly and nobody connects the two.; July, A transformers release renames an argument and warns about it. The warning is filtered out of the logs to keep them tidy.; September, The Space rebuilds against a newer default SDK version, and a renamed Gradio argument raises a TypeError at start-up.; October, The Space is red, the last commit to it was in March, and there is no record of what any of it used to be.. Four things move independently and none of them is your code. Pinning the model revision and the library versions is nearly free; the five-line record of what you pinned is what turns the next failure into debugging rather than archaeology.\n\nCopy the hash from the History tab. Pin **every** `from_pretrained` in the codebase, including the tokenizer and the processor: a tokenizer that updates independently of the weights is exactly the mismatch module two warned about.\n\nWrite the revision into your model card, your evaluation results and your logs. \"Trained on Llama-3.1-8B-Instruct\" without a hash is not reproducible, because that name has meant several different sets of bytes.\n\n## Pin the libraries\n\n```\ntransformers==4.46.2\ntorch==2.5.1\ndatasets==3.1.0\ngradio==5.9.1\naccelerate==1.1.1\n```\n\nAnd pin `sdk_version` in a Space's front matter, and the Python version where it matters. Unpinned dependencies are the second-largest cause of a thing that worked in March failing in October with no commit in between.\n\nUpgrade deliberately: read the release notes, upgrade one thing, run your thirty examples, commit. Upgrading five things at once and finding a regression means bisecting five variables.\n\n## The migration that will come\n\nTransformers deprecates with warnings before it removes. `torch_dtype` became `dtype`; `evaluation_strategy` became `eval_strategy`; `huggingface-cli` became `hf`. Each was warned about for a release or more before the old form stopped working.\n\nSo: **read your warnings.** A deprecation warning is a dated notice that your code will break. Filtering them away, which many projects do to clean up logs, converts a warning into an outage later.\n\n## When the model you depend on disappears\n\nRepositories get deleted, made private, or gated retrospectively. If your system cannot function without a specific model:\n\n- **Mirror it** into your own private repository. This is permitted for models whose licence allows redistribution, and it is the reason licence checking matters operationally as well as legally.\n- **Cache the weights** somewhere you control, not only in an ephemeral container.\n- **Record the revision**, so you can identify exactly what you had.\n\nFor anything that matters, a model you did not mirror is a dependency on somebody else's continued goodwill.\n\n## Keeping up without drowning\n\nThe field moves fast enough that trying to follow all of it is a full-time job that produces no work. A sustainable version:\n\n- **Check the trending tab monthly**, not daily. Anything that matters is still there a month later.\n- **Follow the organisations** whose models you actually use, so you see their releases.\n- **Read release notes** for the libraries you pin, on upgrade.\n- **Re-run your thirty examples** against one new candidate model a quarter. This is the only method that tells you whether a new release matters *to you*, and it takes an afternoon.\n\nWhat does not change: the Hub is git; a tokenizer must match its model; memory is parameters times bytes; padding side matters for generation; similarity is not relevance; fine-tuning teaches behaviour and retrieval supplies knowledge; a number without a baseline means nothing. Every specific tool in this course will be superseded and none of those will.\n\n## Re-embedding, the data-side drift\n\nA vector index built in January against documents that changed in June is wrong. Store the source document's hash alongside each vector, and re-embed the chunks whose hash changed. That is a scheduled job, not a rebuild, and it is the difference between a search that decays and one that does not.\n\n## The record that makes all of this possible\n\nOne file in your repository, updated when anything changes:\n\n```\nmodel      Qwen/Qwen2.5-7B-Instruct @ 06f233f\nadapter    your-name/support-lora @ a91c4d2\nembeddings BAAI/bge-small-en-v1.5 @ e8f0c1b, 384 dims, normalised\nlibs       transformers 4.46.2, torch 2.5.1, peft 0.13.2\neval       eval/thirty.jsonl, last run 2026-09-14, 27/30\n```\n\nFive lines. It takes two minutes to write and it is the difference between debugging and archaeology.\n\n## Do this now\n\nGo through your current project and pin every `from_pretrained` to a revision. Then write the five-line record above. You have just made everything you built this course reproducible, which is the thing that makes it worth having built."},"check":{"question":"A team pins their model weights to a commit hash but loads the tokenizer with no revision. What can go wrong?","options":[{"text":"Nothing, since a tokenizer cannot change in ways that affect a pinned model's behaviour.","correct":false,"tempting":"Assumes tokenizer updates are cosmetic when they can change ids, special tokens and the chat template."},{"text":"The tokenizer download will fail, because the Hub requires matching revisions across components of one repository.","correct":false,"tempting":"Invents a consistency requirement; components load independently."},{"text":"Loading will raise a vocabulary-size mismatch, which makes the problem obvious rather than silent.","correct":false,"tempting":"Only a size change raises; a corrected chat template or altered special tokens passes silently."},{"text":"A later commit can change the chat template or special tokens, so prompts differ while the weights stay fixed.","correct":true}]},"prev":{"slug":"contributing-back","title":"Pull requests, discussions and being useful","url":"https://addaly.com/learn/hugging-face/contributing-back"},"next":null,"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Exam keys checked blind by a second model: 3,665 of 3,666 agreed. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'Still working next year', in Hugging Face, End to End. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/hugging-face/pinning-and-keeping-up (Accessed: 13 October 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"Still working next year","courseTitle":"Hugging Face, End to End","module":{"index":8,"slug":"depending-on-it-and-publishing","title":"Depending on it, and publishing so others can"},"answer":null,"keyIdea":"Four things move independently under a working system (the model’s `main` branch, the libraries, the platform defaults and your own corpus) so pin every `from_pretrained` to a revision, pin dependency versions, read deprecation warnings as dated outage notices, and mirror any model you genuinely cannot lose.","hero":{"kind":"figure","figure":{"t":"figure","label":"Figure","figure":{"type":"timeline","title":"A system that worked in March and failed in October","events":[{"when":"March","what":"Everything works. Nothing is pinned: not the model, not the libraries, not the Space SDK version."},{"when":"May","what":"The model’s main branch gets a corrected tokenizer. Retrieval quality drops slightly and nobody connects the two."},{"when":"July","what":"A transformers release renames an argument and warns about it. The warning is filtered out of the logs to keep them tidy."},{"when":"September","what":"The Space rebuilds against a newer default SDK version, and a renamed Gradio argument raises a TypeError at start-up."},{"when":"October","what":"The Space is red, the last commit to it was in March, and there is no record of what any of it used to be."}],"caption":"Four things move independently and none of them is your code. Pinning the model revision and the library versions is nearly free; the five-line record of what you pinned is what turns the next failure into debugging rather than archaeology."},"alt":"Figure: A system that worked in March and failed in October. Timeline: March, Everything works. Nothing is pinned: not the model, not the libraries, not the Space SDK version.; May, The model’s main branch gets a corrected tokenizer. Retrieval quality drops slightly and nobody connects the two.; July, A transformers release renames an argument and warns about it. The warning is filtered out of the logs to keep them tidy.; September, The Space rebuilds against a newer default SDK version, and a renamed Gradio argument raises a TypeError at start-up.; October, The Space is red, the last commit to it was in March, and there is no record of what any of it used to be.. Four things move independently and none of them is your code. Pinning the model revision and the library versions is nearly free; the five-line record of what you pinned is what turns the next failure into debugging rather than archaeology."}},"blocks":[{"t":"h2","id":"four-things-move-under-you","runs":[{"text":"Four things move under you"}]},{"t":"p","runs":[{"text":"A system built on the Hub has four independent moving parts, and each has broken somebody’s production:"}]},{"t":"ol","start":1,"items":[[{"text":"The model.","b":true},{"text":" "},{"text":"main","code":true},{"text":" gets a new commit. Weights change, a tokenizer is fixed, a template is corrected."}],[{"text":"The libraries.","b":true},{"text":" transformers, torch, gradio and datasets all ship breaking changes between major versions."}],[{"text":"The platform.","b":true},{"text":" Space SDK defaults, hardware tiers, provider availability."}],[{"text":"Your own data.","b":true},{"text":" The corpus your vectors were built from drifts away from the vectors."}]]},{"t":"p","runs":[{"text":"Pinning the first two is nearly free. The other two need a habit."}]},{"t":"h2","id":"pin-the-model","runs":[{"text":"Pin the model"}]},{"t":"code","lang":"python","label":"Python","text":"REV = \"06f233fe06e710322aca913c1bc4249a0d71fce1\"\n\nmodel = AutoModelForCausalLM.from_pretrained(MODEL, revision=REV)\ntok = AutoTokenizer.from_pretrained(MODEL, revision=REV)"},{"t":"p","runs":[{"text":"Copy the hash from the History tab. Pin "},{"text":"every","b":true},{"text":" "},{"text":"from_pretrained","code":true},{"text":" in the codebase, including the tokenizer and the processor: a tokenizer that updates independently of the weights is exactly the mismatch module two warned about."}]},{"t":"p","runs":[{"text":"Write the revision into your model card, your evaluation results and your logs. “Trained on Llama-3.1-8B-Instruct” without a hash is not reproducible, because that name has meant several different sets of bytes."}]},{"t":"h2","id":"pin-the-libraries","runs":[{"text":"Pin the libraries"}]},{"t":"code","lang":"","label":"Text","text":"transformers==4.46.2\ntorch==2.5.1\ndatasets==3.1.0\ngradio==5.9.1\naccelerate==1.1.1"},{"t":"p","runs":[{"text":"And pin "},{"text":"sdk_version","code":true},{"text":" in a Space’s front matter, and the Python version where it matters. Unpinned dependencies are the second-largest cause of a thing that worked in March failing in October with no commit in between."}]},{"t":"p","runs":[{"text":"Upgrade deliberately: read the release notes, upgrade one thing, run your thirty examples, commit. Upgrading five things at once and finding a regression means bisecting five variables."}]},{"t":"h2","id":"the-migration-that-will-come","runs":[{"text":"The migration that will come"}]},{"t":"p","runs":[{"text":"Transformers deprecates with warnings before it removes. "},{"text":"torch_dtype","code":true},{"text":" became "},{"text":"dtype","code":true},{"text":"; "},{"text":"evaluation_strategy","code":true},{"text":" became "},{"text":"eval_strategy","code":true},{"text":"; "},{"text":"huggingface-cli","code":true},{"text":" became "},{"text":"hf","code":true},{"text":". Each was warned about for a release or more before the old form stopped working."}]},{"t":"p","runs":[{"text":"So: "},{"text":"read your warnings.","b":true},{"text":" A deprecation warning is a dated notice that your code will break. Filtering them away, which many projects do to clean up logs, converts a warning into an outage later."}]},{"t":"h2","id":"when-the-model-you-depend-on-disappears","runs":[{"text":"When the model you depend on disappears"}]},{"t":"p","runs":[{"text":"Repositories get deleted, made private, or gated retrospectively. If your system cannot function without a specific model:"}]},{"t":"ul","items":[[{"text":"Mirror it","b":true},{"text":" into your own private repository. This is permitted for models whose licence allows redistribution, and it is the reason licence checking matters operationally as well as legally."}],[{"text":"Cache the weights","b":true},{"text":" somewhere you control, not only in an ephemeral container."}],[{"text":"Record the revision","b":true},{"text":", so you can identify exactly what you had."}]]},{"t":"p","runs":[{"text":"For anything that matters, a model you did not mirror is a dependency on somebody else’s continued goodwill."}]},{"t":"h2","id":"keeping-up-without-drowning","runs":[{"text":"Keeping up without drowning"}]},{"t":"p","runs":[{"text":"The field moves fast enough that trying to follow all of it is a full-time job that produces no work. A sustainable version:"}]},{"t":"ul","items":[[{"text":"Check the trending tab monthly","b":true},{"text":", not daily. Anything that matters is still there a month later."}],[{"text":"Follow the organisations","b":true},{"text":" whose models you actually use, so you see their releases."}],[{"text":"Read release notes","b":true},{"text":" for the libraries you pin, on upgrade."}],[{"text":"Re-run your thirty examples","b":true},{"text":" against one new candidate model a quarter. This is the only method that tells you whether a new release matters "},{"text":"to you","i":true},{"text":", and it takes an afternoon."}]]},{"t":"p","runs":[{"text":"What does not change: the Hub is git; a tokenizer must match its model; memory is parameters times bytes; padding side matters for generation; similarity is not relevance; fine-tuning teaches behaviour and retrieval supplies knowledge; a number without a baseline means nothing. Every specific tool in this course will be superseded and none of those will."}]},{"t":"h2","id":"re-embedding-the-data-side-drift","runs":[{"text":"Re-embedding, the data-side drift"}]},{"t":"p","runs":[{"text":"A vector index built in January against documents that changed in June is wrong. Store the source document’s hash alongside each vector, and re-embed the chunks whose hash changed. That is a scheduled job, not a rebuild, and it is the difference between a search that decays and one that does not."}]},{"t":"h2","id":"the-record-that-makes-all-of-this-possible","runs":[{"text":"The record that makes all of this possible"}]},{"t":"p","runs":[{"text":"One file in your repository, updated when anything changes:"}]},{"t":"code","lang":"","label":"Text","text":"model      Qwen/Qwen2.5-7B-Instruct @ 06f233f\nadapter    your-name/support-lora @ a91c4d2\nembeddings BAAI/bge-small-en-v1.5 @ e8f0c1b, 384 dims, normalised\nlibs       transformers 4.46.2, torch 2.5.1, peft 0.13.2\neval       eval/thirty.jsonl, last run 2026-09-14, 27/30"},{"t":"p","runs":[{"text":"Five lines. It takes two minutes to write and it is the difference between debugging and archaeology."}]},{"t":"h2","id":"do-this-now","runs":[{"text":"Do this now"}],"role":"try"},{"t":"p","runs":[{"text":"Go through your current project and pin every "},{"text":"from_pretrained","code":true},{"text":" to a revision. Then write the five-line record above. You have just made everything you built this course reproducible, which is the thing that makes it worth having built."}]}],"check":{"question":[{"text":"A team pins their model weights to a commit hash but loads the tokenizer with no revision. What can go wrong?"}],"options":[{"text":[{"text":"Nothing, since a tokenizer cannot change in ways that affect a pinned model’s behaviour."}],"correct":false,"tempting":[{"text":"Assumes tokenizer updates are cosmetic when they can change ids, special tokens and the chat template."}]},{"text":[{"text":"The tokenizer download will fail, because the Hub requires matching revisions across components of one repository."}],"correct":false,"tempting":[{"text":"Invents a consistency requirement; components load independently."}]},{"text":[{"text":"Loading will raise a vocabulary-size mismatch, which makes the problem obvious rather than silent."}],"correct":false,"tempting":[{"text":"Only a size change raises; a corrected chat template or altered special tokens passes silently."}]},{"text":[{"text":"A later commit can change the chat template or special tokens, so prompts differ while the weights stay fixed."}],"correct":true,"tempting":null}],"order":[1,0,3,2],"why":null},"prev":{"slug":"contributing-back","title":"Pull requests, discussions and being useful","minutes":8},"next":null}}