Skip to content

Commit d9a1323

Browse files
authored
Final QA (#457)
1 parent 5102449 commit d9a1323

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

embeddings-and-vector-databases-with-chromadb/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Embeddings and Vector Databases With ChromaDB
22

3-
Supporting code for the Real Python tutorial [Embeddings and Vector Databases With ChromaDB](https://realpython.com/embeddings-and-vector-databases-with-chromadb/).
3+
Supporting code for the Real Python tutorial [Embeddings and Vector Databases With ChromaDB](https://realpython.com/chromadb-vector-database/).
44

55
To run the code in this tutorial, you should have `numpy`, `spacy`, `sentence-transformers`, `chromadb`, `polars`, `more-itertools`, and `openai` installed in your environment.
66

embeddings-and-vector-databases-with-chromadb/car_data_etl.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,4 @@ def prepare_car_reviews_data(
5757
documents = car_review_db_data["Review"].to_list()
5858
metadatas = car_review_db_data.drop("Review").to_dicts()
5959

60-
chroma_data = {"ids": ids, "documents": documents, "metadatas": metadatas}
61-
62-
return chroma_data
60+
return {"ids": ids, "documents": documents, "metadatas": metadatas}

embeddings-and-vector-databases-with-chromadb/chroma_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
def build_chroma_collection(
99
chroma_path: pathlib.Path,
1010
collection_name: str,
11-
embbeding_func_name: str,
11+
embedding_func_name: str,
1212
ids: list[str],
1313
documents: list[str],
1414
metadatas: list[dict],
@@ -19,7 +19,7 @@ def build_chroma_collection(
1919
chroma_client = chromadb.PersistentClient(chroma_path)
2020

2121
embedding_func = embedding_functions.SentenceTransformerEmbeddingFunction(
22-
model_name=embbeding_func_name
22+
model_name=embedding_func_name
2323
)
2424

2525
collection = chroma_client.create_collection(

embeddings-and-vector-databases-with-chromadb/cosine_similarity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
def compute_cosine_similarity(u: np.ndarray, v: np.ndarray) -> float:
55
"""Compute the cosine similarity between two vectors"""
66

7-
return u.dot(v) / (np.linalg.norm(u) * np.linalg.norm(v))
7+
return (u @ v) / (np.linalg.norm(u) * np.linalg.norm(v))

embeddings-and-vector-databases-with-chromadb/intro_to_vectors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020

2121
# Dot product
2222
print(np.sum(v1 * v2))
23-
print(v1.dot(v3))
23+
print(v1 @ v3)

0 commit comments

Comments
 (0)