The group, Homes Not Jails, organized a rally Monday evening before marching to the building at the intersection of Divisadero and O'Farrell streets and occupying it overnight, group spokesman Paul Boden said.
About 25 people initially occupied the building, but that number had dwindled to about eight as police began to enter the building late this morning, Boden said.
A police spokesman was not immediately available to provide details, but an officer at the Police Department's Park Station confirmed that a group of about eight people were taken into custody and would be cited for trespassing.
Boden said his group often uses nonviolent actions to raise awareness of the plight of the city's homeless and the lack of affordable housing in the city.
He said this week's action was also to criticize Kaiser Permanente, which owns the building.
"A health care agency has an empty building, which could easily be used for respite or medically injured adults who are homeless while they figure out what to do with it," Boden said.
He said the group estimates that there are about 30,000 empty housing units in San Francisco, which he said is more than enough to accommodate the roughly 10,000 homeless people living in the city.
"We're sitting on empty buildings while people are living out in the streets," Boden said. "To us, it seems like we need to take a new approach."