Storm Austen and Storm Boelo parked themselves over the weekend, so going outside was off the table. Rather than stare at the rain, I sat down and built a small RAG and embeddings experiment start to finish, just to watch each piece work with my own data.
This isn’t a tutorial — I’m not going to teach you RAG from first principles. I just want to walk you through what I actually did, step by step, and show you why it all makes sense once you see the picture at the end. There’s an interactive chart of around four thousand cars further down that you can spin around, which is the payoff.
The dataset I started with
I grabbed a dataset of used-car listings — just over four thousand real cars, each with a make, model, year, mileage, engine, price and so on. Step one was simply loading the whole CSV:
df = pd.read_csv("knowledge-base/cars/used_cars.csv")
print(f"Loaded {len(df):,} rows") # Loaded 4,009 rows
Turning each row into a document
Next I turned every row into a short, readable blurb — one document per car. I kept it plain text on purpose, the way you’d actually describe the car to someone:
def row_to_text(row):
parts = [
f"Brand: {row.get('brand', '')}",
f"Model: {row.get('model', '')}",
f"Year: {row.get('model_year', '')}",
f"Mileage: {row.get('milage', '')}",
f"Fuel type: {row.get('fuel_type', '')}",
f"Engine: {row.get('engine', '')}",
f"Transmission: {row.get('transmission', '')}",
f"Price: {row.get('price', '')}",
]
return "\n".join(str(p) for p in parts)
So each car ends up looking like this:
Brand: BMW
Model: X5 xDrive40i
Year: 2020
Mileage: 4,880 mi.
Fuel type: Gasoline
Engine: 3.0 Liter Turbo
Transmission: Automatic
Price: $52,990
Embedding them and dropping them into a vector store
Then I ran each blurb through a free, lightweight embedding model
(all-MiniLM-L6-v2) and stored the results in a Chroma vector database. The
embedding step is where each car’s text becomes a list of numbers — I didn’t
have to do anything clever, Chroma handles the embedding and storage in one go:
embeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
vectorstore = Chroma.from_documents(documents=documents, embedding=embeddings,
persist_directory="vector_db_cars")
When I peeked at what landed in the store, it reported:
4,009 vectors with 384 dimensions.
Which just means: just over four thousand cars, each turned into a list of 384 numbers. That “384” is simply how long this particular model’s number-lists are. Fine — but you can’t eyeball 384 numbers per car to see if anything sensible happened, so I needed a way to look at it.
Squashing 384 numbers down so I could plot them
Here’s the catch: those 384 numbers live in 384-dimensional space, and we humans simply can’t picture anything beyond three dimensions. We’re wired for a 3D world — a flat drawing (2D) or a box of space (3D) is as far as our intuition stretches. Four dimensions? Three hundred and eighty-four? Our brains just don’t have a handle to grab.
So to actually see what the embeddings were doing, I had to translate them down into something we can look at — 2D first, then 3D. I used t-SNE to shrink each car’s 384 numbers down to just two (and later three), while keeping things that were close in the full version close in the shrunk version. You lose a little detail in the squash, but the arrangement — what sits near what — survives, and that’s the part I wanted to eyeball:
tsne = TSNE(n_components=2, random_state=42)
reduced_2d = tsne.fit_transform(vectors) # 384 numbers -> 2
Plotting it — the 2D view
Then I plotted all 4,009 cars, one dot each, coloured by brand. This is the live chart straight out of my notebook — hover a dot to see the actual car, and use the dropdown top-right (or click a brand in the legend) to isolate one brand.
Here’s the part that made the whole exercise worth it: the same-colour dots clumped together on their own. I never told the code what a “brand” is or where to put the BMWs — it grouped them purely from the text of each blurb. Similar cars read similarly, so they got similar numbers, so they landed near each other.
The 3D view — same thing, more room
Squashing all the way down to two numbers is a bit brutal and some clumps pile on top of each other, so I ran t-SNE again for three numbers instead:
tsne = TSNE(n_components=3, random_state=42)
reduced_3d = tsne.fit_transform(vectors) # 384 numbers -> 3
Same 4,009 cars, now you can drag to rotate, scroll to zoom, hover for details, and filter to one brand with the dropdown. Give it a spin:
Rotating it, a few things jump out:
- Every dot is a real listing, placed purely by the meaning of its blurb.
- Same-colour dots stick together — the grouping is entirely self-organised.
- Related brands sit near each other — luxury names drift into one neighbourhood, everyday ones into another.
- The extra dimension helps — clusters that overlapped in 2D pull apart once you can move around them.
The bit that ties it together
The charts are pretty, but the last thing I ran is what shows the point of it all. I handed the vector store a plain-English query and asked for the five closest listings:
query = "a reliable low-mileage hybrid SUV with no accidents"
results = vectorstore.similarity_search(query, k=5)
And back came exactly what you’d hope — clean, low-mileage hybrid SUVs — even though not one of them literally contains the word “reliable.” It matched on meaning, not keywords, because the query got turned into numbers the same way the cars did, and the search just found the nearest dots.
That’s the whole loop, and seeing it work across all four thousand cars was oddly satisfying: text in, numbers out, similar things land together, and a vague question finds the right answers by sheer proximity. Not a bad way to spend a rained-out weekend.
Where this came from
The used-car data is the public Used Car Price Prediction dataset on Kaggle — thanks to its author for sharing it freely.
And a proper thank-you to Ed Donner, whose LLM Engineering course is where I first built a pipeline like this.