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

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")

Argilla Dataset

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.1b0.tar.gz (440.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

argilla_haystack-0.0.1b0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file argilla_haystack-0.0.1b0.tar.gz.

File metadata

  • Download URL: argilla_haystack-0.0.1b0.tar.gz
  • Upload date:
  • Size: 440.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.25.0

File hashes

Hashes for argilla_haystack-0.0.1b0.tar.gz
Algorithm Hash digest
SHA256 183f966be683e17585a828706239b401b79b4fc01da1d8589b2b32c2b3be43a1
MD5 92534fedb373f1760351bcc7168398b2
BLAKE2b-256 d0f765867ab89496672bc2a3cc96bf5ce574802b33d0d6bf3fd2e6b7a7740d4d

See more details on using hashes here.

File details

Details for the file argilla_haystack-0.0.1b0-py3-none-any.whl.

File metadata

File hashes

Hashes for argilla_haystack-0.0.1b0-py3-none-any.whl
Algorithm Hash digest
SHA256 40faec26ac89bacdc4065c5035488e96b921dab1dbdd0f8d3056f968850485f1
MD5 5ea68ea9377eac7962710258f43cae8a
BLAKE2b-256 06939c24bcc27e3005d7d0b29625a0abf30a5ae5736c6196645aa7fffbab8971

See more details on using hashes here.

Supported by

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