Mayor Marion Barry has told a group of community leaders that, whether they like it or not, more group homes will be opening in their neighborhoods in the next two years. The homes will house neglected children, juveniles who have committed petty crimes, prisoners, the mentally retarded and mentally ill, and physically handicapped.

The mayor asked for more citizen cooperation at a meeting last month of leaders from the city's 37 advisory neighborhood commissions (ANCs). He spoke at a time when the city is notifying more and more citizens that a group home will be their neighbor.

There are now 329 city-funded group homes but the number is growing rapidly because of court orders to close down Forest Haven, the city's home for the mentally retarded; the deinstitutionalization of many of the patients at St. Elizabeths Hospital, and the city's decision to close its minimum-security facility for delinquent youths at Cedar Knoll.

The group homes now house more than 9,000 residents.

Ward 1, in the heart of the city, has 62 homes with 977 beds; Ward 2, which is generally Shaw, Southwest and Capitol Hill, has 33 homes with 2,459 beds; Ward 3, located west of Rock Creek Park, has 19 homes with 1,347 beds; Ward 4, which generally runs from North Capitol to 16th Streets, has 76 homes with 701 beds; Ward 5, the Brookland, Woodridge and Eckington neighborhoods, has 46 homes with 714 beds; Ward 6, the rest of Capitol Hill and a pinch of Anacostia, has 41 homes with 1,430 beds; Ward 7, generally the area north of Pennsylvania Avenue SE, has 26 homes with 500 beds; and Ward 8, the area generally south of Pennsylvania Avenue, has 26 homes with 1,064 beds.

The city needs to open 29 more group homes by next July to adhere to its schedule for emptying Forest Haven. A home proposed for Franklin Street NE has aroused some opposition from neighbors who complain that group homes lower neighborhood property values and endanger their children. But it also has some supporters.

In some neighborhoods with existing group homes, some of the citizens who once opposed them are now supporters.

"Those people will never blend in here," shouted Esther MacIntosh after learning at an ANC meeting last month that six mentally retarded men will move into a house at 1653 Franklin St. NE, less than a block from her house.

"I wouldn't let my children go near that house," said Elsie Kyle, a Franklin Street neighbor who attended the meeting.

But Beatrice Vaughn, another Brookland resident, said, "If we were as concerned about some of our so-called neighbors as we are about these mentally retarded men we'd have a much better community." She said she would gladly move next to a group home for the retarded "because they are a pleasure to have as neighbors and I welcome them into the community."

Across town, at a Glover Park-Burleith ANC meeting where new group homes were discussed, a resident said, "I live less than 500 feet from a group home for the mentally retarded and I've heard of no complaints."

A year ago residents from the fashionable Cleveland Park/Woodley Park neighborhoods told a D.C. City Council hearing that the community had become supportive of a group home for the mentally retarded that had opened in their midst to strenuous community opposition in 1981.

In response to citizen complaints, Mayor Barry, in December, established a special office on community-based residential facilities, with a $123,100 budget for the current fiscal year, to coordinate more than 11 city agencies that operate or fund group homes and to act as an information clearinghouse.

The city funds seven different kinds of group homes. Most of those homes are operated by nonprofit organizations. A few group homes are operated by profit-making companies.

The city and federal governments pay to house and feed group home residents.

The types of homes include:

* Adult rehabilitation homes, or halfway houses for prisoners on work-release programs or inmates leaving the prison system. There are 10 of these homes with 354 beds.

* Youth rehabilitation homes for those awaiting trial, or those convicted of misdemeanors or felonies. There are 17 of these homes with 185 beds.

* Community residential homes for the mentally ill, mentally retarded, physically handicapped or the elderly who need supervision. There are 163 of these homes with 1,707 beds.

* Health care facilities for people who are bedridden and require 24-hour care. There are 17 with 3,663 beds.

* Substance abuse homes are detoxification centers for alcoholics and drug abusers. There are seven with 315 beds.

* Emergency shelters for the homeless and battered spouses and children. There are 32 shelters with 2,350 beds.

* Youth residential care homes for neglected or abused children. There are 83 with 618 beds.

Most group homes are single-family homes housing four to 10 people.

"We are not only under law required to furnish these homes, but also from the humane point of view many of these people shouldn't be locked up in big institutions," City Council member Polly Shackleton (D-Ward 3) said last week. Shackleton heads the City Council's Committee on Human Services.

Shackleton recalled a meeting in which she lost her temper with some Ward 3 residents who opposed a home for the mentally retarded in their neighborhood.

"I said, 'If you had a relative who was retarded, would you want them to live down on 14th Street or in a not-so-safe neighborhood?' . . . . A number of people walked out and gave me chilly looks and I thought, 'Well, tough.' I do feel quite strongly about it."