0
0
Prompt Engineering / GenAIml~12 mins

Tool usage (function calling) in Prompt Engineering / GenAI - Model Pipeline Trace

Choose your learning style9 modes available
Model Pipeline - Tool usage (function calling)

This pipeline shows how a machine learning model uses a tool (function) during prediction to improve its output. The model calls a function to get extra information, then combines it with its own prediction.

Data Flow - 5 Stages
1Input data
1 sample x 3 featuresReceive raw input features1 sample x 3 features
[5.1, 3.5, 1.4]
2Preprocessing
1 sample x 3 featuresNormalize features to range 0-11 sample x 3 features
[0.51, 0.7, 0.14]
3Model prediction
1 sample x 3 featuresFeed features into neural network1 sample x 2 outputs
[0.6, 0.4]
4Function call (tool usage)
1 sample x 3 featuresCall external function to get extra info1 sample x 1 feature
[0.8]
5Combine outputs
1 sample x 2 outputs + 1 featureCombine model output and function output1 sample x 2 outputs
[0.68, 0.32]
Training Trace - Epoch by Epoch

Loss
0.7 |****
0.6 |*** 
0.5 |**  
0.4 |*   
0.3 |    
     1 2 3 4 5 Epochs
EpochLoss ↓Accuracy ↑Observation
10.650.60Model starts learning, loss high, accuracy low
20.500.72Loss decreases, accuracy improves
30.400.80Model learns important patterns
40.320.85Loss continues to drop, accuracy rises
50.280.88Model converges with good accuracy
Prediction Trace - 5 Layers
Layer 1: Input features
Layer 2: Normalization
Layer 3: Neural network prediction
Layer 4: Function call (tool usage)
Layer 5: Combine outputs
Model Quiz - 3 Questions
Test your understanding
What does the function call (tool usage) provide in the pipeline?
ARaw input data
BExtra information to improve prediction
CFinal prediction output
DTraining loss value
Key Insight
Using a tool (function call) during prediction can provide extra useful information that improves the model's final output beyond what the model alone predicts.