Implement an in-memory vector index for semantic search. The index should support: adding items with id, embedding vector, and metadata; deleting by id; and querying top-k nearest neighbors by cosine similarity while applying metadata filters such as {"source": "docs", "lang": "en"}. Your implementation should be correct and reasonably efficient for tens of thousands of vectors. After coding, describe one optimization you would make for larger-scale approximate nearest neighbor search.