A machine learning system for generating and managing Veo video prompts using transformer models, PEFT fine-tuning, and semantic search.
- Prompt Extraction: Fine-tuned Flan-T5 model to extract structured data from raw text
- Semantic Search: FAISS-based vector search using BGE embeddings
- Prompt Composition: AI-powered prompt generation from user intent
- Quality Scoring: Reward model for ranking generated prompts
- REST API: FastAPI endpoints for integration
- N8N Integration: Workflow automation support
veo-prompt-ml/
├── api/ # FastAPI application
├── data/ # Data files and indexes
├── models/ # Trained models
├── n8n/ # N8N workflow files
├── notebooks/ # Jupyter notebooks
├── scripts/ # Training and deployment scripts
├── src/ # Source code
└── requirements.txt # Python dependencies
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtCreate data/raw_prompts.txt with one prompt per line:
neon-lit street market at blue hour, handheld camera, 24fps
sunrise over foggy mountains, dolly shot, cinematic lighting
rainy city streets at night, sodium vapor lamps, gimbal movement
python src/boot_extract.pyThis creates data/prompts_seed.jsonl with structured prompt data.
accelerate configsh scripts/train_all.shOr run individually:
# Train extractor model
accelerate launch src/train_extractor.py
# Build FAISS index
python src/index_faiss.py --build
# Train reward model
python src/train_reward.pysh scripts/run_api.shThe API will be available at http://localhost:8000
curl http://localhost:8000/healthcurl -X POST http://localhost:8000/extract \
-H "Content-Type: application/json" \
-d '{"text": "neon-lit street market at blue hour"}'curl -X POST http://localhost:8000/search \
-H "Content-Type: application/json" \
-d '{"query": "neon lighting", "k": 5}'curl -X POST http://localhost:8000/suggest \
-H "Content-Type: application/json" \
-d '{"intent": "neon rain street market at blue hour", "k": 6, "n": 6}'python src/predict_extractor.py "your raw prompt text here"python src/index_faiss.py --buildpython src/index_faiss.py --search "your search query" --k 8python src/train_reward.pypython src/train_reward.py --score "your prompt text"Import n8n/veo_suggest_flow.json into N8N to create automated workflows.
Note: If not running in Docker, change the host from host.docker.internal:8000 to localhost:8000 in the HTTP Request node.
Use the Jupyter notebook notebooks/quicktest.ipynb for quick testing and experimentation.
The API logs all /suggest calls to data/online_log.jsonl for analysis and future training.
Models are cached in memory using global singletons to avoid reloading on each request.
Build and run with Docker:
docker build -t veo-prompt-ml .
docker run -p 8000:8000 veo-prompt-ml- Model not found: Ensure you've run the training scripts first
- CUDA out of memory: Reduce batch sizes in training scripts
- Import errors: Check that virtual environment is activated
models/extractor/: Required for/extractendpointmodels/reward/: Required for/suggestendpointdata/faiss.index: Required for/searchendpointdata/metas.json: Required for/searchendpoint
MIT License