Graph embedding models, also known as network representation models, have been tried to be applied to community detection tasks. However, most existing graph embedding models are not specially designed for community detection tasks and thus may be incapable of revealing the community structures in networks well. To fill this gap, this paper proposes two novel graph embedding models, GEMod and GEMap, which are specially designed for community detection. The proposed methods try to optimize the modified modularity and two-level coding length while learning the nodes embedding, so that the learned nodes embedding can be better applied to detect community structures in networks. Experimental results show that the algorithms proposed are superior or comparable to other community detection algorithms based on graph embedding models. Besides, the nodes embedding generated by GEMod and GEMap are generally more compact and separable, which means that they are more suitable for clustering tasks.