Skip to main content

Argilla-Haystack Integration

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

argilla_haystack-0.0.2.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

argilla_haystack-0.0.2-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file argilla_haystack-0.0.2.tar.gz.

File metadata

  • Download URL: argilla_haystack-0.0.2.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.25.0

File hashes

Hashes for argilla_haystack-0.0.2.tar.gz
Algorithm Hash digest
SHA256 6b87148c7394bc03742ed10adfe97513a9e536c3678ee2da61537fa913e7e189
MD5 e0451a6d1f8795b0a9e027789008e081
BLAKE2b-256 bbe2a1850654b776d0dca0eace76fed2a0ea57796640c38dd414035908838b14

See more details on using hashes here.

File details

Details for the file argilla_haystack-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for argilla_haystack-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c931331f37cd43af86256b22ef828127f5149059d9802bd22249c08de498e495
MD5 c53b19d2c65ff1405303806bc9fb4788
BLAKE2b-256 69b8f89106a0b9a76c507ef9797a606e4f35aeb932a20e639f3e3748486ac4e8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page