Relation classification (RC) is a fundamental task to building knowledge graphs and describing semantic formalization. It aims to classify a relation between the head and the tail entities in a sentence. The existing RC method mainly adopts the distant supervision (DS) scheme. However, DS still has the problem of long-tail and suffers from data sparsity. Recently, few-shot learning (FSL) has attracted people’s attention. It solves the long-tail problem by learning from few-shot samples. The prototypical networks have a better effect on FSL, which classifies a relation by distance. However, the prototypical networks and their related variants did not consider the critical role of entity words. In addition, not all sentences in support set equally contributed to classifying relations. Furthermore, an entity pair in a sentence may have true and confusing relations, which is difficult for the RC model to distinguish them. A new context encoder BERT_FE is proposed to address those problems, which uses the BERT model as pre-training and fuses the information of head and tail entities by entity word-level attention (WLA). At the same time, the sentence-level attention (SLA) is proposed to give more weight to sentences of the support set similar to the query instance and improve the classification accuracy. A confusing loss function (CLF) is designed to enhance the model’s ability to distinguish between true and confusing relations. The experiment results demonstrate that our proposed model (HACLF) is better than several baseline models.