filename
stringclasses 33
values | chunks
stringlengths 28
500
| repo_name
stringclasses 1
value |
---|---|---|
argilla-python/docs/reference/argilla_sdk/records/suggestions.md
|
Or, instantiate the Record and related Suggestions objects directly, like this:
python
dataset.records.log(
[
rg.Record(
fields={"text": "Hello World, how are you?"},
suggestions=[rg.Suggestion("negative", "label", score=0.9, agent="model_name")],
)
]
)
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/suggestions.md
|
Iterating over records with suggestions
Just like responses, suggestions can be accessed from a Record via their question name as an attribute of the record. So if a question is named label, the suggestion can be accessed as record.label. The following example demonstrates how to access suggestions from a record object:
python
for record in dataset.records(with_suggestions=True):
print(record.suggestions.label)
Class Reference
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/suggestions.md
|
rg.Suggestion
::: argilla_sdk.suggestions.Suggestion
options:
heading_level: 3
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/vectors.md
|
hide: footer
rg.Vector
A vector is a numerical representation of a Record field or attribute, usually the record's text. Vectors can be used to search for similar records via the UI or SDK. Vectors can be added to a record directly or as a dictionary with a key that the matches rg.VectorField name.
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/vectors.md
|
Usage Examples
To use vectors within a dataset, you must define a vector field in the dataset settings. The vector field is a list of vector fields that can be attached to a record. The following example demonstrates how to add vectors to a dataset and how to access vectors from a record object:
```python
import argilla_sdk as rg
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/vectors.md
|
dataset = Dataset(
name="dataset_with_metadata",
settings=Settings(
fields=[TextField(name="text")],
questions=[LabelQuestion(name="label", labels=["positive", "negative"])],
vectors=[
VectorField(name="vector_name"),
],
),
)
dataset.create()
```
Then, you can add records to the dataset with vectors that correspond to the vector field defined in the dataset settings:
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/vectors.md
|
python
dataset.records.log(
[
{
"text": "Hello World, how are you?",
"vector_name": [0.1, 0.2, 0.3]
}
]
)
Vectors can be passed using a mapping, where the key is the key in the data source and the value is the name in the dataset's setting's rg.VectorField object. For example, the following code adds a record with a vector using a mapping:
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/vectors.md
|
python
dataset.records.log(
[
{
"text": "Hello World, how are you?",
"x": [0.1, 0.2, 0.3]
}
],
mapping={"x": "vector_name"}
)
Or, vectors can be instantiated and added to a record directly, like this:
python
dataset.records.log(
[
rg.Record(
fields={"text": "Hello World, how are you?"},
vectors=[rg.Vector("embedding", [0.1, 0.2, 0.3])],
)
]
)
Class Reference
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/vectors.md
|
rg.Vector
::: argilla_sdk.vectors.Vector
options:
heading_level: 3
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/responses.md
|
hide: footer
rg.Response
Class for interacting with Argilla Responses of records. Responses are answers to questions by a user. Therefore, a recod question can have multiple responses, one for each user that has answered the question. A Response is typically created by a user in the UI or consumed from a data source as a label, unlike a Suggestion which is typically created by a model prediction.
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/responses.md
|
Usage Examples
Responses can be added to an instantiated Record directly or as a dictionary a dictionary. The following examples demonstrate how to add responses to a record object and how to access responses from a record object:
Instantiate the Record and related Response objects:
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/responses.md
|
python
dataset.records.log(
[
rg.Record(
fields={"text": "Hello World, how are you?"},
responses=[rg.Response("label", "negative", user_id=user.id)],
external_id=str(uuid.uuid4()),
)
]
)
Or, add a response from a dictionary where key is the question name and value is the response:
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/responses.md
|
```python
dataset.records.log(
[
{
"text": "Hello World, how are you?",
"label.response": "negative",
},
]
)
```
Responses can be accessed from a Record via their question name as an attribute of the record. So if a question is named label, the response can be accessed as record.label. The following example demonstrates how to access responses from a record object:
```python
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/responses.md
|
iterate over the records and responses
for record in dataset.records:
for response in record.responses.label:
print(response.value)
print(response.user_id)
validate that the record has a response
for record in dataset.records:
if record.responses.label:
for response in record.responses.label:
print(response.value)
print(response.user_id)
```
Class Reference
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/responses.md
|
rg.Response
::: argilla_sdk.responses.Response
options:
heading_level: 3
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/records.md
|
hide: footer
rg.Record
The Record object is used to represent a single record in Argilla. It contains fields, suggestions, responses, metadata, and vectors.
Usage Examples
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/records.md
|
Creating a Record
To create records, you can use the Record class and pass it to the Dataset.records.log method. The Record class requires a fields parameter, which is a dictionary of field names and values. The field names must match the field names in the dataset's Settings object to be accepted.
python
dataset.records.add(
records=[
rg.Record(
fields={"text": "Hello World, how are you?"},
),
]
) # (1)
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/records.md
|
The Argilla dataset contains a field named text matching the key here.
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/records.md
|
Accessing Record Attributes
The Record object has suggestions, responses, metadata, and vectors attributes that can be accessed directly whilst iterating over records in a dataset.
python
for record in dataset.records(
with_suggestions=True,
with_responses=True,
with_metadata=True,
with_vectors=True
):
print(record.suggestions)
print(record.responses)
print(record.metadata)
print(record.vectors)
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/records/records.md
|
Record properties can also be updated whilst iterating over records in a dataset.
python
for record in dataset.records(with_metadata=True):
record.metadata = {"department": "toys"}
For changes to take effect, the user must call the update method on the Dataset object, or pass the updated records to Dataset.records.log.
Class Reference
rg.Record
::: argilla_sdk.records.Record
options:
heading_level: 3
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/datasets/dataset_records.md
|
hide: footer
rg.Dataset.records
Usage Examples
In most cases, you will not need to create a DatasetRecords object directly. Instead, you can access it via the Dataset object:
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/datasets/dataset_records.md
|
python
dataset.records
!!! note "For user familiar with legacy approaches"
1. Dataset.records object is used to interact with the records in a dataset. It interactively fetches records from the server in batches without using a local copy of the records.
2. The log method of Dataset.records is used to both add and update records in a dataset. If the record includes a known id field, the record will be updated. If the record does not include a known id field, the record will be added.
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/datasets/dataset_records.md
|
Adding records to a dataset
To add records to a dataset, use the log method. Records can be added as dictionaries or as Record objects. Single records can also be added as a dictionary or Record.
=== "As a Record object"
=== "From a data structure"
=== "From a data structure with a mapping"
=== "From a Hugging Face dataset"
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/datasets/dataset_records.md
|
Updating records in a dataset
Records can also be updated using the log method with records that contain an id to identify the records to be updated. As above, records can be added as dictionaries or as Record objects.
=== "As a Record object"
=== "From a data structure"
=== "From a data structure with a mapping"
=== "From a Hugging Face dataset"
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/datasets/dataset_records.md
|
Iterating over records in a dataset
Dataset.records can be used to iterate over records in a dataset from the server. The records will be fetched in batches from the server::
```python
for record in dataset.records:
print(record)
Fetch records with suggestions and responses
for record in dataset.records(with_suggestions=True, with_responses=True):
print(record.suggestions)
print(record.responses)
Filter records by a query and fetch records with vectors
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/datasets/dataset_records.md
|
for record in dataset.records(query="capital", with_vectors=True):
print(record.vectors)
```
Check out the rg.Record class reference for more information on the properties and methods available on a record and the rg.Query class reference for more information on the query syntax.
Class Reference
rg.Dataset.records
::: argilla_sdk.records.DatasetRecords
options:
heading_level: 3
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/datasets/datasets.md
|
hide: footer
rg.Dataset
Dataset is a class that represents a collection of records. It is used to store and manage records in Argilla.
Usage Examples
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/datasets/datasets.md
|
Creating a Dataset
To create a new dataset you need to define its name and settings. Optional parameters are workspace and client, if you want to create the dataset in a specific workspace or on a specific Argilla instance.
python
dataset = rg.Dataset(
name="my_dataset",
settings=rg.Settings(
fields=[
rg.TextField(name="text"),
],
questions=[
rg.TextQuestion(name="response"),
],
),
)
dataset.create()
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/datasets/datasets.md
|
For a detail guide of the dataset creation and publication process, see the Dataset how to guide.
Retrieving an existing Dataset
To retrieve an existing dataset, use client.datasets("my_dataset") instead.
python
dataset = client.datasets("my_dataset")
Class Reference
rg.Dataset
::: argilla_sdk.datasets.Dataset
options:
heading_level: 3
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/.ipynb_checkpoints/workspaces-checkpoint.md
|
hide: footer
rg.Workspace
In Argilla, workspaces are used to organize datasets in to groups. For example, you might have a workspace for each project or team.
Usage Examples
To create a new workspace, instantiate the Workspace object with the client and the name:
python
workspace = rg.Workspace(name="my_workspace")
workspace.create()
To retrieve an existing workspace, use the client.workspaces attribute:
python
workspace = client.workspaces("my_workspace")
Class Reference
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/.ipynb_checkpoints/workspaces-checkpoint.md
|
rg.Workspace
::: argilla_sdk.workspaces.Workspace
options:
heading_level: 4
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/.ipynb_checkpoints/client-checkpoint.md
|
hide: footer
rg.Argilla
To interact with the Argilla server from python you can use the Argilla class. The Argilla client is used to create, get, update, and delete all Argilla resources, such as workspaces, users, datasets, and records.
Usage Examples
Connecting to an Argilla server
To connect to an Argilla server, instantiate the Argilla class and pass the api_url of the server and the api_key to authenticate.
```python
import argilla_sdk as rg
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/.ipynb_checkpoints/client-checkpoint.md
|
client = rg.Argilla(
api_url="https://argilla.example.com",
api_key="my_token",
)
```
Accessing Dataset, Workspace, and User objects
The Argilla clients provides access to the Dataset, Workspace, and User objects of the Argilla server.
```python
my_dataset = client.datasets("my_dataset")
my_workspace = client.workspaces("my_workspace")
|
argilla-io/argilla-python
|
argilla-python/docs/reference/argilla_sdk/.ipynb_checkpoints/client-checkpoint.md
|
my_user = client.users("my_user")
```
These resources can then be interacted with to access their properties and methods. For example, to list all datasets in a workspace:
python
for dataset in my_workspace.datasets:
print(dataset.name)
Class Reference
rg.Argilla
::: argilla_sdk.client.Argilla
options:
heading_level: 3
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/quickstart.md
|
description: Quickstart of Argilla on how to create your first dataset.
Quickstart
This guide provides a quick overview of the Argilla SDK and how to create your first dataset.
Setting up your Argilla project
Install the SDK with pip
To work with Argilla datasets, you need to use the Argilla SDK. You can install the SDK with pip as follows:
!!! note
The package is not yet available on PyPi. You'll need to install it directly from the GitHub repository.
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/quickstart.md
|
console
pip install git+https://github.com/argilla-io/argilla-python.git
Run the Argilla server
If you have already deployed Argilla Server, you can skip this step. Otherwise, you can quickly deploy it in two different ways:
Remotely using a HF Space.
Locally using Docker.
console
docker run -d --name quickstart -p 6900:6900 argilla/argilla-quickstart:latest
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/quickstart.md
|
Connect to the Argilla server
Get your <api_url>:
If you are using Hugging Face Spaces, the URL should be constructed as follows: https://[your-owner-name]-[your_space_name].hf.space
If you are using Docker, the URL is the URL shown in your browser (by default http://localhost:6900)
Get your <api_key> in My Settings in the Argilla UI (by default owner.apikey).
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/quickstart.md
|
!!! note
Make sure to replace <api_url> and <api_key> with your actual values. If you are using a private Hugging Face Space, you need to specify your HF_TOKEN which can be found here.
```python
import argilla_sdk as rg
client = rg.Argilla(
api_url="",
api_key=""
# extra_headers={"Authorization": f"Bearer {HF_TOKEN}"}
)
```
Create your first dataset
To create a dataset with a simple text classification task, first, you need to define the dataset settings.
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/quickstart.md
|
python
settings = rg.Settings(
guidelines="Classify the reviews as positive or negative.",
fields=[
rg.TextField(
name="review",
title="Text from the review",
use_markdown=False,
),
],
questions=[
rg.LabelQuestion(
name="my_label",
title="In which category does this article fit?",
labels=["positive", "negative"],
)
],
)
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/quickstart.md
|
Now you can create the dataset with the settings you defined. Publish the dataset to make it available in the UI and add the records.
!!! note
The workspace parameter is optional. If you don't specify it, the dataset will be created in the default workspace admin.
python
dataset = rg.Dataset(
name=f"my_first_dataset",
settings=settings,
client=client,
)
dataset.create()
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/quickstart.md
|
Add records to your dataset
Retrieve the data to be added to the dataset. We will use the IMDB dataset from the Hugging Face Datasets library.
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/quickstart.md
|
python
pip install -qqq datasets
```python
from datasets import load_dataset
data = load_dataset("imdb", split="train[:100]").to_list()
```
Now you can add the data to your dataset. Use a mapping to indicate which keys/columns in the source data correspond to the Argilla dataset fields.
python
dataset.records.log(records=data, mapping={"text": "review"})
🎉 You have successfully created your first dataset with Argilla. You can now access it in the Argilla UI and start annotating the records.
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/quickstart.md
|
More references
Installation guide
How-to guides
API reference
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/faq.md
|
description: Argilla-python is the reference argilla python server SDK.
hide: toc
FAQs
??? Question "What is Argilla?"
??? Question "Does Argilla cost money?"
??? Question "What data types does Argilla support?"
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/faq.md
|
??? Question "Does Argilla train models?"
??? Question "Does Argilla provide annotation workforces?"
??? Question "How does Argilla differ from competitors like Lilac, Snorkel, Prodigy and Scale?"
??? Question "What is the difference between Argilla 2.0 and the legacy datasets in 1.0?"
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/installation.md
|
description: Installation of Argilla-python.
Installation
Install the SDK with pip
Since this package is not yet published on PyPi, you can install it directly from the repository:
console
pip install git+https://github.com/argilla-io/argilla-python.git
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/installation.md
|
Run the Argilla server
If you have already deployed Argilla Server, you can skip this step. Otherwise, you can quickly deploy it in two different ways:
!!! note
You can use this SDK with any stable release of argilla server >= 1.27.
Using a HF Space.
Locally with Docker.
console
docker run -d --name quickstart -p 6900:6900 argilla/argilla-quickstart:latest
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/installation.md
|
Connect to the Argilla server
Get your <api_url>:
If you are using HF Spaces, it should be constructed as follows: https://[your-owner-name]-[your_space_name].hf.space
If you are using Docker, it is the URL shown in your browser (by default http://localhost:6900)
Get your <api_key> in My Settings in the Argilla UI (by default owner.apikey).
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/installation.md
|
!!! note
Make sure to replace <api_url> and <api_key> with your actual values. If you are using a private HF Space, you need to specify your HF_TOKEN which can be found here.
```python
import argilla_sdk as rg
client = rg.Argilla(
api_url="",
api_key="",
# extra_headers={"Authorization": f"Bearer {HF_TOKEN}"}
)
```
Developer documentation
If you want to contribute to the development of the SDK, you can follow the instructions below.
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/installation.md
|
Installation
To install the development dependencies, run the following commands:
```console
Install pdm (https://github.com/pdm-project/pdm)
pip install pdm
Install the package in editable mode
pip install -e .
Install the development dependencies with pdm
pdm install --dev
```
Generating documentation
To generate the docs you will need to install the development dependencies, and run the following command to create the development server with mkdocs:
|
argilla-io/argilla-python
|
argilla-python/docs/getting_started/installation.md
|
console
mkdocs serve
You will find the built documentation in http://localhost:8000/argilla-python/.
|
argilla-io/argilla-python
|