AI Intermediate · 17% practice allocation

AI Intermediate: Hugging Face & Open Source Models Practice Questions

5 free sample questions from the Hugging Face & Open Source Models domain, with answers and explanations. The full AI Intermediate bank has 963 questions across 5 domains. Questions follow the AI Intermediate course content.

1.

A developer wants to quickly test a pre-trained sentiment analysis model from Hugging Face without writing any model-loading or tokenization code. Which transformers library abstraction is BEST suited for this use case?

  • A. AutoTokenizer.from_pretrained()
  • B. Trainer()
  • C. AutoModel.from_pretrained()
  • D. pipeline()✓ Correct
Explanation

pipeline() is correct because it provides a high-level, task-oriented API that automatically handles model loading, tokenization, inference, and post-processing in a single call — ideal for quick testing without boilerplate code. AutoModel.from_pretrained() loads only the model weights and requires manual tokenization and forward-pass logic. AutoTokenizer.from_pretrained() loads only the tokenizer, not the model. Trainer() is used for fine-tuning workflows, not inference.

2.

A startup is building a commercial SaaS product and wants to use an open-source LLM. Their legal team requires that the license explicitly permits unrestricted commercial use and imposes no usage restrictions on the output. Which TWO of the following model licenses satisfy this requirement without additional conditions?

  • A. CC BY-NC 4.0
  • B. Llama Community License
  • C. RAIL (Responsible AI License)
  • D. MIT✓ Correct
  • E. Apache 2.0✓ Correct
Explanation

Apache 2.0 and MIT are correct because both are permissive open-source licenses that allow unrestricted commercial use, redistribution, and modification with minimal conditions (attribution only). The Llama Community License restricts use based on monthly active user thresholds (>700M MAU requires a separate Meta agreement) and contains acceptable-use provisions on outputs. RAIL imposes behavioral-use restrictions on what the model's outputs can be used for, making it unsuitable here. CC BY-NC 4.0 explicitly prohibits commercial use (NC = NonCommercial).

3.

A developer loads a model using AutoModelForCausalLM.from_pretrained('mistralai/Mistral-7B-v0.1', device_map='auto', load_in_4bit=True). Which library must be installed for the load_in_4bit=True argument to work?

  • A. llama-cpp-python
  • B. auto-gptq
  • C. optimum
  • D. bitsandbytes✓ Correct
Explanation

load_in_4bit=True in the from_pretrained() call is a BitsAndBytes integration feature. The bitsandbytes library provides the NF4 4-bit quantization kernels that the transformers library wraps via this parameter. optimum is a Hugging Face library for hardware-specific optimizations (ONNX, TensorRT, etc.) but does not provide 4-bit loading. auto-gptq handles GPTQ-quantized models and uses a different loading pattern. llama-cpp-python is a Python binding for llama.cpp and works with GGUF files, not the standard from_pretrained() API.

4.

A data scientist needs to deploy a fine-tuned image classification model as an interactive web demo for stakeholders, with zero infrastructure management and no local server. The demo should be publicly accessible via a shareable URL. Which Hugging Face feature is MOST appropriate?

  • A. Hugging Face Inference API with a private endpoint
  • B. Hosting the model on the Hugging Face Hub model card
  • C. Using the transformers Trainer class with push_to_hub=True
  • D. A Hugging Face Space running a Gradio app✓ Correct
Explanation

A Hugging Face Space running a Gradio app is correct. Spaces are purpose-built for hosting interactive ML demos with zero infrastructure management; they auto-provision compute, provide a public URL, and support Gradio (and Streamlit) apps natively. The Inference API provides programmatic model inference but not an interactive web UI for stakeholders. A model card hosts documentation and metadata, not an interactive app. Trainer with push_to_hub=True uploads model weights to the Hub but does not create a runnable demo.

5.

A developer runs ollama run llama3 and types a prompt directly in the terminal. They then want to create a custom variant that always responds as a pirate and limits context to 2048 tokens. Which Modelfile instructions should they use together to achieve this?

  • A. FROM and INSTRUCTION
  • B. PROMPT and CONTEXT
  • C. SYSTEM and PARAMETER✓ Correct
  • D. TEMPLATE and LIMIT
Explanation

In an Ollama Modelfile, SYSTEM sets the system prompt (e.g., 'You are a pirate'), and PARAMETER num_ctx 2048 sets the context window size. Together they achieve both goals. PROMPT and CONTEXT are not valid Modelfile instructions. TEMPLATE controls the full prompt template format (not the system persona), and LIMIT does not exist. INSTRUCTION is not a Modelfile directive; the base model is specified with FROM.

Test yourself across every AI Intermediate domain

The free AI Intermediate practice test mixes about 20 questions weighted like the exam. The full 963-question bank adds instant grading, flashcards and a timed mock exam.

Study this domain

Hugging Face & Open Source Models study guide (AI Intermediate) →

Other AI Intermediate domains

← All AI Intermediate study resources