Creating & Ingesting Your Own Embeddings in Weaviate | Vector Databases for Beginners | Part 7

Data Science Dojo · Beginner ·🔍 RAG & Vector Search ·6mo ago

Key Takeaways

Creates and ingests custom embeddings in Weaviate using the Bring Your Own Vectors approach and Hugging Face models

Full Transcript

I wanted to go over how you can create embeddings two different ways with Weaviate. So, I'm going to go over to a notebook over here in Colab. Um the first one we're going to use is bring your own vectors in Weaviate. So, with this notebook, we're going to generate embeddings with modern BERT on Hugging Face here. Um we use this model to generate embeddings and then insert them into Weaviate. So, I've already done some of the stuff up here. I've installed the Transformers library, data sets, and Weaviate. We're going to be using a data set from my colleague Shorten or from my colleague Connor um on archive paper machine learning papers. Um so, I just loaded all that cuz otherwise it would take too long during this. We're going to keep just the title and the abstract columns from this data set. And then we're going to take So, the original data set contained over 100,000 titles and abstracts. But for this demo, we're just going to take a random sample of 100 different papers. So, that's this part just taking a random sample. Um and basically at the end of that, we're going to get a data set of 100 examples. And now we need to create embeddings. And I also did this before. I was hoping to do it during this, but it took too long. So, I'm going to import the sentence Transformers library here. Set my model as the modern BERT base model. And for every example, I'm going to generate a embedding and store it under the im- beddings sort of property dictionary key um for each example. And then I'm just going to map these embeddings into our existing data set. Okay. So, when we do all this, we're going to get a data set changing it to pandas. Really hoping this works. It's always a rough time. Oh, no. I have to run all this again, I think. Oh boy. Okay. Well, we're just going to do all this quickly. >> [laughter] >> And hopefully it won't take too long. Again, we installed the Transformers library. We're going to generate embeddings with the modern BERT model from Hugging Face. We've kept 100 rows of this archive data set. And if we look at the little data set itself, you'll see [snorts] we have the title, we have the abstract, and we have the text, which is a combination of both of those. And then we have our embeddings. Um Right. So, next we're going to actually put this in Weaviate. And to do that, I'm going to use a sandbox from Weaviate Cloud. It's free, which is always good. So, I'm going to create a cluster Oh, so I'm going to go to console. that.weaviate.cloud. I have an account. I'm logged in, hopefully. Yes, I'm logged in. Um if you don't have an account, you can sign up for free. And then you click up you can go to clusters, click on this button right here, create cluster. Going to create a sandbox, and I'm going to name it embedding demo. I'm going to select Europe because I live in Europe, and then I'm going to create. Awesome. So, cluster's being prepared. And what we can do now is we can click on this connect button and we can copy all of our info. So, I'm going to copy the Weaviate URL here. I'm going to bring it back over here. And if you're doing this for real, please store these as environment variables. But for right now, I'll just paste them in there cuz it's fine if you access these. Um okay. We're also going to copy the Weaviate API key here. Bring it back over here as well. Awesome. Um and then we need to connect from here to our cloud. So, I'm going to go back over here. And what's nice about this little button is it already gives you the code. So, I'm going to uh copy this part. Go back over here. I'm going to paste this part. And hopefully when I run this, it'll work. Oh, it might not work because I don't know if it's ready yet. Okay, still being prepared. Give it a second, then. Do do do do. Put some elevator music. >> [laughter] >> Okay, while it's doing that, I'll go a little bit over the next part. So, when that works, we'll have a client is ready. And then we need to actually create our collection within Weaviate to store our vectors that we just made in. So, I imported all the Weaviate stuff up here, and I'm going to define my collection name as bring your own vectors collection, BYOV collection. Um and then this is just if I already have a collection, delete it. So, then I'm going to initialize a collection by client.collections.create client.collections.create. My collection name will be the collection name. And then I have to set a vectorizer config. And we have our own vectors for this one, so we actually want to set the config to none. So, then I'm going to do wvc. config. dot configure. configure.vectorizer. dot none. And this is because we already have our vectors. So, we don't want to actually vectorize anything within here. Is my cluster ready yet? Yeah. Okay. Cluster's ready. Hopefully this should work now. Yeah. So, client is ready. True. And then we can initialize our collection. Nice. Run. Um next thing we're going to do is we're going to insert all our data into this collection. So, I've defined properties here. We have a text property and a title property. Um and then I can insert text, title, and also our embeddings into the collection. So, by using this vector property. And I'm using insert many. And if I run this, [clears throat] it will put all of our data into the collection. If we go back into the cloud, reload this. Hm. Reload this again. Um go to the explorer. And our embedding demo and our bring your own vector collection, we can actually see all of our stuff that's in Weaviate already. So, we have our vectors here. Nice. We have our text, we have our title. Great. So, everything looks good in here.

