HuggingFace AutoTrain API — no-code/low-code model training.
AutoTrain allows training and fine-tuning ML models without writing training code. Supports text classification, NER, Q&A, LLM fine-tuning, image classification, and more.
See: https://huggingface.co/docs/autotrain
Supported Task Types
NLP
"text-classification"— sentiment, intent, topic classification"token-classification"— NER, POS tagging"question-answering"— extractive QA"summarization"— abstractive summarization"translation"— machine translation"seq2seq"— encoder-decoder tasks
LLM
"llm-sft"— supervised fine-tuning"llm-orpo"— ORPO alignment"llm-dpo"— DPO alignment"llm-reward"— reward modeling
Vision
"image-classification"— multi-class image classification"image-regression"— regression on images"object-detection"— bounding box detection
Tabular
"tabular-classification"— structured data classification"tabular-regression"— structured data regression
Example
# Create a text classification training job
{:ok, project} = HuggingfaceClient.autotrain_create(
project_name: "my-sentiment-model",
task: "text-classification",
base_model: "bert-base-uncased",
dataset: "my-org/sentiment-dataset",
column_mapping: %{"text" => "text", "label" => "label"},
access_token: "hf_..."
)
# Check status
{:ok, status} = HuggingfaceClient.autotrain_status(project["id"], access_token: "hf_...")
IO.puts("Status: #{status["status"]}")
Summary
Functions
Cancels a running AutoTrain project.
Creates a new AutoTrain training project.
Deletes an AutoTrain project.
Gets training logs for a project.
Gets training metrics (loss, accuracy, etc.) for a project.
Lists all AutoTrain projects for the authenticated user or namespace.
Returns available hardware options for AutoTrain.
Returns available task types and their descriptions.
Gets the status of an AutoTrain project.
Functions
@spec cancel( String.t(), keyword() ) :: :ok | {:error, Exception.t()}
Cancels a running AutoTrain project.
Example
:ok = HuggingfaceClient.autotrain_cancel("my-project-id", access_token: "hf_...")
@spec create(keyword()) :: {:ok, map()} | {:error, Exception.t()}
Creates a new AutoTrain training project.
Options
:project_name— name for the project/output model (required):task— task type string (required). See module docs for full list.:base_model— HF model ID to fine-tune from (required for LLM tasks):dataset— HF dataset ID or dataset config:column_mapping— map of task columns to dataset columns:hub_model— output model destination (defaults touser/project_name):hardware— compute flavor (e.g."a10g-small"):params— task-specific hyperparameters map:namespace— org/user namespace for billing:access_token
Hyperparameter Examples
# LLM fine-tuning params
params: %{
"epochs" => 3,
"batch_size" => 2,
"learning_rate" => 2.0e-4,
"max_seq_length" => 2048,
"lora_r" => 16,
"lora_alpha" => 32,
"use_peft" => true
}
# Text classification params
params: %{
"epochs" => 5,
"batch_size" => 16,
"learning_rate" => 3.0e-5,
"max_seq_length" => 512
}
@spec delete( String.t(), keyword() ) :: :ok | {:error, Exception.t()}
Deletes an AutoTrain project.
Example
:ok = HuggingfaceClient.autotrain_delete("my-project-id", access_token: "hf_...")
@spec get_logs( String.t(), keyword() ) :: {:ok, String.t()} | {:error, Exception.t()}
Gets training logs for a project.
@spec get_metrics( String.t(), keyword() ) :: {:ok, map()} | {:error, Exception.t()}
Gets training metrics (loss, accuracy, etc.) for a project.
@spec list(keyword()) :: {:ok, [map()]} | {:error, Exception.t()}
Lists all AutoTrain projects for the authenticated user or namespace.
Example
{:ok, projects} = HuggingfaceClient.autotrain_list(access_token: "hf_...")
Enum.each(projects, fn p ->
IO.puts("#{p["name"]}: #{p["status"]}")
end)
@spec list_hardware(keyword()) :: {:ok, [map()]} | {:error, Exception.t()}
Returns available hardware options for AutoTrain.
@spec list_tasks(keyword()) :: {:ok, [map()]} | {:error, Exception.t()}
Returns available task types and their descriptions.
Example
{:ok, tasks} = HuggingfaceClient.autotrain_list_tasks()
Enum.each(tasks, fn t -> IO.puts("#{t["name"]}: #{t["description"]}") end)
@spec status( String.t(), keyword() ) :: {:ok, map()} | {:error, Exception.t()}
Gets the status of an AutoTrain project.
Example
{:ok, project} = HuggingfaceClient.autotrain_status("my-project-id",
access_token: "hf_..."
)
IO.puts("Status: #{project["status"]}")
IO.puts("Model: #{project["output_model"]}")