To solve the problem that learners are unable to get personalized instruction, an improved algorithm is proposed for constructing self-organized communities. This algorithm adopts P2P architecture, and strengthens connections between learners with similar interests based on improved Hebbian learning law. In this way, community structure is adjusted automatically, organizing learners with similar interests together eventually. Experimental results show that compared with traditional Hebbian-based P2P algorithm, this algorithm achieves better construction quality and higher construction speed.