Argilla is an open-source data curation platform for LLMs. Using Argilla, everyone can build robust language models through faster data curation using both human and machine feedback. We provide support for each step in the MLOps cycle, from data labeling to model monitoring.
ArgillaCallbackHandler.
It’s useful to keep track of the inputs and outputs of your LLMs to generate datasets for future fine-tuning. This is especially useful when you’re using a LLM to generate data for a specific task, such as question answering, summarization, or translation.
Installation and Setup
Getting API Credentials
To get the Argilla API credentials, follow the next steps:- Go to your Argilla UI.
- Click on your profile picture and go to “My settings”.
- Then copy the API Key.
Setup Argilla
To use theArgillaCallbackHandler we will need to create a new FeedbackDataset in Argilla to keep track of your LLM experiments. To do so, please use the following code:
📌 NOTE: at the moment, just the prompt-response pairs are supported asFeedbackDataset.fields, so theArgillaCallbackHandlerwill just track the prompt i.e. the LLM input, and the response i.e. the LLM output.
Tracking
To use theArgillaCallbackHandler you can either use the following code, or just reproduce one of the examples presented in the following sections.
Scenario 1: Tracking an LLM
First, let’s just run a single LLM a few times and capture the resulting prompt-response pairs in Argilla.
Scenario 2: Tracking an LLM in a chain
Then we can create a chain using a prompt template, and then track the initial prompt and the final response in Argilla.
Scenario 3: Using an Agent with Tools
Finally, as a more advanced workflow, you can create an agent that uses some tools. So thatArgillaCallbackHandler will keep track of the input and the output, but not about the intermediate steps/thoughts, so that given a prompt we log the original prompt and the final response to that given prompt.
Note that for this scenario we’ll be using Google Search API (Serp API) so you will need to both installgoogle-search-resultsaspip install google-search-results, and to set the Serp API Key asos.environ["SERPAPI_API_KEY"] = "..."(you can find it at serpapi.com/dashboard), otherwise the example below won’t work.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.