Buckets:
| import{s as Ie,n as Ae,o as Re}from"../chunks/scheduler.37c15a92.js";import{S as Ge,i as ze,g as S,s as o,r as i,A as De,h as P,f as a,c as n,j as Me,u as r,x as Ce,k as Je,y as je,a as s,v as l,d as h,t as m,w as c}from"../chunks/index.7cb9c9b8.js";import{C as We}from"../chunks/CodeBlock.abae2786.js";import{C as Ye}from"../chunks/CourseFloatingBanner.df82c153.js";import{Q as p}from"../chunks/Question.7e41e492.js";import{H as f,E as Be}from"../chunks/getInferenceSnippets.f9350a3f.js";function Fe(_e){let d,L,Z,N,u,X,$,Q,g,qe="This chapter covered a lot of ground! Don’t worry if you didn’t grasp all the details; the next chapters will help you understand how things work under the hood.",V,w,ke="Before moving on, though, let’s test what you learned in this chapter.",K,y,O,x,ee,b,te,T,ae,v,Ue="Which of the following commands will produce a random sample of 50 elements from <code>dataset</code>?",se,C,oe,_,ne,q,ie,k,re,U,le,M,he,J,me,W,ce,I,fe,A,pe,R,de,G,ue,z,$e,D,ge,j,we,Y,ye,B,xe,F,be,H,Te,E,ve;return u=new f({props:{title:"End-of-chapter quiz",local:"end-of-chapter-quiz",headingTag:"h1"}}),$=new Ye({props:{chapter:5,classNames:"absolute z-10 right-0 top-0"}}),y=new f({props:{title:"1. The load_dataset() function in 🤗 Datasets allows you to load a dataset from which of the following locations?",local:"1-the-loaddataset-function-in--datasets-allows-you-to-load-a-dataset-from-which-of-the-following-locations",headingTag:"h3"}}),x=new p({props:{choices:[{text:"Locally, e.g. on your laptop",explain:"Correct! You can pass the paths of local files to the <code>data_files</code> argument of <code>load_dataset()</code> to load local datasets.",correct:!0},{text:"The Hugging Face Hub",explain:"Correct! You can load datasets on the Hub by providing the dataset ID, e.g. <code>load_dataset('emotion')</code>.",correct:!0},{text:"A remote server",explain:"Correct! You can pass URLs to the <code>data_files</code> argument of <code>load_dataset()</code> to load remote files.",correct:!0}]}}),b=new f({props:{title:"2. Suppose you load one of the GLUE tasks as follows:",local:"2-suppose-you-load-one-of-the-glue-tasks-as-follows",headingTag:"h3"}}),T=new We({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJnbHVlJTIyJTJDJTIwJTIybXJwYyUyMiUyQyUyMHNwbGl0JTNEJTIydHJhaW4lMjIp",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset | |
| dataset = load_dataset(<span class="hljs-string">"glue"</span>, <span class="hljs-string">"mrpc"</span>, split=<span class="hljs-string">"train"</span>)`,wrap:!1}}),C=new p({props:{choices:[{text:"<code>dataset.sample(50)</code>",explain:"This is incorrect -- there is no <code>Dataset.sample()</code> method."},{text:"<code>dataset.shuffle().select(range(50))</code>",explain:"Correct! As you saw in this chapter, you first shuffle the dataset and then select the samples from it.",correct:!0},{text:"<code>dataset.select(range(50)).shuffle()</code>",explain:"This is incorrect -- although the code will run, it will only shuffle the first 50 elements in the dataset."}]}}),_=new f({props:{title:"3. Suppose you have a dataset about household pets called pets_dataset , which has a name column that denotes the name of each pet. Which of the following approaches would allow you to filter the dataset for all pets whose names start with the letter “L”?",local:"3-suppose-you-have-a-dataset-about-household-pets-called-petsdataset--which-has-a-name-column-that-denotes-the-name-of-each-pet-which-of-the-following-approaches-would-allow-you-to-filter-the-dataset-for-all-pets-whose-names-start-with-the-letter-l",headingTag:"h3"}}),q=new p({props:{choices:[{text:"<code>pets_dataset.filter(lambda x : x['name'].startswith('L'))</code>",explain:"Correct! Using a Python lambda function for these quick filters is a great idea. Can you think of another solution?",correct:!0},{text:"<code>pets_dataset.filter(lambda x['name'].startswith('L'))</code>",explain:"This is incorrect -- a lambda function takes the general form <code>lambda *arguments* : *expression*</code>, so you need to provide arguments in this case."},{text:"Create a function like <code>def filter_names(x): return x['name'].startswith('L')</code> and run <code>pets_dataset.filter(filter_names)</code>.",explain:"Correct! Just like with <code>Dataset.map()</code>, you can pass explicit functions to <code>Dataset.filter()</code>. This is useful when you have some complex logic that isn't suitable for a short lambda function. Which of the other solutions would work?",correct:!0}]}}),k=new f({props:{title:"4. What is memory mapping?",local:"4-what-is-memory-mapping",headingTag:"h3"}}),U=new p({props:{choices:[{text:"A mapping between CPU and GPU RAM",explain:"That's not it -- try again!"},{text:"A mapping between RAM and filesystem storage",explain:"Correct! 🤗 Datasets treats each dataset as a memory-mapped file. This allows the library to access and operate on elements of the dataset without needing to fully load it into memory.",correct:!0},{text:"A mapping between two files in the 🤗 Datasets cache",explain:"This is not correct - try again!"}]}}),M=new f({props:{title:"5. Which of the following are the main benefits of memory mapping?",local:"5-which-of-the-following-are-the-main-benefits-of-memory-mapping",headingTag:"h3"}}),J=new p({props:{choices:[{text:"Accessing memory-mapped files is faster than reading from or writing to disk.",explain:"Correct! This allows 🤗 Datasets to be blazing fast. That's not the only benefit, though.",correct:!0},{text:"Applications can access segments of data in an extremely large file without having to read the whole file into RAM first.",explain:"Correct! This allows 🤗 Datasets to load multi-gigabyte datasets on your laptop without blowing up your CPU. What other advantage does memory mapping offer?",correct:!0},{text:"It consumes less energy, so your battery lasts longer.",explain:"This is not correct -- try again!"}]}}),W=new f({props:{title:"6. Why does the following code fail?",local:"6-why-does-the-following-code-fail",headingTag:"h3"}}),I=new We({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJhbGxvY2luZSUyMiUyQyUyMHN0cmVhbWluZyUzRFRydWUlMkMlMjBzcGxpdCUzRCUyMnRyYWluJTIyKSUwQWRhdGFzZXQlNUIwJTVE",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset | |
| dataset = load_dataset(<span class="hljs-string">"allocine"</span>, streaming=<span class="hljs-literal">True</span>, split=<span class="hljs-string">"train"</span>) | |
| dataset[<span class="hljs-number">0</span>]`,wrap:!1}}),A=new p({props:{choices:[{text:"It tries to stream a dataset that's too large to fit in RAM.",explain:"This is not correct -- streaming datasets are decompressed on the fly, and you can process terabyte-sized datasets with very little RAM!"},{text:"It tries to access an <code>IterableDataset</code>.",explain:"Correct! An <code>IterableDataset</code> is a generator, not a container, so you should access its elements using <code>next(iter(dataset))</code>.",correct:!0},{text:"The <code>allocine</code> dataset doesn't have a <code>train</code> split.",explain:"This is incorrect -- check out the [<code>allocine</code> dataset card](https://huggingface.co/datasets/allocine) on the Hub to see which splits it contains."}]}}),R=new f({props:{title:"7. Which of the following are the main benefits of creating a dataset card?",local:"7-which-of-the-following-are-the-main-benefits-of-creating-a-dataset-card",headingTag:"h3"}}),G=new p({props:{choices:[{text:"It provides information about the intended use and supported tasks of the dataset so others in the community can make an informed decision about using it.",explain:"Correct! Undocumented datasets may be used to train models that may not reflect the intentions of the dataset creators, or may produce models whose legal status is murky if they're trained on data that violates privacy or licensing restrictions. This isn't the only benefit, though!",correct:!0},{text:"It helps draw attention to the biases that are present in a corpus.",explain:"Correct! Almost all datasets have some form of bias, which can produce negative consequences downstream. Being aware of them helps model builders understand how to address the inherent biases. What else do dataset cards help with?",correct:!0},{text:"It improves the chances that others in the community will use my dataset.",explain:"Correct! A well-written dataset card will tend to lead to higher usage of your precious dataset. What other benefits does it offer?",correct:!0}]}}),z=new f({props:{title:"8. What is semantic search?",local:"8-what-is-semantic-search",headingTag:"h3"}}),D=new p({props:{choices:[{text:"A way to search for exact matches between the words in a query and the documents in a corpus",explain:"This is incorrect -- this type of search is called *lexical search*, and it's what you typically see with traditional search engines."},{text:"A way to search for matching documents by understanding the contextual meaning of a query",explain:"Correct! Semantic search uses embedding vectors to represent queries and documents, and uses a similarity metric to measure the amount of overlap between them. How else might you describe it?",correct:!0},{text:"A way to improve search accuracy",explain:"Correct! Semantic search engines can capture the intent of a query much better than keyword matching and typically retrieve documents with higher precision. But this isn't the only right answer - what else does semantic search provide?",correct:!0}]}}),j=new f({props:{title:"9. For asymmetric semantic search, you usually have:",local:"9-for-asymmetric-semantic-search-you-usually-have",headingTag:"h3"}}),Y=new p({props:{choices:[{text:"A short query and a longer paragraph that answers the query",explain:"Correct!",correct:!0},{text:"Queries and paragraphs that are of about the same length",explain:"This is actually an example of symmetric semantic search -- try again!"},{text:"A long query and a shorter paragraph that answers the query",explain:"This is incorrect -- try again!"}]}}),B=new f({props:{title:"10. Can I use 🤗 Datasets to load data for use in other domains, like speech processing?",local:"10-can-i-use--datasets-to-load-data-for-use-in-other-domains-like-speech-processing",headingTag:"h3"}}),F=new p({props:{choices:[{text:"No",explain:"This is incorrect -- 🤗 Datasets currently supports tabular data, audio, and computer vision. Check out the <a href='https://huggingface.co/datasets/mnist'>MNIST dataset</a> on the Hub for a computer vision example."},{text:"Yes",explain:"Correct! Check out the exciting developments with speech and vision in the 🤗 Transformers library to see how 🤗 Datasets is used in these domains.",correct:!0}]}}),H=new Be({props:{source:"https://github.com/huggingface/course/blob/main/chapters/en/chapter5/8.mdx"}}),{c(){d=S("meta"),L=o(),Z=S("p"),N=o(),i(u.$$.fragment),X=o(),i($.$$.fragment),Q=o(),g=S("p"),g.textContent=qe,V=o(),w=S("p"),w.textContent=ke,K=o(),i(y.$$.fragment),O=o(),i(x.$$.fragment),ee=o(),i(b.$$.fragment),te=o(),i(T.$$.fragment),ae=o(),v=S("p"),v.innerHTML=Ue,se=o(),i(C.$$.fragment),oe=o(),i(_.$$.fragment),ne=o(),i(q.$$.fragment),ie=o(),i(k.$$.fragment),re=o(),i(U.$$.fragment),le=o(),i(M.$$.fragment),he=o(),i(J.$$.fragment),me=o(),i(W.$$.fragment),ce=o(),i(I.$$.fragment),fe=o(),i(A.$$.fragment),pe=o(),i(R.$$.fragment),de=o(),i(G.$$.fragment),ue=o(),i(z.$$.fragment),$e=o(),i(D.$$.fragment),ge=o(),i(j.$$.fragment),we=o(),i(Y.$$.fragment),ye=o(),i(B.$$.fragment),xe=o(),i(F.$$.fragment),be=o(),i(H.$$.fragment),Te=o(),E=S("p"),this.h()},l(e){const t=De("svelte-u9bgzb",document.head);d=P(t,"META",{name:!0,content:!0}),t.forEach(a),L=n(e),Z=P(e,"P",{}),Me(Z).forEach(a),N=n(e),r(u.$$.fragment,e),X=n(e),r($.$$.fragment,e),Q=n(e),g=P(e,"P",{"data-svelte-h":!0}),Ce(g)!=="svelte-bcp370"&&(g.textContent=qe),V=n(e),w=P(e,"P",{"data-svelte-h":!0}),Ce(w)!=="svelte-1767byc"&&(w.textContent=ke),K=n(e),r(y.$$.fragment,e),O=n(e),r(x.$$.fragment,e),ee=n(e),r(b.$$.fragment,e),te=n(e),r(T.$$.fragment,e),ae=n(e),v=P(e,"P",{"data-svelte-h":!0}),Ce(v)!=="svelte-x04233"&&(v.innerHTML=Ue),se=n(e),r(C.$$.fragment,e),oe=n(e),r(_.$$.fragment,e),ne=n(e),r(q.$$.fragment,e),ie=n(e),r(k.$$.fragment,e),re=n(e),r(U.$$.fragment,e),le=n(e),r(M.$$.fragment,e),he=n(e),r(J.$$.fragment,e),me=n(e),r(W.$$.fragment,e),ce=n(e),r(I.$$.fragment,e),fe=n(e),r(A.$$.fragment,e),pe=n(e),r(R.$$.fragment,e),de=n(e),r(G.$$.fragment,e),ue=n(e),r(z.$$.fragment,e),$e=n(e),r(D.$$.fragment,e),ge=n(e),r(j.$$.fragment,e),we=n(e),r(Y.$$.fragment,e),ye=n(e),r(B.$$.fragment,e),xe=n(e),r(F.$$.fragment,e),be=n(e),r(H.$$.fragment,e),Te=n(e),E=P(e,"P",{}),Me(E).forEach(a),this.h()},h(){Je(d,"name","hf:doc:metadata"),Je(d,"content",He)},m(e,t){je(document.head,d),s(e,L,t),s(e,Z,t),s(e,N,t),l(u,e,t),s(e,X,t),l($,e,t),s(e,Q,t),s(e,g,t),s(e,V,t),s(e,w,t),s(e,K,t),l(y,e,t),s(e,O,t),l(x,e,t),s(e,ee,t),l(b,e,t),s(e,te,t),l(T,e,t),s(e,ae,t),s(e,v,t),s(e,se,t),l(C,e,t),s(e,oe,t),l(_,e,t),s(e,ne,t),l(q,e,t),s(e,ie,t),l(k,e,t),s(e,re,t),l(U,e,t),s(e,le,t),l(M,e,t),s(e,he,t),l(J,e,t),s(e,me,t),l(W,e,t),s(e,ce,t),l(I,e,t),s(e,fe,t),l(A,e,t),s(e,pe,t),l(R,e,t),s(e,de,t),l(G,e,t),s(e,ue,t),l(z,e,t),s(e,$e,t),l(D,e,t),s(e,ge,t),l(j,e,t),s(e,we,t),l(Y,e,t),s(e,ye,t),l(B,e,t),s(e,xe,t),l(F,e,t),s(e,be,t),l(H,e,t),s(e,Te,t),s(e,E,t),ve=!0},p:Ae,i(e){ve||(h(u.$$.fragment,e),h($.$$.fragment,e),h(y.$$.fragment,e),h(x.$$.fragment,e),h(b.$$.fragment,e),h(T.$$.fragment,e),h(C.$$.fragment,e),h(_.$$.fragment,e),h(q.$$.fragment,e),h(k.$$.fragment,e),h(U.$$.fragment,e),h(M.$$.fragment,e),h(J.$$.fragment,e),h(W.$$.fragment,e),h(I.$$.fragment,e),h(A.$$.fragment,e),h(R.$$.fragment,e),h(G.$$.fragment,e),h(z.$$.fragment,e),h(D.$$.fragment,e),h(j.$$.fragment,e),h(Y.$$.fragment,e),h(B.$$.fragment,e),h(F.$$.fragment,e),h(H.$$.fragment,e),ve=!0)},o(e){m(u.$$.fragment,e),m($.$$.fragment,e),m(y.$$.fragment,e),m(x.$$.fragment,e),m(b.$$.fragment,e),m(T.$$.fragment,e),m(C.$$.fragment,e),m(_.$$.fragment,e),m(q.$$.fragment,e),m(k.$$.fragment,e),m(U.$$.fragment,e),m(M.$$.fragment,e),m(J.$$.fragment,e),m(W.$$.fragment,e),m(I.$$.fragment,e),m(A.$$.fragment,e),m(R.$$.fragment,e),m(G.$$.fragment,e),m(z.$$.fragment,e),m(D.$$.fragment,e),m(j.$$.fragment,e),m(Y.$$.fragment,e),m(B.$$.fragment,e),m(F.$$.fragment,e),m(H.$$.fragment,e),ve=!1},d(e){e&&(a(L),a(Z),a(N),a(X),a(Q),a(g),a(V),a(w),a(K),a(O),a(ee),a(te),a(ae),a(v),a(se),a(oe),a(ne),a(ie),a(re),a(le),a(he),a(me),a(ce),a(fe),a(pe),a(de),a(ue),a($e),a(ge),a(we),a(ye),a(xe),a(be),a(Te),a(E)),a(d),c(u,e),c($,e),c(y,e),c(x,e),c(b,e),c(T,e),c(C,e),c(_,e),c(q,e),c(k,e),c(U,e),c(M,e),c(J,e),c(W,e),c(I,e),c(A,e),c(R,e),c(G,e),c(z,e),c(D,e),c(j,e),c(Y,e),c(B,e),c(F,e),c(H,e)}}}const He='{"title":"End-of-chapter quiz","local":"end-of-chapter-quiz","sections":[{"title":"1. The load_dataset() function in 🤗 Datasets allows you to load a dataset from which of the following locations?","local":"1-the-loaddataset-function-in--datasets-allows-you-to-load-a-dataset-from-which-of-the-following-locations","sections":[],"depth":3},{"title":"2. Suppose you load one of the GLUE tasks as follows:","local":"2-suppose-you-load-one-of-the-glue-tasks-as-follows","sections":[],"depth":3},{"title":"3. Suppose you have a dataset about household pets called pets_dataset , which has a name column that denotes the name of each pet. Which of the following approaches would allow you to filter the dataset for all pets whose names start with the letter “L”?","local":"3-suppose-you-have-a-dataset-about-household-pets-called-petsdataset--which-has-a-name-column-that-denotes-the-name-of-each-pet-which-of-the-following-approaches-would-allow-you-to-filter-the-dataset-for-all-pets-whose-names-start-with-the-letter-l","sections":[],"depth":3},{"title":"4. What is memory mapping?","local":"4-what-is-memory-mapping","sections":[],"depth":3},{"title":"5. Which of the following are the main benefits of memory mapping?","local":"5-which-of-the-following-are-the-main-benefits-of-memory-mapping","sections":[],"depth":3},{"title":"6. Why does the following code fail?","local":"6-why-does-the-following-code-fail","sections":[],"depth":3},{"title":"7. Which of the following are the main benefits of creating a dataset card?","local":"7-which-of-the-following-are-the-main-benefits-of-creating-a-dataset-card","sections":[],"depth":3},{"title":"8. What is semantic search?","local":"8-what-is-semantic-search","sections":[],"depth":3},{"title":"9. For asymmetric semantic search, you usually have:","local":"9-for-asymmetric-semantic-search-you-usually-have","sections":[],"depth":3},{"title":"10. Can I use 🤗 Datasets to load data for use in other domains, like speech processing?","local":"10-can-i-use--datasets-to-load-data-for-use-in-other-domains-like-speech-processing","sections":[],"depth":3}],"depth":1}';function Se(_e){return Re(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qe extends Ge{constructor(d){super(),ze(this,d,Se,Fe,Ie,{})}}export{Qe as component}; | |
Xet Storage Details
- Size:
- 17.3 kB
- Xet hash:
- c1ce6f8826165a10c1e832e2658953b7922bc67dc49e9138fd8dade1b93899fc
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.