01 Yt Search

semantic-searchlearnyt-searchsearchpinecone-examples

Open In Colab Open nbviewer

Install prerequisite packages.

[ ]

YouTube Indexing and Queries

In this notebook we will work through an example of indexing and querying the YouTube video transcriptions data. We start by loading the dataset.

[ ]
Using custom data configuration pinecone--yt-transcriptions-b2ddba2bc158a89e
Reusing dataset json (/Users/jamesbriggs/.cache/huggingface/datasets/json/pinecone--yt-transcriptions-b2ddba2bc158a89e/0.0.0/ac0ca5f5289a6cf108e706efcf040422dbbfa8e658dee6a819f20d76bb84d26b)
Dataset({
,    features: ['video_id', 'text', 'start_second', 'end_second', 'url', 'title', 'thumbnail'],
,    num_rows: 11298
,})

Each sample includes video-level information (ID, title, url and thumbnail) and snippet-level information (text, start_second, end_second).

[ ]
{'video_id': 'ZPewmEu7644', 'text': " hi this is Jeff Dean welcome to applications of deep neural networks of Washington University in this video we're going to look at how we can use ganz to generate additional training data for the latest on my a I course and projects click subscribe in the bell next to it to be notified of every new video Dan's have a wide array of uses beyond just the face generation that you", 'start_second': 0, 'end_second': 20, 'url': 'https://www.youtube.com/watch?v=ZPewmEu7644&t=0s', 'title': 'GANS for Semi-Supervised Learning in Keras (7.4)', 'thumbnail': 'https://i.ytimg.com/vi/ZPewmEu7644/maxresdefault.jpg'}

Uploading Documents to Pinecone Index

The next step is indexing this dataset in Pinecone, for this we need a sentence transformer model (to encode the text into embeddings), and a Pinecone index.

We will initialize the sentence transformer first.

[ ]
SentenceTransformer(
,  (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: MPNetModel 
,  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
,  (2): Normalize()
,)

We can see the embedding dimension of 768 above, we will need this when creating our Pinecone index.

[ ]
768

Initializing the Index

Now we need a place to store these embeddings and enable a efficient vector search through them all. To do that we use Pinecone, we can get a free API key and enter it below where we will initialize our connection to Pinecone and create a new index.

[ ]

Now we setup our index specification, this allows us to define the cloud provider and region where we want to deploy our index. You can find a list of all available providers and regions here.

[ ]

Create the index:

[ ]
[ ]

We will index our data in batches of 64, the data we insert into our index will contain records (eg documents) containing a unique document/snippet ID, embedding, and metadata in the format:

	{
    'doc-id',
    [0.0, 0.3, 0.1, ...],
    {'title': '???', 'start_seconds': 12, ...}
}

[ ]
  0%|          | 0/177 [00:00<?, ?it/s]
[ ]
{'dimension': 768,
, 'index_fullness': 0.01,
, 'namespaces': {'': {'vector_count': 11298}}}

Querying

When query we encode our text with the same retriever model and pass it to the Pinecone query endpoint.

[ ]
[ ]
 terms of optimization but what's the algorithm for updating the parameters or updating whatever the state of the network is and then the the last part is the the data set like how do you actually represent the world as it comes into your machine learning system so I think of deep learning as telling us something about what does the model look like and basically to qualify as deep I
---
 any theoretical components any theoretical things that you need to understand about deep learning can be sick later for that link again just watched the word doc file again in that I mentioned the link also the second channel is my channel because deep learning might be complete deep learning playlist that I have created is completely in order okay to the other
---
 under a rock for the last few years you have heard of the deep networks and how they have revolutionised computer vision and kind of the standard classic way of doing this is it's basically a classic supervised learning problem you are giving a network which you can think of as a big black box a pairs of input images and output labels XY pairs okay and this big black box essentially you
---
 do the task at hand. Now deep learning is just a subset of machine learning which takes this idea even a step further and says how can we automatically extract the useful pieces of information needed to inform those future predictions or make a decision And that's what this class is all about teaching algorithms how to learn a task directly from raw data. We want to
---
 algorithm and yelled at everybody in a good way that nobody was answering it correctly everybody knew what the alkyl it was graduate course everybody knew what an algorithm was but they weren't able to answer it well let me ask you in that same spirit what is deep learning I would say deep learning is any kind of machine learning that involves learning parameters of more than one consecutive
---

Delete the Index

If you're done with the index, we delete it to save resources.

[ ]