Cheat sheet · Specialise
Hugging Face cheat sheet
Opens with creditsA quick-revision book on the Hugging Face ecosystem for engineers who use open models from Python. It moves from finding a model on the Hub to running it, preparing data, fine-tuning it cheaply, evaluating it, serving it and sharing the result.
Chapters
8 chapters · 51 concepts
1The HubThe shared home for models, datasets and demo apps, and the account and tooling you need to use it from code.7 concepts
- 1Hub repositoriesEvery model, dataset and Space on the Hub is a Git-based repository with an id of the form
owner/name, such asQwen/Qwen3-8B. - 2The hf CLI and loginThe
hfcommand line tool (the successor tohuggingface-cli) logs in, downloads and uploads files. - 3Model cardsThe README of a model repo: what the model is for, how it was trained, its evaluation results, limitations and intended use, plus YAML metadata such as licence…
- 4Licences and gated modelsEach repo declares a licence, such as Apache 2.0, MIT or a custom model licence with usage conditions.
- 5SpacesSpaces host small apps, usually built with Gradio or as a Docker container, directly from a Hub repo, on free CPU or paid GPU hardware.
- 6The local cacheDownloads are stored once in a shared cache (by default under
~/.cache/huggingface) and reused by every library. - 7huggingface_hub in PythonThe
huggingface_hublibrary downloads single files or whole repos, creates repos, uploads folders and searches the Hub from Python.
7 in this chapterOpen this chapter- 1Hub repositoriesEvery model, dataset and Space on the Hub is a Git-based repository with an id of the form
2Running models with transformersThe transformers library: from a one-line pipeline to loading the tokeniser and model yourself and generating text.7 concepts
- 1pipeline
pipeline(task, model=...)bundles preprocessing, the model and postprocessing for a task such as text generation, classification, summarisation or speech… - 2Auto classesAuto classes read a repo's config and build the right architecture.
- 3dtype and device_map
dtype="auto"loads weights in the precision they were saved in, oftenbfloat16, instead offloat32. - 4generate
model.generateproduces tokens one at a time. - 5Chat templatesEach chat model expects messages formatted with its own special tokens.
- 6Model outputs and headsCalling a model returns an output object:
logitsfor models with a task head,last_hidden_statefor a bareAutoModel, andlosswhen you passlabels. - 7safetensorsThe default weight format on the Hub: a simple file of tensors with a JSON header, which loads fast and cannot run code.
7 in this chapterOpen this chapter- 1pipeline
- TokenisersHow text becomes the integer ids a model reads, and the settings that matter when you batch it.6 conceptsOpens with credits
- DatasetsThe datasets library loads data from the Hub or local files into fast, memory-mapped tables and transforms it in batches.7 conceptsOpens with credits
- Fine-tuning with TrainerTraining a pretrained model further on your own labelled data with the high-level Trainer API.6 conceptsOpens with credits
- LoRA, quantisation and accelerateFitting fine-tuning and inference of large models onto modest hardware, and scaling the same code up.6 conceptsOpens with credits
- Evaluation and embeddingsMeasuring whether a model is good enough, and turning text into vectors for search and similarity.6 conceptsOpens with credits
- Inference and sharingRunning models without managing GPUs, serving them yourself, and publishing what you trained.6 conceptsOpens with credits
- 9Glossary, A to ZEvery concept in the sheet and the smaller terms it uses, in one list.75 terms
About this sheet
The Hub, transformers, tokenisers, datasets, fine-tuning, LoRA, quantisation, inference and embeddings with the Hugging Face libraries.
Related on Sefism
Picked from the other libraries by shared topics.
Roadmaps
See allBest practices
See all- Best Practices for Building LLM AppsHow to build LLM apps and agents that hold up in production: prompts, evals, prompt injection, tool permissions, cost, logging and privacy.
- Prompt Engineering Best PracticesHow to write prompts that work the same way on the hundredth input as on the first: clear instructions, structure, examples, reasoning, output control and testing.
- Best Practices for AI Coding AssistantsHow to get reliable code from AI coding assistants and agents: instruction files, task prompts, verification, review, security, dependencies and session hygiene.
Checklists
See all- RAG Production ChecklistA RAG production checklist: chunking, embeddings, hybrid search, reranking, per-user permissions, citations, evals, re-indexing and cost, with how to verify each check.
- LLM Evaluation ChecklistAn LLM evaluation checklist: success criteria, eval datasets, code and model graders, judge calibration, agent evals, safety tests and production monitoring, with how to verify each check.
- AI Feature Launch ChecklistAn AI feature launch checklist: use case fit, evals, UX for errors, disclosure, human override, abuse filters, rate limits, cost caps, prompt privacy, monitoring and rollback.
Project structures
See all- GenAI RAG app (FastAPI) project structureFor developers turning a "chat with your documents" demo into an app people can rely on. A FastAPI backend where every layer has a home: ingestion workers, retrieval, prompts as versioned files, model clients with fallbacks and cost caps, guards, evals that gate CI, and tracing, so a wrong answer can be traced to the step that caused it.
- Machine learning project project structureFor students and analysts whose model works in a notebook and now needs to be reproducible, reviewable, served and watched. It starts from the Cookiecutter Data Science v2 layout (immutable raw data, numbered notebooks, a real Python package) and grows into versioned data with DVC, typed parameters, data validation with pandera, experiment tracking and a model registry with MLflow, a FastAPI prediction service, drift monitoring and, for a team, scheduled retraining, model cards, fairness checks and shadow deployment.
- AI agent with an MCP server project structureFor developers who want to give AI assistants safe access to their own data or API. A TypeScript MCP server built on the official SDK, organised by feature (tasks, projects) with each feature owning its tools, resources and prompts, served over stdio for local hosts and Streamable HTTP with OAuth for remote ones, plus a small agent and the evals that prove a model can use it.
Career questions
See all- I am good with computers but not good at math. Can I still have a successful career in software engineering or AI?Yes for most of software engineering, which needs logical thinking far more than advanced math. For AI it depends on the role: building products on top of models needs little math, while research and model training need a lot. Most people who say they are bad at math were taught badly, and the math you need can be learned.
- Which AI tools do employers expect junior developers to know in 2026?Employers rarely require a specific brand. They expect you to use an AI coding assistant well (in the editor and in the terminal), to review and test what it produces, to call an LLM API in a small feature, and to explain when you would not use AI. Pick one assistant, learn it properly, and show judgement in your projects.
- How do I use AI to become a better engineer instead of becoming dependent on it?Decide the job AI does before you open it. Use it as a tutor, reviewer and sparring partner that explains and challenges, not a vending machine that hands you finished code. Attempt first, ask second, and always be able to explain and defend what you ship.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
- 1:1 Mentorship
- Fresh Graduate Mentorship
- Career Guidance
Brand deals, promos and partnerships: tauseeffayyaz@gmail.com