Skip to content

A starter kit for embeddings creation and vector search with Python and MongoDB.

License

Notifications You must be signed in to change notification settings

woltapp/mongo-vector-embeddings-helsinki-python-meetup-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vector Embeddings Demo

A starter kit for embeddings creation and vector search with Python and MongoDB.

Getting started

  • Clone this repository
  • Requirements:
  • Create a virtual environment and install the dependencies
poetry install
  • Activate the virtual environment
poetry shell

For embeddings creation and vector search you will also need the following env variables:

  • OPENAI_API_KEY:
  • MONGO_DEMO_URI:
    • A MongoDB connection string in the following format:
      mongodb+srv://username:password@cluster0.example.mongodb.net/database?retryWrites=true&w=majority
      (you might also need to add &tls=true&tlsAllowInvalidCertificates=true)

Getting and storing embeddings

Use the command make create_and_store_embeddings items_path=<path_to_file> to create and store embeddings for the demo data that is provided. Use items/demo_items.csv as items_path if you want to compute the embeddings from the provided dataset. Note that this option takes several hours to run, and you will be charged according to OpenAI's pricing. There is also a smaller dataset with precomputed embeddings. Use items/demo_items_with_embeddings.csv if you only want to store those to your database.

Creating indexes

You can find the commands for creating the necessary indexes in the mongo.ipynb file.

Trying it out

demo.ipynb contains several commands for performing and visualizing vector search. Note that using the get_text_embedding function uses the OpenAI API and is not free.

About

A starter kit for embeddings creation and vector search with Python and MongoDB.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published