What's the correct objective function for cosine similarity of two vectors to be 1 or 0?
There are a wide variety of loss metrics to compare two vectors (e.g., Triplet loss, Lifted Structure Loss, N-Pair loss, and Angular Loss).

Cosine distance (1-cosine similarity) can be used. Typically, a loss metrics needs to be minimized so distances metrics should be used.