The high-quality glass is in high demand in the market, so it is of great importance to inspect the quality of glass quickly and accurately. However, the process of imaging the glass is susceptible to the surrounding environment interference, making it difficult to acquire glass surface data. In addition, glass surface defects are generally small and randomly distributed. To detect glass surface defects efficiently, we employ three imaging methods to obtain glass surface images and construct a glass surface defect dataset (GSDD). At the same time, we propose an unsupervised defect detection method based on the similarity of embedding vectors with the attention mechanism. By introducing an attention mechanism, the network can focus on the features of the defect without being affected by other features, which makes the feature embedding vector more representative. With the well-designed attention mechanism, our method achieves superior performance for both detection task and localization task. On the challenging dataset GSDD, our method achieves a 97.6% AUROC in detection task and a 99.6% AUROC in localization task, outperforming the previous state-of-the-art method.