Despite the success of emerging online communities, they face a serious practical challenge: the participating agents are strategic, and incentive mechanisms are needed to compel such agents to provide high-quality services. Traditional mechanisms based on pricing and direct reciprocity schemes are not effective in providing incentives in such communities due to their unique features: large number of agents able to perform diverse services, imperfect monitoring of agents' service quality, etc. To compel agents to provide high-quality services, we develop a novel game-theoretic framework for providing incentives using rating-based pricing schemes. In our framework, the service-providing agents are not rated individually; instead, they are divided into separate groups based on their expertise, location, etc., and are rated collectively, as a group. A collective rating is updated for each group based on the quality of service provided by all the agents appertaining to the group. Depending on whether a group of agents collectively contributes a sufficiently high level of services or not, the agents in the group are rewarded or punished through increased or decreased collective rating, which will lead to higher or lower payments they receive in the future. We systematically analyze how the group size and the rating scheme affect the community designer's revenue as well as the social welfare of the agents and, based on this analysis. We design optimal rating protocols and show that these protocols can significantly improve the social welfare of the community as compared to a variety of alternative incentive mechanisms.