Skip to main content

Argilla-Haystack

Argilla is an open-source platform for data-centric LLM development. Integrates human and model feedback loops for continuous LLM refinement and oversight.

With Argilla's Python SDK and adaptable UI, you can create human and model-in-the-loop workflows for:

  • Supervised fine-tuning
  • Preference tuning (RLHF, DPO, RLAIF, and more)
  • Small, specialized NLP models
  • Scalable evaluation.

Getting Started

You first need to install argilla and argilla-haystack as follows:

pip install argilla argilla-haystack["haystack-v1"]

You will need to an Argilla Server running to monitor the LLM. You can either install the server locally or have it on HuggingFace Spaces. For a complete guide on how to install and initialize the server, you can refer to the Quickstart Guide.

Usage

You can use your Haystack agent with Argilla with just a simple step. After the agent is created, we will need to call the handler to log the data into Argilla.

Let us create a simple pipeline with a conversational agent. Also, we will use GPT3.5 from OpenAI as our LLM. For this, you will need a valid API key from OpenAI. You can have more info and get one via this link.

After you get your API key, let us import the key.

import os
from getpass import getpass

openai_api_key = os.getenv("OPENAI_API_KEY", None) or getpass("Enter OpenAI API key:")

With the code snippet below, let us create the agent.

from haystack.nodes import PromptNode
from haystack.agents.memory import ConversationSummaryMemory
from haystack.agents.conversational import ConversationalAgent

# Define the node with the model
prompt_node = PromptNode(
    model_name_or_path="gpt-3.5-turbo-instruct", api_key=openai_api_key, max_length=256, stop_words=["Human"]
)
summary_memory = ConversationSummaryMemory(prompt_node)
conversational_agent = ConversationalAgent(prompt_node=prompt_node, memory=summary_memory)

Let us import the ArgillaCallback and run it. Note that the dataset with the given name will be pulled from Argilla server. If the dataset does not exist, it will be created with the given name.

from argilla_haystack import ArgillaCallback

api_key = "argilla.apikey"
api_url = "http://localhost:6900/"
dataset_name = "conversational_ai"

ArgillaCallback(agent=conversational_agent, dataset_name=dataset_name, api_url=api_url, api_key=api_key)

Now, let us run the agent to obtain a response. The prompt given and the response obtained will be logged in to Argilla server.

conversational_agent.run("Tell me three most interesting things about Istanbul, Turkey")

Alt text

Other Use Cases

Please refer to this notebook for a more detailed example.

Metadata

Release files for argilla-haystack 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for argilla-haystack 0.0.2
File Size Uploaded
argilla_haystack-0.0.2.tar.gz 1.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for argilla-haystack 0.0.2
File Interpreter ABI Platform
argilla_haystack-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 1.6 MB

Release files / argilla_haystack-0.0.2.tar.gz

Download URL argilla_haystack-0.0.2.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
6b87148c7394bc03742ed10adfe97513a9e536c3678ee2da61537fa913e7e189
BLAKE2b-256 checksum
How to use checksums
bbe2a1850654b776d0dca0eace76fed2a0ea57796640c38dd414035908838b14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.25.0

Release files / argilla_haystack-0.0.2-py3-none-any.whl

Download URL argilla_haystack-0.0.2-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c931331f37cd43af86256b22ef828127f5149059d9802bd22249c08de498e495
BLAKE2b-256 checksum
How to use checksums
69b8f89106a0b9a76c507ef9797a606e4f35aeb932a20e639f3e3748486ac4e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.25.0

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page