Hugging Face integrates Codex for end-to-end ML experiments

Hugging Face has integrated OpenAI Codex with the HF-skills repository, enabling the AI coding agent to manage the entire machine learning lifecycle from data validation to model deployment. This integration allows engineers to delegate complex experiments—including fine-tuning and RL alignment—to an agent that can autonomously select hardware, monitor training metrics, and maintain detailed experiment reports.

Automated End-to-End ML Workflows

Codex can now execute complete machine learning experiments via simple natural language prompts. By utilizing AGENTS.md files within the HF-skills repository, Codex can perform the following tasks:

  • Fine-tuning and Alignment: Execute supervised fine-tuning (SFT), direct preference optimization (DPO), and reinforcement learning (RL) with verifiable rewards.
  • Infrastructure Management: Automatically select appropriate hardware (e.g., t4-small for models under 1B parameters) and submit jobs to Hugging Face Jobs.
  • Data Validation: Inspect datasets on CPU to ensure compatibility with training methods (e.g., verifying the presence of 'messages' columns for SFT or 'chosen'/'rejected' columns for DPO).
  • Monitoring and Reporting: Review live training metrics via Trackio and maintain a structured training_reports/<model>-<dataset>-<method>.md file that tracks parameters, run status, and evaluation scores.
  • Deployment: Export models to GGUF format with quantization (e.g., Q4_K_M) for local deployment and publish final models to the Hugging Face Hub.

Technical Implementation and Setup

The integration relies on the Model Context Protocol (MCP) and specialized skill files to bridge the gap between the coding agent and the Hugging Face ecosystem.

Configuration

To enable these capabilities, users must install Codex and clone the HF-skills repository. Codex automatically detects the AGENTS.md file to load the necessary machine learning skills. For deeper Hub integration, users can configure the Hugging Face MCP server in their ~/.codex/config.toml file:

[mcp_servers.huggingface]
command = "npx"
args = ["-y", "mcp-remote", "https://huggingface.co/mcp?login"]

Hardware and Cost Scaling

Codex selects hardware based on the parameter count of the model being trained:

Model Size Recommended Hardware Estimated Cost Use Case
< 1B parameters t4-small $1 - $2 Educational/Experimental
1B - 3B parameters t4-medium or a10g-small $5 - $15 Small-scale training
3B - 7B parameters a10g-large or a100-large (with LoRA) $15 - $40 Production-grade training

Currently, the system does not support models larger than 7B parameters.

Experiment Lifecycle Example

When tasked with improving code-solving abilities using the open-r1/codeforces-cots dataset and the openai_humaneval benchmark, Codex follows a structured pipeline:

  1. Preparation: Validates the dataset and selects the cheapest viable GPU (e.g., t4-small for a 0.6B model).
  2. Execution: Submits the job to Hugging Face Jobs and provides the user with an estimated cost and time (e.g., ~$0.30 for 20 minutes).
  3. Tracking: Updates the training report with links to run logs and Trackio dashboards for real-time loss monitoring.
  4. Evaluation: Runs evaluation jobs to compare the fine-tuned checkpoint's pass@1 score against the base model.
  5. Finalization: Merges LoRA adapters if applicable and converts the model to GGUF for local use via llama-server.

Sources