HCIP-AI EI Developer cheat sheet
HCIP-AI EI Developer · Keep the key ideas within reach.
AI Development Fundamentals and Huawei AI Platform
Huawei's full-stack AI strategy has four layers: Ascend/IP and chip enablement, CANN (compute architecture for neural networks), MindSpore AI framework, and MindX/application enablement (ModelArts, HiAI).
Ascend 310 is an edge/inference SoC (about 8 TOPS INT8 at 8 W typical), while Ascend 910 is the training chip; Atlas 200/300/500/800/900 products package these chips for edge, server, and cluster scenarios.
CANN sits between frameworks and Ascend hardware; it includes operators (TBE), graph compiler, runtime, and HCCL collective communication library for multi-card training.
ModelArts workflow order: create dataset and label (or auto-label) → create training job (built-in or custom algorithm) → hyperparameter tuning → model management/import → deploy as real-time, batch, or edge service.
ExeML (ExeML/auto ML) in ModelArts performs automatic data processing, model selection, and hyperparameter search; it suits tabular and image classification tasks without custom code.
Huawei AI certifications and developer resources: Huawei Cloud EI (Enterprise Intelligence) services include Image, NLP, OCR, Video, and Content Moderation APIs, each invoked with AK/SK or token authentication.
OBS (Object Storage Service) is the default data source for ModelArts; data must reside in a region matching the ModelArts workspace, and IAM agency authorization is required to access it.
HiAI Foundation provides on-device inference APIs for Kirin chips; HiAI Engine exposes vision, speech, and NLP capabilities to apps without hosting models in the cloud.
Python and AI Development Frameworks
NumPy broadcasting rule: dimensions are compared from the right; a dimension is compatible if equal or one of them is 1; otherwise the operation raises a ValueError.
PyTorch training loop order: zero_grad() → forward → compute loss → backward() → optimizer.step(); forgetting zero_grad accumulates gradients across iterations.
TensorFlow 2.x defaults to eager execution; tf.function traces Python into a graph, and @tf.function retracing occurs when input shapes or dtypes change.
MindSpore defines networks by subclassing nn.Cell, implementing construct(), and using value_and_grad for automatic differentiation; it supports both PyNative (eager) and Graph modes.
In MindSpore, dataset loading uses mindspore.dataset (MindDataset, ImageFolderDataset, GeneratorDataset); data augmentation is applied through map() with c_transforms or py_transforms.
PyTorch tensor.device and model.to(device) must match; moving a model to GPU does not move existing input tensors, which must also be moved explicitly.
Common loss-to-task mapping: CrossEntropyLoss for multi-class single-label, BCEWithLogitsLoss for multi-label/binary, MSELoss for regression, and CTC/token-level cross-entropy for sequence labeling.
DataLoader workers>0 on Windows or in notebooks can deadlock; set num_workers=0 when debugging, and pin_memory=True speeds host-to-GPU transfer.
Machine Learning and Deep Learning Model Development
Bias-variance diagnostic: high training error and high validation error indicate underfitting (increase capacity, reduce regularization); low training error with high validation error indicates overfitting.
Regularization formulas: L2 adds λ‖w‖², L1 adds λ‖w‖₁; dropout randomly zeroes activations with probability p during training and is disabled at inference.
Batch normalization normalizes per-channel over the batch and learns scale/shift γ, β; it behaves differently in train and eval mode, so call model.eval() before validation.
Optimizers: SGD with momentum, Adam (adaptive per-parameter learning rates using first/second moments), and AdamW (decoupled weight decay); learning-rate warmup plus cosine decay is a common schedule.
CNN output size formula: floor((W − K + 2P)/S) + 1, where W is input width, K kernel, P padding, S stride.
Transformer self-attention: Attention(Q,K,V) = softmax(QKᵀ/√d_k)V; multi-head attention concatenates heads then projects, and positional encoding supplies order information.
Evaluation metrics: precision = TP/(TP+FP), recall = TP/(TP+FN), F1 = 2PR/(P+R); accuracy is misleading on imbalanced data, where AUC-ROC or PR-AUC is preferred.
K-fold cross-validation splits data into K folds, training on K−1 and validating on the held-out fold; it reduces variance of the performance estimate versus a single split.
Computer Vision Application Development
IoU = area of intersection / area of union of two boxes; detection matches use IoU thresholds (commonly 0.5), and mAP averages AP across classes and IoU levels (COCO uses 0.5:0.05:0.95).
NMS sorts boxes by score, keeps the highest, and suppresses boxes with IoU above a threshold; soft-NMS decays scores instead of removing them.
YOLO treats detection as a single regression over a grid, predicting box offsets, objectness, and class probabilities in one forward pass; anchor-free variants predict center offsets directly.
Semantic segmentation assigns a class per pixel; instance segmentation separates objects; Mask R-CNN adds a mask branch to Faster R-CNN's region proposals.
Transfer learning for vision: replace the final classification layer to match the new class count, freeze the backbone for initial epochs, then unfreeze and fine-tune with a smaller learning rate.
Data augmentation for images: random crop, horizontal flip, rotation, color jitter, and MixUp/CutMix; keep label-preserving transforms consistent between training and validation (no random flip at validation).
Huawei Cloud Image services include image tagging, image search, and celebrity/face recognition; OCR services handle general text, ID cards, and license plates via REST endpoints.
Natural Language Processing Application Development
Tokenization: BERT uses WordPiece, GPT-2 uses byte-level BPE; subword units balance vocabulary size against out-of-vocabulary coverage, and [CLS]/[SEP] mark sentence boundaries in BERT input.
BERT is encoder-only and pretrained with masked language modeling plus next-sentence prediction; GPT is decoder-only and autoregressive; T5 is encoder-decoder with span corruption.
Fine-tuning BERT for classification: pool the [CLS] token, add a linear head sized to the label count, and use a small learning rate (e.g., 2e-5 to 5e-5).
Named entity recognition is token classification; use BIO tagging (B-begin, I-inside, O-outside) and evaluate with entity-level precision/recall/F1 rather than per-token accuracy.
Text similarity can be measured with cosine similarity over TF-IDF, average word embeddings, or sentence embeddings; cosine = (A·B)/(‖A‖‖B‖).
Sequence-to-sequence decoding strategies: greedy (fast, repetitive), beam search (higher quality, slower), and sampling with temperature/top-k/top-p for diversity.
Huawei Cloud NLP services cover text classification, sentiment analysis, entity extraction, and machine translation; requests are signed with AK/SK and region-specific endpoints.
Long-document handling: truncate to the model's max length (BERT typically 512 tokens), use sliding windows with overlap, or hierarchical pooling of chunk embeddings.
AI Development Fundamentals and Huawei AI Platform
MindSpore Lite converts trained models to .ms format for on-device inference on Ascend, Kirin, and CPU targets.
ModelArts notebook instances mount OBS via MoXing (mox.file) APIs; local disk is ephemeral and not persisted.
Huawei Cloud IAM AK/SK signs API requests; a temporary token from IAM is used with AK/SK for service calls.
ModelArts training job logs and metrics are visible in the job detail page and can be exported to AOM.
Python and AI Development Frameworks
A PyTorch tensor with requires_grad=True accumulates .grad after backward(); call .detach() to stop gradient flow.
MindSpore's nn.WithLossCell and TrainOneStepCell compose the loss and optimizer into a single training step.
tf.data pipelines use .cache(), .shuffle(buffer), .batch(n), and .prefetch(tf.data.AUTOTUNE) in that order for performance.
In NumPy, arr.reshape(-1) flattens and np.expand_dims adds a new axis; both return views when possible.
Machine Learning and Deep Learning Model Development
Learning-rate too high causes loss divergence or oscillation; too low causes slow convergence or plateau.
Class imbalance remedies: class-weighted loss, oversampling of minority classes, undersampling of majority, and focal loss.
Gradient clipping caps the norm of gradients to prevent exploding gradients in RNNs and deep transformers.
Early stopping monitors validation loss and restores the best checkpoint when no improvement occurs for a patience window.
Computer Vision Application Development
Anchor boxes are predefined boxes of varying scales/aspect ratios; the network predicts offsets and objectness for each anchor.
Feature pyramid networks combine multi-scale feature maps so small objects are detected from high-resolution levels.
Confusion matrix for segmentation is computed per pixel; mIoU averages IoU over classes.
Model input normalization must match pretrained weights (e.g., ImageNet mean/std), or accuracy drops sharply.
Natural Language Processing Application Development
Word embeddings (Word2Vec, GloVe) map tokens to dense vectors where cosine distance reflects semantic similarity.
Attention weights sum to 1 across keys after softmax; masking sets padded positions to -inf before softmax.
For text classification with limited labels, freeze the pretrained encoder and train only the classification head first.
BLEU and ROUGE are n-gram overlap metrics for generation and summarization; neither fully captures semantic correctness.