Abstract: In this session, you will learn about function calling in open source large language models (LLMs).
Function calling extends the capabilities of LLMs beyond text generation, allowing them to interact with external systems, APIs, and tools. This technique involves the model selecting appropriate functions or tools from a predefined set and invoking them through structured responses, typically formatted as JSON objects, to accomplish specific tasks. Key benefits of function calling include real-time data access, math problem solving, improved decision-making, and task execution.
We will begin the session with the fundamentals of function calling, followed by a basic hands-on example, and conclude with a practical use case. We will leverage open source frameworks and libraries such as LangChain and Pydantic, and make fast LLM inferences using the open source Llama-3-8b model that runs at 1,000 tokens/s on the SambaNova AI platform powered by the SN40L AI chip. Speed is crucial in this context as it enables real-time responsiveness, significantly enhancing user interaction and experience.
By completing this workshop, you will develop an understanding of function calls with LLMs. The knowledge you gain will be helpful in building advanced AI agents, as well as enhancing your generative AI workflows.
Session Outline:
Lesson 1: Fundamentals of function calls in LLMs
Dive into the fundamentals of function calls in LLMs, exploring their importance, how to invoke functions, define JSON schemas, pass arguments, and handle return values.
Lesson 2: Basic hands-on example
Explore how to implement function calling with an open source language model, Llama-3-8b, in LangChain. Define various functions/tools for getting the current time/date or weather in a specific location, performing arithmetic calculations, and generating and executing Python scripts. Modify the system prompt to allow the LLM to select the appropriate tool based on the user’s query, generate arguments, and invoke the selected tool to answer the query.
Lesson 3: Advanced application – Stock market analysis
Build an end-to-end function-calling pipeline for a practical use case in finance. Integrate Llama-3-8b function calling with the external Yahoo Finance API in LangChain for enhanced stock market analysis, such as retrieving the latest stock prices of a given company.
Supplementary resources:
For each coding example, we will provide a link to the Github repository with step-by-step instructions on how to install the required libraries and run the Jupyter notebooks and Streamlit apps. SambaNova API keys for the Llama-3 endpoints will also be provided.
Learning Objectives and Tools:
Participants will learn about function calling in LLMs and how to build agentic workflows. We will be using the following tools and models:
● LangChain
● Pydantic
● Llama-3-8b-instruct from Meta
● Streamlit
● Jupyter Notebook
● Yahoo Finance API
Pre-requisites and Background knowledge needed:
● Experience in programming, ideally in Python
● Familiarity with LLMs is recommended but not required
● A laptop with reliable WiFi access
Bio: Petro is a Principal Engineer in the AI Solutions team at SambaNova Systems, where he is currently working on developing applications powered by large language models. His expertise spans AI for Science and Generative AI. He obtained his PhD and MS from the Georgia Institute of Technology and previously interned at Argonne National Laboratory. He has given several tutorials and workshops at conferences, e.g., Supercomputing and AI Engineer World’s Fair, and in 2023, he was selected to participate in the prestigious US Frontiers of Engineering organized by the National Academy of Engineering.

Petro Junior Milan
Title
Principal AI Engineer | SambaNova Systems


