added utils for cosine sim and finite differences