What is function calling in LLM?
- User
What is function calling in LLM?
Assistant
Function calling in LLM (Low Level Machine) works as follows:
-
When a function is called, the arguments are pushed onto the stack in reverse order. So the last argument is pushed first.
-
The return address (the address of the instruction after the call instruction) is pushed onto the stack.
-
The program counter is set to the start of the called function.
-
The called function executes its instructions. It can access the arguments by popping them off the stack.
-
When the called function finishes, it pops the return address off the stack and jumps to that address.
-
Execution continues at the instruction after the call. The caller can access the return value (if any) which is left on top of the stack.
So in summary, function calls in LLM use the stack to pass arguments and store the return address. The program counter is used to transfer control to the called function, and a return jump is used to return to the caller.
An example LLM function call would look something like this:
# Caller function push argument1 # Push arguments onto stack push argument2 call function # Call function, push return address pop result # Pop result (return value) # Called function pop arg1 # Pop arguments off stack pop arg2 ... push result # Push return value onto stack ret # Return to callerHope this helps explain function calling in LLM! Let me know if you have any other questions.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.