import{s as Ft,f as Xt,n as Qt,o as Wt}from"../chunks/scheduler.37c15a92.js";import{S as zt,i as Ht,g as i,s as a,r,A as Nt,h as o,f as s,c as n,j as jt,u,x as p,k as W,y as St,a as l,v as h,d,t as M,w as m}from"../chunks/index.2bf4358c.js";import{C as z}from"../chunks/CodeBlock.4f5fc1ad.js";import{C as Lt}from"../chunks/CourseFloatingBanner.15ba07e6.js";import{H as yt,E as Vt}from"../chunks/EditOnGithub.8916dc7c.js";function Yt(bt){let w,S,H,L,f,V,T,Y,J,It='Depending on the NLP task that you’re working with and the specific use case or application, your data and the annotation task will look differently. For this section of the course, we’ll use <a href="https://huggingface.co/datasets/SetFit/ag_news" rel="nofollow">a dataset collecting news</a> to complete two tasks: a text classification on the topic of each text and a token classification to identify the named entities mentioned.',P,c,Ut,D,g,$t="It is possible to import datasets from the Hub using the Argilla UI directly, but we’ll be using the SDK to learn how we can make further edits to the data if needed.",K,j,O,y,xt="The first step is to connect to our Argilla instance as we did in the previous section:",tt,b,et,I,Ct="We can now think about the settings of our dataset in Argilla. These represent the annotation task we’ll do over our data. First, we can load the dataset from the Hub and inspect its features, so that we can make sure that we configure the dataset correctly.",st,U,lt,$,At="These are the features of our dataset:",at,x,nt,C,kt="It contains a <code>text</code> and also some initial labels for the text classification. We’ll add those to our dataset settings together with a <code>spans</code> question for the named entities:",it,A,ot,k,vt="Let’s dive a bit deeper into what these settings mean. First, we’ve defined <strong>fields</strong>, these include the information that we’ll be annotating. In this case, we only have one field and it comes in the form of a text, so we’ve choosen a <code>TextField</code>.",pt,v,qt="Then, we define <strong>questions</strong> that represent the tasks that we want to perform on our data:",rt,q,Rt="<li>For the text classification task we’ve chosen a <code>LabelQuestion</code> and we used the unique values of the <code>label_text</code> column as our labels, to make sure that the question is compatible with the labels that already exist in the dataset.</li> <li>For the token classification task, we’ll need a <code>SpanQuestion</code>. We’ve defined a set of labels that we’ll be using for that task, plus the field on which we’ll be drawing the spans.</li>",ut,R,_t='To learn more about all the available types of fields and questions and other advanced settings, like metadata and vectors, go to the <a href="https://docs.argilla.io/latest/how_to_guides/dataset/#define-dataset-settings" rel="nofollow">Argilla docs</a>.',ht,_,dt,E,Et="Now that we’ve defined some settings, we can create the dataset:",Mt,Z,mt,B,Zt="The dataset now appears in our Argilla instance, but you will see that it’s empty. Now we need to add the records that we’ll be annotating i.e., the rows in our dataset. To do that, we’ll simply need to log the data as records and provide a mapping for those elements that don’t have the same name in the hub and Argilla datasets:",ct,G,wt,F,Bt="In our mapping, we’ve specified that the <code>label_text</code> column in the dataset should be mapped to the question with the name <code>label</code>. In this way, we’ll use the existing labels in the dataset as pre-annotations so we can annotate faster.",ft,X,Gt="Now our dataset is ready to start annotating!",Tt,Q,Jt,N,gt;return f=new yt({props:{title:"Load your dataset to Argilla",local:"load-your-dataset-to-argilla",headingTag:"h1"}}),T=new Lt({props:{chapter:10,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter10/section3.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter10/section3.ipynb"}]}}),j=new yt({props:{title:"Configure your dataset",local:"configure-your-dataset",headingTag:"h2"}}),b=new z({props:{code:"aW1wb3J0JTIwYXJnaWxsYSUyMGFzJTIwcmclMEElMEFIRl9UT0tFTiUyMCUzRCUyMCUyMi4uLiUyMiUyMCUyMCUyMyUyMG9ubHklMjBmb3IlMjBwcml2YXRlJTIwc3BhY2VzJTBBJTBBY2xpZW50JTIwJTNEJTIwcmcuQXJnaWxsYSglMEElMjAlMjAlMjAlMjBhcGlfdXJsJTNEJTIyLi4uJTIyJTJDJTBBJTIwJTIwJTIwJTIwYXBpX2tleSUzRCUyMi4uLiUyMiUyQyUwQSUyMCUyMCUyMCUyMGhlYWRlcnMlM0QlN0IlMjJBdXRob3JpemF0aW9uJTIyJTNBJTIwZiUyMkJlYXJlciUyMCU3QkhGX1RPS0VOJTdEJTIyJTdEJTJDJTIwJTIwJTIzJTIwb25seSUyMGZvciUyMHByaXZhdGUlMjBzcGFjZXMlMEEp",highlighted:`<span class="hljs-keyword">import</span> argilla <span class="hljs-keyword">as</span> rg

HF_TOKEN = <span class="hljs-string">&quot;...&quot;</span>  <span class="hljs-comment"># only for private spaces</span>

client = rg.Argilla(
    api_url=<span class="hljs-string">&quot;...&quot;</span>,
    api_key=<span class="hljs-string">&quot;...&quot;</span>,
    headers={<span class="hljs-string">&quot;Authorization&quot;</span>: <span class="hljs-string">f&quot;Bearer <span class="hljs-subst">{HF_TOKEN}</span>&quot;</span>},  <span class="hljs-comment"># only for private spaces</span>
)`,wrap:!1}}),U=new z({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YSUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJTZXRGaXQlMkZhZ19uZXdzJTIyJTJDJTIwc3BsaXQlM0QlMjJ0cmFpbiUyMiklMEFkYXRhLmZlYXR1cmVz",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

data = load_dataset(<span class="hljs-string">&quot;SetFit/ag_news&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)
data.features`,wrap:!1}}),x=new z({props:{code:"JTdCJ3RleHQnJTNBJTIwVmFsdWUoZHR5cGUlM0Qnc3RyaW5nJyUyQyUyMGlkJTNETm9uZSklMkMlMEElMjAnbGFiZWwnJTNBJTIwVmFsdWUoZHR5cGUlM0QnaW50NjQnJTJDJTIwaWQlM0ROb25lKSUyQyUwQSUyMCdsYWJlbF90ZXh0JyUzQSUyMFZhbHVlKGR0eXBlJTNEJ3N0cmluZyclMkMlMjBpZCUzRE5vbmUpJTdE",highlighted:`{<span class="hljs-string">&#x27;text&#x27;</span>: Value(dtype=<span class="hljs-string">&#x27;string&#x27;</span>, <span class="hljs-built_in">id</span>=<span class="hljs-literal">None</span>),
 <span class="hljs-string">&#x27;label&#x27;</span>: Value(dtype=<span class="hljs-string">&#x27;int64&#x27;</span>, <span class="hljs-built_in">id</span>=<span class="hljs-literal">None</span>),
 <span class="hljs-string">&#x27;label_text&#x27;</span>: Value(dtype=<span class="hljs-string">&#x27;string&#x27;</span>, <span class="hljs-built_in">id</span>=<span class="hljs-literal">None</span>)}`,wrap:!1}}),A=new z({props:{code:"c2V0dGluZ3MlMjAlM0QlMjByZy5TZXR0aW5ncyglMEElMjAlMjAlMjAlMjBmaWVsZHMlM0QlNUJyZy5UZXh0RmllbGQobmFtZSUzRCUyMnRleHQlMjIpJTVEJTJDJTBBJTIwJTIwJTIwJTIwcXVlc3Rpb25zJTNEJTVCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmcuTGFiZWxRdWVzdGlvbiglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBuYW1lJTNEJTIybGFiZWwlMjIlMkMlMjB0aXRsZSUzRCUyMkNsYXNzaWZ5JTIwdGhlJTIwdGV4dCUzQSUyMiUyQyUyMGxhYmVscyUzRGRhdGEudW5pcXVlKCUyMmxhYmVsX3RleHQlMjIpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJnLlNwYW5RdWVzdGlvbiglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBuYW1lJTNEJTIyZW50aXRpZXMlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0aXRsZSUzRCUyMkhpZ2hsaWdodCUyMGFsbCUyMHRoZSUyMGVudGl0aWVzJTIwaW4lMjB0aGUlMjB0ZXh0JTNBJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbGFiZWxzJTNEJTVCJTIyUEVSU09OJTIyJTJDJTIwJTIyT1JHJTIyJTJDJTIwJTIyTE9DJTIyJTJDJTIwJTIyRVZFTlQlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmaWVsZCUzRCUyMnRleHQlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjApJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTJDJTBBKQ==",highlighted:`settings = rg.Settings(
    fields=[rg.TextField(name=<span class="hljs-string">&quot;text&quot;</span>)],
    questions=[
        rg.LabelQuestion(
            name=<span class="hljs-string">&quot;label&quot;</span>, title=<span class="hljs-string">&quot;Classify the text:&quot;</span>, labels=data.unique(<span class="hljs-string">&quot;label_text&quot;</span>)
        ),
        rg.SpanQuestion(
            name=<span class="hljs-string">&quot;entities&quot;</span>,
            title=<span class="hljs-string">&quot;Highlight all the entities in the text:&quot;</span>,
            labels=[<span class="hljs-string">&quot;PERSON&quot;</span>, <span class="hljs-string">&quot;ORG&quot;</span>, <span class="hljs-string">&quot;LOC&quot;</span>, <span class="hljs-string">&quot;EVENT&quot;</span>],
            field=<span class="hljs-string">&quot;text&quot;</span>,
        ),
    ],
)`,wrap:!1}}),_=new yt({props:{title:"Upload the dataset",local:"upload-the-dataset",headingTag:"h2"}}),Z=new z({props:{code:"ZGF0YXNldCUyMCUzRCUyMHJnLkRhdGFzZXQobmFtZSUzRCUyMmFnX25ld3MlMjIlMkMlMjBzZXR0aW5ncyUzRHNldHRpbmdzKSUwQSUwQWRhdGFzZXQuY3JlYXRlKCk=",highlighted:`dataset = rg.Dataset(name=<span class="hljs-string">&quot;ag_news&quot;</span>, settings=settings)

dataset.create()`,wrap:!1}}),G=new z({props:{code:"ZGF0YXNldC5yZWNvcmRzLmxvZyhkYXRhJTJDJTIwbWFwcGluZyUzRCU3QiUyMmxhYmVsX3RleHQlMjIlM0ElMjAlMjJsYWJlbCUyMiU3RCk=",highlighted:'dataset.records.log(data, mapping={<span class="hljs-string">&quot;label_text&quot;</span>: <span class="hljs-string">&quot;label&quot;</span>})',wrap:!1}}),Q=new Vt({props:{source:"https://github.com/huggingface/course/blob/main/chapters/en/chapter10/3.mdx"}}),{c(){w=i("meta"),S=a(),H=i("p"),L=a(),r(f.$$.fragment),V=a(),r(T.$$.fragment),Y=a(),J=i("p"),J.innerHTML=It,P=a(),c=i("iframe"),D=a(),g=i("p"),g.textContent=$t,K=a(),r(j.$$.fragment),O=a(),y=i("p"),y.textContent=xt,tt=a(),r(b.$$.fragment),et=a(),I=i("p"),I.textContent=Ct,st=a(),r(U.$$.fragment),lt=a(),$=i("p"),$.textContent=At,at=a(),r(x.$$.fragment),nt=a(),C=i("p"),C.innerHTML=kt,it=a(),r(A.$$.fragment),ot=a(),k=i("p"),k.innerHTML=vt,pt=a(),v=i("p"),v.innerHTML=qt,rt=a(),q=i("ul"),q.innerHTML=Rt,ut=a(),R=i("p"),R.innerHTML=_t,ht=a(),r(_.$$.fragment),dt=a(),E=i("p"),E.textContent=Et,Mt=a(),r(Z.$$.fragment),mt=a(),B=i("p"),B.textContent=Zt,ct=a(),r(G.$$.fragment),wt=a(),F=i("p"),F.innerHTML=Bt,ft=a(),X=i("p"),X.textContent=Gt,Tt=a(),r(Q.$$.fragment),Jt=a(),N=i("p"),this.h()},l(t){const e=Nt("svelte-u9bgzb",document.head);w=o(e,"META",{name:!0,content:!0}),e.forEach(s),S=n(t),H=o(t,"P",{}),jt(H).forEach(s),L=n(t),u(f.$$.fragment,t),V=n(t),u(T.$$.fragment,t),Y=n(t),J=o(t,"P",{"data-svelte-h":!0}),p(J)!=="svelte-21xmjs"&&(J.innerHTML=It),P=n(t),c=o(t,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),jt(c).forEach(s),D=n(t),g=o(t,"P",{"data-svelte-h":!0}),p(g)!=="svelte-1nj4pzu"&&(g.textContent=$t),K=n(t),u(j.$$.fragment,t),O=n(t),y=o(t,"P",{"data-svelte-h":!0}),p(y)!=="svelte-tteoxx"&&(y.textContent=xt),tt=n(t),u(b.$$.fragment,t),et=n(t),I=o(t,"P",{"data-svelte-h":!0}),p(I)!=="svelte-qr4xxl"&&(I.textContent=Ct),st=n(t),u(U.$$.fragment,t),lt=n(t),$=o(t,"P",{"data-svelte-h":!0}),p($)!=="svelte-1tgrrsi"&&($.textContent=At),at=n(t),u(x.$$.fragment,t),nt=n(t),C=o(t,"P",{"data-svelte-h":!0}),p(C)!=="svelte-qqdqqz"&&(C.innerHTML=kt),it=n(t),u(A.$$.fragment,t),ot=n(t),k=o(t,"P",{"data-svelte-h":!0}),p(k)!=="svelte-14iwfy7"&&(k.innerHTML=vt),pt=n(t),v=o(t,"P",{"data-svelte-h":!0}),p(v)!=="svelte-1ps5pnk"&&(v.innerHTML=qt),rt=n(t),q=o(t,"UL",{"data-svelte-h":!0}),p(q)!=="svelte-1pt9e0q"&&(q.innerHTML=Rt),ut=n(t),R=o(t,"P",{"data-svelte-h":!0}),p(R)!=="svelte-12o3rnk"&&(R.innerHTML=_t),ht=n(t),u(_.$$.fragment,t),dt=n(t),E=o(t,"P",{"data-svelte-h":!0}),p(E)!=="svelte-kgkkua"&&(E.textContent=Et),Mt=n(t),u(Z.$$.fragment,t),mt=n(t),B=o(t,"P",{"data-svelte-h":!0}),p(B)!=="svelte-1t734rf"&&(B.textContent=Zt),ct=n(t),u(G.$$.fragment,t),wt=n(t),F=o(t,"P",{"data-svelte-h":!0}),p(F)!=="svelte-3kvwa0"&&(F.innerHTML=Bt),ft=n(t),X=o(t,"P",{"data-svelte-h":!0}),p(X)!=="svelte-akh87c"&&(X.textContent=Gt),Tt=n(t),u(Q.$$.fragment,t),Jt=n(t),N=o(t,"P",{}),jt(N).forEach(s),this.h()},h(){W(w,"name","hf:doc:metadata"),W(w,"content",Pt),Xt(c.src,Ut="https://huggingface.co/datasets/SetFit/ag_news/embed/viewer/default/train")||W(c,"src",Ut),W(c,"frameborder","0"),W(c,"width","100%"),W(c,"height","560px")},m(t,e){St(document.head,w),l(t,S,e),l(t,H,e),l(t,L,e),h(f,t,e),l(t,V,e),h(T,t,e),l(t,Y,e),l(t,J,e),l(t,P,e),l(t,c,e),l(t,D,e),l(t,g,e),l(t,K,e),h(j,t,e),l(t,O,e),l(t,y,e),l(t,tt,e),h(b,t,e),l(t,et,e),l(t,I,e),l(t,st,e),h(U,t,e),l(t,lt,e),l(t,$,e),l(t,at,e),h(x,t,e),l(t,nt,e),l(t,C,e),l(t,it,e),h(A,t,e),l(t,ot,e),l(t,k,e),l(t,pt,e),l(t,v,e),l(t,rt,e),l(t,q,e),l(t,ut,e),l(t,R,e),l(t,ht,e),h(_,t,e),l(t,dt,e),l(t,E,e),l(t,Mt,e),h(Z,t,e),l(t,mt,e),l(t,B,e),l(t,ct,e),h(G,t,e),l(t,wt,e),l(t,F,e),l(t,ft,e),l(t,X,e),l(t,Tt,e),h(Q,t,e),l(t,Jt,e),l(t,N,e),gt=!0},p:Qt,i(t){gt||(d(f.$$.fragment,t),d(T.$$.fragment,t),d(j.$$.fragment,t),d(b.$$.fragment,t),d(U.$$.fragment,t),d(x.$$.fragment,t),d(A.$$.fragment,t),d(_.$$.fragment,t),d(Z.$$.fragment,t),d(G.$$.fragment,t),d(Q.$$.fragment,t),gt=!0)},o(t){M(f.$$.fragment,t),M(T.$$.fragment,t),M(j.$$.fragment,t),M(b.$$.fragment,t),M(U.$$.fragment,t),M(x.$$.fragment,t),M(A.$$.fragment,t),M(_.$$.fragment,t),M(Z.$$.fragment,t),M(G.$$.fragment,t),M(Q.$$.fragment,t),gt=!1},d(t){t&&(s(S),s(H),s(L),s(V),s(Y),s(J),s(P),s(c),s(D),s(g),s(K),s(O),s(y),s(tt),s(et),s(I),s(st),s(lt),s($),s(at),s(nt),s(C),s(it),s(ot),s(k),s(pt),s(v),s(rt),s(q),s(ut),s(R),s(ht),s(dt),s(E),s(Mt),s(mt),s(B),s(ct),s(wt),s(F),s(ft),s(X),s(Tt),s(Jt),s(N)),s(w),m(f,t),m(T,t),m(j,t),m(b,t),m(U,t),m(x,t),m(A,t),m(_,t),m(Z,t),m(G,t),m(Q,t)}}}const Pt='{"title":"Load your dataset to Argilla","local":"load-your-dataset-to-argilla","sections":[{"title":"Configure your dataset","local":"configure-your-dataset","sections":[],"depth":2},{"title":"Upload the dataset","local":"upload-the-dataset","sections":[],"depth":2}],"depth":1}';function Dt(bt){return Wt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class le extends zt{constructor(w){super(),Ht(this,w,Dt,Yt,Ft,{})}}export{le as component};
