This project enriches user-provided screenwriting prompts with semantic context from a movie database.
It leverages sentence-transformers and MongoDB Atlas Vector Search to create intelligent, original story ideas.
- Embeds movie plots using
sentence-transformers/all-MiniLM-L6-v2 - Stores and retrieves vectors from MongoDB Atlas with
$vectorSearch - Automatically builds detailed prompts for story ideation
- Uses the
sample_mflix.moviescollection - Modular scripts for embedding and inference
-
Embedding
Thecreate_embeddings.pyscript:- Connects to MongoDB Atlas
- Embeds the
plotfield from each movie - Stores the embeddings in a new field (
plot_embedding_hf)
-
Inference
Theinference.pyscript:- Takes a user prompt (e.g., "epic medieval war")
- Finds the top 10 semantically similar movies using
$vectorSearch - Generates a rich, structured prompt combining those films with the user's idea
git clone https://github.com/your-repo-name.git
cd your-repo-name
pip install -r requirements.txtCreate a .env file:
USER_NAME=your_mongodb_user
PASSWORD=your_mongodb_password
python create_embeddings.pyThis will iterate over all documents with a plot, generate embeddings, and update them in the MongoDB database.
python inference.pyYou can modify the query at the bottom of inference.py to test other story ideas.
Example:
query = "A cyberpunk heist in a dystopian city controlled by rogue AIs"Main libraries used:
pymongo
sentence-transformers
python-dotenv