Original Description

In part 7, we walk through a full hands-on workflow for generating embeddings externally and importing them into Weaviate using the Bring Your Own Vectors approach. In this section, we're going to go over: - Generating embeddings using a Hugging Face model (ModernBERT) in Google Colab - Sampling and preparing a large dataset for embedding generation - Converting text (titles + abstracts) into vector embeddings using Sentence Transformers - Setting up a free Weaviate Cloud sandbox cluster - Connecting Colab to Weaviate using API keys and cluster endpoints - Creating a custom collection with vectorizer disabled for external embeddings - Inserting embeddings, metadata, and text into Weaviate at scale This workflow shows how easy it is to bring your own vectors into Weaviate and manage your embeddings end-to-end—giving you full control over vector generation, storage, and retrieval. #EmbeddingGeneration #Weaviate #APIIntegration #SentenceTransformers #GoogleColab . . . Learn data science, AI, and machine learning through our hands-on training programs: https://www.youtube.com/@Datasciencedojo/courses Check our community webinars in this playlist: https://www.youtube.com/playlist?list=PL8eNk_zTBST-EBv2LDSW9Wx_V4Gy5OPFT Check our latest Future of Data and AI Conference: https://www.youtube.com/playlist?list=PL8eNk_zTBST9Wkc6-bczfbClBbSKnT2nI Subscribe to our newsletter for data science content & infographics: https://datasciencedojo.com/newsletter/ Love podcasts? Check out our Future of Data and AI Podcast with industry-expert guests: https://www.youtube.com/playlist?list=PL8eNk_zTBST_jMlmiokwBVfS_BqbAt0z2
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Data Science Dojo · Data Science Dojo · 0 of 60

