Summary of "HEC Generative AI Training Program | C2 | Week 3 | Main Session 1"

HEC Generative AI Training Program — C2 | Week 3 | Main Session 1

Session purpose

What is generative AI

Generative AI refers to systems that produce new content (text, images, audio, video, 3D, code, etc.) from prompts. Examples include:

Platforms & tools covered

Key concepts explained

Deployment workflow (high-level)

Practical examples demonstrated

Common issues & recommended fixes

Best practices and architecture suggestions

Use cases & monetization ideas

Detailed methodology / step-by-step (as taught)

  1. Prototype in Google Colab

    • Create a new notebook; optionally set runtime → Change runtime type → GPU (T4).
    • Install libraries (pip install gradio, pip install requests, etc.).
    • Use commented code cells and Markdown cells for notes/headings.
  2. Obtain API key from model provider (example: Grok/Grok Cloud)

    • Provider dashboard → Manage Projects / API Keys → Create New Key.
    • Give a descriptive display name (e.g., “translator-english-urdu”).
    • Copy the key immediately (dashboards often don’t show it again).
  3. Secure the API key in the development environment

    • In Colab: use environment variables or Colab secrets (do not commit plain keys).
    • In Hugging Face Spaces: Space → Settings → Variables & Secrets → Add new secret (e.g., GROK_API_KEY or HF_TOKEN).
  4. Implement translation/generation logic in code

    • app.py should:
      • Read the secret (os.environ[“GROK_API_KEY”] or HF secret name).
      • Call the provider’s API (construct request, pass prompt, receive output).
      • Include prompt engineering for the task (e.g., translate English → Urdu).
      • Keep code modular: separate API logic, prompt templates, and UI code.
  5. Test the model call in Colab

    • Run and confirm outputs.
    • If model-not-found occurs, check provider docs and avoid hardcoding outdated names.
  6. Prepare deployment on Hugging Face Spaces

    • Create a new Space (name, choose Gradio/Streamlit, license, public/private).
    • Add requirements.txt and app.py (README.md optional).
    • List required libraries in requirements.txt; consider omitting exact version pins or choose versions carefully.
  7. Add API secrets to the Space

    • Space → Settings → Variables & Secrets → Add secret with the same name used in app.py.
  8. Build & deploy

    • Push or upload files to the Space (web upload or git).
    • Trigger the build and monitor logs for dependency/runtime errors.
    • Fix secret name mismatches or missing dependencies, then rebuild.
  9. Post-deploy testing & fallback strategy

    • Test the UI with sample prompts and examples.
    • Implement fallback models or try/catch logic for removed primary models; store preferred model list in env vars or config.
  10. Operational recommendations - Monitor usage/quota on Hugging Face and provider dashboards. - Never embed secret keys in source; use Secrets. - For production/commercial use, consider Docker for reproducible deployments and dependency control.

Practical troubleshooting notes

Questions/topics raised by participants (high level)

Speakers and sources featured

Category ?

Educational


Share this summary


Is the summary off?

If you think the summary is inaccurate, you can reprocess it with the latest model.

Video