filename
stringclasses 32
values | chunks
stringlengths 28
500
| repo_name
stringclasses 1
value |
---|---|---|
argilla/argilla/docs/reference/argilla/settings/metadata_property.md | Define metadata properties as integer
int_metadata_field = rg.IntegerMetadataProperty(
name="quantity",
min=0,
max=100,
title="Quantity",
)
```
Metadata properties can be added to a dataset settings object: | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/settings/metadata_property.md | ```python
dataset = rg.Dataset(
name="my_dataset",
settings=rg.Settings(
fields=[
rg.TextField(name="text"),
],
metadata=[
metadata_field,
float_metadata_field,
int_metadata_field,
],
),
)
```
To add records with metadata, refer to the rg.Metadata class documentation.
Class References | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/settings/metadata_property.md | rg.FloatMetadataProperty
::: src.argilla.settings._metadata.FloatMetadataProperty
options:
heading_level: 3
rg.IntegerMetadataProperty
::: src.argilla.settings._metadata.IntegerMetadataProperty
options:
heading_level: 3
rg.TermsMetadataProperty
::: src.argilla.settings._metadata.TermsMetadataProperty
options:
heading_level: 3 | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/settings/questions.md | hide: footer
Questions
Questions in Argilla are the questions that will be answered as feedback. They are used to define the questions that will be answered by users or models. | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/settings/questions.md | Usage Examples
To define a label question, for example, instantiate the LabelQuestion class and pass it to the Settings class.
```python
label_question = rg.LabelQuestion(name="label", labels=["positive", "negative"])
settings = rg.Settings(
fields=[
rg.TextField(name="text"),
],
questions=[
label_question,
],
)
``` | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/settings/questions.md | Questions can be combined in extensible ways based on the type of feedback you want to collect. For example, you can combine a label question with a text question to collect both a label and a text response.
```python
label_question = rg.LabelQuestion(name="label", labels=["positive", "negative"])
text_question = rg.TextQuestion(name="response")
settings = rg.Settings(
fields=[
rg.TextField(name="text"),
],
questions=[
label_question,
text_question,
],
) | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/settings/questions.md | dataset = rg.Dataset(
name="my_dataset",
settings=settings,
)
```
To add records with responses to questions, refer to the rg.Response class documentation.
Class References
rg.LabelQuestion
::: src.argilla.settings._question.LabelQuestion
options:
heading_level: 3
rg.MultiLabelQuestion
::: src.argilla.settings._question.MultiLabelQuestion
options:
heading_level: 3 | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/settings/questions.md | rg.RankingQuestion
::: src.argilla.settings._question.RankingQuestion
options:
heading_level: 3
rg.TextQuestion
::: src.argilla.settings._question.TextQuestion
options:
heading_level: 3
rg.RatingQuestion
::: src.argilla.settings._question.RatingQuestion
options:
heading_level: 3
rg.SpanQuestion
::: src.argilla.settings._question.SpanQuestion
options:
heading_level: 3 | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/records/metadata.md | hide: footer
metadata
Metadata in argilla is a dictionary that can be attached to a record. It is used to store additional information about the record that is not part of the record's fields or responses. For example, the source of the record, the date it was created, or any other information that is relevant to the record. Metadata can be added to a record directly or as valules within a dictionary. | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/records/metadata.md | Usage Examples
To use metadata within a dataset, you must define a metadata property in the dataset settings. The metadata property is a list of metadata properties that can be attached to a record. The following example demonstrates how to add metadata to a dataset and how to access metadata from a record object:
```python
import argilla as rg | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/records/metadata.md | dataset = Dataset(
name="dataset_with_metadata",
settings=Settings(
fields=[TextField(name="text")],
questions=[LabelQuestion(name="label", labels=["positive", "negative"])],
metadata=[
rg.TermsMetadataProperty(name="category", options=["A", "B", "C"]),
],
),
)
dataset.create()
```
Then, you can add records to the dataset with metadata that corresponds to the metadata property defined in the dataset settings: | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/records/metadata.md | python
dataset_with_metadata.records.log(
[
{"text": "text", "label": "positive", "category": "A"},
{"text": "text", "label": "negative", "category": "B"},
]
) | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/records/suggestions.md | hide: footer
rg.Suggestion
Class for interacting with Argilla Suggestions of records. Suggestions are typically created by a model prediction, unlike a Response which is typically created by a user in the UI or consumed from a data source as a label.
Usage Examples | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/records/suggestions.md | Adding records with suggestions
Suggestions can be added to a record directly or via a dictionary structure. The following examples demonstrate how to add suggestions to a record object and how to access suggestions from a record object:
Add a response from a dictionary where key is the question name and value is the response: | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/records/suggestions.md | python
dataset.records.log(
[
{
"text": "Hello World, how are you?",
"label": "negative", # this will be used as a suggestion
},
]
)
If your data contains scores for suggestions you can add them as well via the mapping parameter. The following example demonstrates how to add a suggestion with a score to a record object: | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/records/suggestions.md | python
dataset.records.log(
[
{
"prompt": "Hello World, how are you?",
"label": "negative", # this will be used as a suggestion
"score": 0.9, # this will be used as the suggestion score
"model": "model_name", # this will be used as the suggestion agent
},
],
mapping={
"score": "label.suggestion.score",
"model": "label.suggestion.agent",
}, # `label` is the question name in the dataset settings
) | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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"].value) | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/records/suggestions.md | We can also add suggestions to records as we iterate over them using the add method:
python
for record in dataset.records(with_suggestions=True):
if not record.suggestions["label"]: # (1)
record.suggestions.add(
rg.Suggestion("positive", "label", score=0.9, agent="model_name")
) # (2)
Validate that the record has a suggestion
Add a suggestion to the record if it does not already have one
Class Reference | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/records/suggestions.md | rg.Suggestion
::: src.argilla.suggestions.Suggestion
options:
heading_level: 3 | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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 as rg | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/records/vectors.md | rg.Vector
::: src.argilla.vectors.Vector
options:
heading_level: 3 | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/records/responses.md | iterate over the records and responses
for record in dataset.records:
for response in record.responses["label"]: # (1)
print(response.value)
print(response.user_id) | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/records/responses.md | 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)
else:
record.responses.add(
rg.Response("label", "positive", user_id=user.id)
) # (2) | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/records/responses.md | ``
1. Access the responses for the question namedlabelfor each record like a dictionary containing a list ofResponse` objects.
2. Add a response to the record if it does not already have one.
Class Reference
rg.Response
::: src.argilla.responses.Response
options:
heading_level: 3 | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/records/records.md | The Argilla dataset contains a field named text matching the key here. | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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. All core record atttributes can be updated in this way. Check their respective documentation for more information: Suggestions, Responses, Metadata, Vectors. | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/records/records.md | Class Reference
rg.Record
::: src.argilla.records._resource.Record
options:
heading_level: 3 | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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
::: src.argilla.records._dataset_records.DatasetRecords
options:
heading_level: 3 | argilla-io/argilla |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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 |
argilla/argilla/docs/reference/argilla/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
::: src.argilla.datasets._resource.Dataset
options:
heading_level: 3 | argilla-io/argilla |
argilla/argilla/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:
console
pip install argilla --pre | argilla-io/argilla |
argilla/argilla/docs/getting_started/quickstart.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:
Remotely using a HF Space.
!!! note
As this is a release candidate version, you'll need to manually change the version in the HF Space Files > Dockerfile to argilla/argilla-quickstart:v2.0.0rc1.
Locally using Docker.
console
docker run -d --name quickstart -p 6900:6900 argilla/argilla-quickstart:v2.0.0rc1 | argilla-io/argilla |
argilla/argilla/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 |
argilla/argilla/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 as rg
client = rg.Argilla(
api_url="",
api_key=""
# 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 |
argilla/argilla/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 |
argilla/argilla/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 |
argilla/argilla/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 |
argilla/argilla/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 |
argilla/argilla/docs/getting_started/quickstart.md | More references
Installation guide
How-to guides
API reference | argilla-io/argilla |
argilla/argilla/docs/getting_started/faq.md | description: These are the Frequently Asked Questions regarding Argilla.
hide: toc
FAQs
??? Question "What is Argilla?"
??? Question "Does Argilla cost money?"
??? Question "What data types does Argilla support?" | argilla-io/argilla |
argilla/argilla/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 |
argilla/argilla/docs/getting_started/installation.md | description: Installation of the Argilla SDK.
Installation
Install the SDK with pip
console
pip install argilla --pre | argilla-io/argilla |
argilla/argilla/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:
Using a HF Space.
!!! note
As this is a release candidate version, you'll need to manually change the version in the HF Space Files > Dockerfile to argilla/argilla-quickstart:v2.0.0rc1.
Locally with Docker.
console
docker run -d --name quickstart -p 6900:6900 argilla/argilla-quickstart:v2.0.0rc1 | argilla-io/argilla |
argilla/argilla/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 |
argilla/argilla/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 as rg
client = rg.Argilla(
api_url="",
api_key="",
# 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 |
argilla/argilla/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 |
argilla/argilla/docs/getting_started/installation.md | console
mkdocs serve
You will find the built documentation in http://localhost:8000/argilla-python/. | argilla-io/argilla |