← Previous Next →
1 Feature Engineering and Predictive Modeling | Data Analytics with R and Azure ML | Community Webinar
Feature Engineering and Predictive Modeling | Data Analytics with R and Azure ML | Community Webinar
Data Science Dojo
2 Data Exploration and Visualization | Beginning Azure ML | Part 3
Data Exploration and Visualization | Beginning Azure ML | Part 3
Data Science Dojo
3 Reading External Data Sources | Beginning Azure ML | Part 2
Reading External Data Sources | Beginning Azure ML | Part 2
Data Science Dojo
4 Importing Data, Accessing, & Creating a New Experiment | Beginning Azure ML | Part 1
Importing Data, Accessing, & Creating a New Experiment | Beginning Azure ML | Part 1
Data Science Dojo
5 Casting Columns & Renaming Columns | Beginning Azure ML | Part 4
Casting Columns & Renaming Columns | Beginning Azure ML | Part 4
Data Science Dojo
6 Scrub Missing Values & Project Columns | Beginning Azure ML | Part 5
Scrub Missing Values & Project Columns | Beginning Azure ML | Part 5
Data Science Dojo
7 Feature Engineering & R Script | Beginning Azure ML | Part 6
Feature Engineering & R Script | Beginning Azure ML | Part 6
Data Science Dojo
8 Building Your First Model | Beginning Azure ML |  Part 7
Building Your First Model | Beginning Azure ML | Part 7
Data Science Dojo
9 Run and Fine-Tune Multiple Models | Beginning Azure ML | Part 8
Run and Fine-Tune Multiple Models | Beginning Azure ML | Part 8
Data Science Dojo
10 Deploying Your First Predictive Model As a Web Service | Beginning Azure ML | Part 9
Deploying Your First Predictive Model As a Web Service | Beginning Azure ML | Part 9
Data Science Dojo
11 Using R API to Obtain Predictions From Your Web Service Beginning Azure ML | Part 10
Using R API to Obtain Predictions From Your Web Service Beginning Azure ML | Part 10
Data Science Dojo
12 Using Python API to Obtain Predictions From Your Web Service | Beginning Azure ML | Part 11
Using Python API to Obtain Predictions From Your Web Service | Beginning Azure ML | Part 11
Data Science Dojo
13 Twitter Sentiment Analysis | Natural Language Processing | Community Webinar
Twitter Sentiment Analysis | Natural Language Processing | Community Webinar
Data Science Dojo
14 Listening to the Melody of the Universe (LIGO Gravitational Waves Presentation) | Community Webinar
Listening to the Melody of the Universe (LIGO Gravitational Waves Presentation) | Community Webinar
Data Science Dojo
15 David Wechsler on the Impact of Data Science Bootcamp
David Wechsler on the Impact of Data Science Bootcamp
Data Science Dojo
16 Andrew Choi on the Impact of Data Science Bootcamp
Andrew Choi on the Impact of Data Science Bootcamp
Data Science Dojo
17 Microsoft's Software Engineer Shares Her Experience with Data Science Bootcamp
Microsoft's Software Engineer Shares Her Experience with Data Science Bootcamp
Data Science Dojo
18 Michael DAndrea on the Impact of Data Science Bootcamp
Michael DAndrea on the Impact of Data Science Bootcamp
Data Science Dojo
19 Data Driven Decision-Making with Data Science Bootcamp: Artem Kopelev's Revelation
Data Driven Decision-Making with Data Science Bootcamp: Artem Kopelev's Revelation
Data Science Dojo
20 Learn the Fundamentals of Data Science: Srinivas Rao's Experience with Data Science Bootcamp
Learn the Fundamentals of Data Science: Srinivas Rao's Experience with Data Science Bootcamp
Data Science Dojo
21 Re-Learning Data Science with Data Science Bootcamp: Analyst's Revelation
Re-Learning Data Science with Data Science Bootcamp: Analyst's Revelation
Data Science Dojo
22 Scale R to Big Data with Hadoop & Spark | Community Webinar
Scale R to Big Data with Hadoop & Spark | Community Webinar
Data Science Dojo
23 Enhancing Skills with Data Science Bootcamp: Sharon Lane-Getaz's Revelation
Enhancing Skills with Data Science Bootcamp: Sharon Lane-Getaz's Revelation
Data Science Dojo
24 Ryan DeMartino on the Impact of Data Science Bootcamp
Ryan DeMartino on the Impact of Data Science Bootcamp
Data Science Dojo
25 Software Engineer at Microsoft Reveals About His Experience with Data Science Bootcamp
Software Engineer at Microsoft Reveals About His Experience with Data Science Bootcamp
Data Science Dojo
26 Wade Wimer on the Impact of Data Science Bootcamp
Wade Wimer on the Impact of Data Science Bootcamp
Data Science Dojo
27 Analyzing Data with Data Science Bootcamp: Hannah Richta's Revelation
Analyzing Data with Data Science Bootcamp: Hannah Richta's Revelation
Data Science Dojo
28 Applying Data Science Skills to The Current Role with Bootcamp: Marcos Lacayo's Revelation
Applying Data Science Skills to The Current Role with Bootcamp: Marcos Lacayo's Revelation
Data Science Dojo
29 Lance Milner on the Impact of Data Science Bootcamp
Lance Milner on the Impact of Data Science Bootcamp
Data Science Dojo
30 Deloitte's Data Scientist Revelation: Learning Predictive Analytics with Data Science Bootcamp
Deloitte's Data Scientist Revelation: Learning Predictive Analytics with Data Science Bootcamp
Data Science Dojo
31 Rajesh Patil's Experience at Data Science Bootcamp As an Enterprise Architect
Rajesh Patil's Experience at Data Science Bootcamp As an Enterprise Architect
Data Science Dojo
32 Michael Atlin on the Impact of Data Science Bootcamp
Michael Atlin on the Impact of Data Science Bootcamp
Data Science Dojo
33 Amina Tariq's In-Person Experience at Data Science Bootcamp
Amina Tariq's In-Person Experience at Data Science Bootcamp
Data Science Dojo
34 Ceo's Revelation about Data Science Bootcamp
Ceo's Revelation about Data Science Bootcamp
Data Science Dojo
35 Stephen Miller Describes His Experience at Data Science Dojo's Bootcamp
Stephen Miller Describes His Experience at Data Science Dojo's Bootcamp
Data Science Dojo
36 Kevin Hillaker on the Impact of Data Science Bootcamp
Kevin Hillaker on the Impact of Data Science Bootcamp
Data Science Dojo
37 Marko Topalovic's Experience with Data Science Bootcamp
Marko Topalovic's Experience with Data Science Bootcamp
Data Science Dojo
38 Text Analytics With Python, Cognitive Services & PowerBI | Data Analytics | Community Webinar
Text Analytics With Python, Cognitive Services & PowerBI | Data Analytics | Community Webinar
Data Science Dojo
39 Unisys Manager's Revelation: Visualizing Real Time Data with Data Science Bootcamp
Unisys Manager's Revelation: Visualizing Real Time Data with Data Science Bootcamp
Data Science Dojo
40 Learn Data Mining with Data Science Bootcamp: Ryan LaBrie's Revelation
Learn Data Mining with Data Science Bootcamp: Ryan LaBrie's Revelation
Data Science Dojo
41 Vang Xiong on the Impact of Data Science Bootcamp
Vang Xiong on the Impact of Data Science Bootcamp
Data Science Dojo
42 Data Scientist's Experience at Our Data Science Bootcamp
Data Scientist's Experience at Our Data Science Bootcamp
Data Science Dojo
43 Alejandro Wolf Yadlin on the Impact of Data Science Bootcamp
Alejandro Wolf Yadlin on the Impact of Data Science Bootcamp
Data Science Dojo
44 Introduction To Titanic Kaggle Competition | Part 1
Introduction To Titanic Kaggle Competition | Part 1
Data Science Dojo
45 Learning How to Code in R with Data Science Bootcamp: Priscilla Mannuel's Revelation
Learning How to Code in R with Data Science Bootcamp: Priscilla Mannuel's Revelation
Data Science Dojo
46 Andrew Berman On Why Data Science Bootcamp Is Better Fit for Him
Andrew Berman On Why Data Science Bootcamp Is Better Fit for Him
Data Science Dojo
47 How To Do Titanic Kaggle Competition in R | Part 3.1
How To Do Titanic Kaggle Competition in R | Part 3.1
Data Science Dojo
48 How to do the Titanic Kaggle competition in R | Part 3.1
How to do the Titanic Kaggle competition in R | Part 3.1
Data Science Dojo
49 Delve Deeper into Data Science with Data Science Bootcamp
Delve Deeper into Data Science with Data Science Bootcamp
Data Science Dojo
50 Bank of America Data Scientist Reveals His Experience of Data Science Bootcamp
Bank of America Data Scientist Reveals His Experience of Data Science Bootcamp
Data Science Dojo
51 Shaena Montanari on the Impact of Data Science Bootcamp
Shaena Montanari on the Impact of Data Science Bootcamp
Data Science Dojo
52 Types of Sampling | Introduction to Data Mining | Part 12
Types of Sampling | Introduction to Data Mining | Part 12
Data Science Dojo
53 Sampling for Data Selection | Introduction to Data Mining | Part 11
Sampling for Data Selection | Introduction to Data Mining | Part 11
Data Science Dojo
54 Data Aggregation | Introduction to Data Mining | Part 10
Data Aggregation | Introduction to Data Mining | Part 10
Data Science Dojo
55 Data Cleaning | Introduction to Data Mining | Part 9
Data Cleaning | Introduction to Data Mining | Part 9
Data Science Dojo
56 Missing & Duplicated Data | Introduction to Data Mining | Part 8
Missing & Duplicated Data | Introduction to Data Mining | Part 8
Data Science Dojo
57 Data Noise | Introduction to Data Mining | Part 7
Data Noise | Introduction to Data Mining | Part 7
Data Science Dojo
58 Graph and Ordered Data | Introduction to Data Mining | Part 5
Graph and Ordered Data | Introduction to Data Mining | Part 5
Data Science Dojo
59 Document Data & Transaction Data | Introduction to Data Mining | Part 4
Document Data & Transaction Data | Introduction to Data Mining | Part 4
Data Science Dojo
60 Data Quality | Introduction to Data Mining | Part 6
Data Quality | Introduction to Data Mining | Part 6
Data Science Dojo

Related Reads

📰
Optimizing RAG at Scale: Chunking, Retrieval, and the Bayesian Search That Cut Latency 40%
Learn how to optimize RAG at scale using chunking, retrieval, and Bayesian search to reduce latency by 40%
Dev.to · Imus
📰
Add a Freshness Gate Before Your RAG Model Call
Learn to add a freshness gate before your RAG model call to ensure timely and valid responses
Dev.to AI
📰
Optimizing RAG at Scale: Chunking, Retrieval, and the Bayesian Search That Cut Latency 40%
Learn how to optimize RAG at scale by implementing chunking, retrieval, and Bayesian search to reduce latency by 40% and achieve 95% recall@10
Dev.to AI
📰
Optimizing RAG at Scale: Chunking, Retrieval, and the Bayesian Search That Cut Latency 40%
Optimize RAG at scale by implementing chunking, retrieval, and Bayesian search to reduce latency by 40% and achieve 95% recall@10
Dev.to AI
Up next
Build a Chatbot with RAG in 10 minutes | Python, LangChain, OpenAI
Thomas Janssen
Watch →