From 3a591a792e57544dd5840067e3d453a18c7b591d Mon Sep 17 00:00:00 2001 From: sdiazlor Date: Wed, 21 Feb 2024 11:32:10 +0100 Subject: [PATCH] add argilla integration --- integrations/argilla.md | 87 ++++++++++++++++++++++++++++++++++++++++ logos/argilla.png | Bin 0 -> 7139 bytes 2 files changed, 87 insertions(+) create mode 100644 integrations/argilla.md create mode 100644 logos/argilla.png diff --git a/integrations/argilla.md b/integrations/argilla.md new file mode 100644 index 00000000..c96cd38b --- /dev/null +++ b/integrations/argilla.md @@ -0,0 +1,87 @@ +--- +layout: integration +name: Argilla +description: Use Argilla as a collaboration platform for AI engineers and domain experts! +authors: + - name: Argilla Team + socials: + github: argilla-io + twitter: argilla_io + linkedin: argilla-io +pypi: https://pypi.org/project/argilla-haystack +repo: https://github.com/argilla-io/argilla-haystack +type: Monitoring +report_issue: https://github.com/argilla-io/argilla-haystack/issues +logo: /logos/argilla.png +version: Haystack 1.x +--- + +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: + +```bash +pip install argilla argilla-haystack['haystack-v1'] +``` + +You will need 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](https://docs.argilla.io/en/latest/getting_started/quickstart_installation.html). + +## 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. + +```python +import os +from getpass import getpass + +openai_api_key = os.getenv("OPENAI_API_KEY", None) +``` + +With the code snippet below, let us create the conversational agent. + +```python +from haystack.nodes import PromptNode +from haystack.agents.memory import ConversationSummaryMemory +from haystack.agents.conversational import ConversationalAgent + +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 `ArgillaCallbackHandler` with the standard arguments 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. For more customization, you can refer to the [tutorial](https://github.com/argilla-io/argilla-haystack/blob/main/docs/use_argilla_callback_in_haystack-v1.ipynb). + +```python +from argilla_haystack import ArgillaCallbackHandler + +dataset_name = "conversational_ai" +api_url = "http://localhost:6900/" +api_key = "argilla.apikey" + +argilla_callback = ArgillaCallbackHandler(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. + +```python +conversational_agent.run("Tell me three most interesting things about Istanbul, Turkey") +``` + +## Other Use Cases + +Please refer to this [notebook](https://github.com/argilla-io/argilla-haystack/blob/main/docs/use_argilla_callback_in_haystack-v1.ipynb) for a more detailed example. diff --git a/logos/argilla.png b/logos/argilla.png new file mode 100644 index 0000000000000000000000000000000000000000..124510cc65e57bceab15939f8e3554da096677b7 GIT binary patch literal 7139 zcmd^kX;4#J({2z2L_kFWndQ8Oqa+ara9}*5h|CBk*$D&^AOb;V12Ur^2r4Q_P;f#- zgoLmS^B{xFL{z{a1OXLM8AB36fH2&6Zrz{v_xDzPyJ}b0>eb!*SzT*Ay{dPrlY^DK ztePwY0+F{qcg7h4*#!J~WhBL#)N0>3u~5Bi30!swx_CK)5K4rc@(%JO?zIje_z<0m z1nged&_%~6{yOp=iYtvJ! zgP#R=)484mejsTfI(+foUE%ZRi|9B-a(qBjS0!gn1_i&OfI)XDpXnOE{L68=~d4U!$vI{i2U= zIHyjp3l~;88KS|?b^hGSyXw_1?^nkMMW0&M`TTiX2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