PITTSBURGH (AP) _ Five actors who returned to Carnegie-Mellon University to take part in a star-studded show pulled out of the fund-raiser Saturday after learning of their alma mater's Defense Department contracts.

''We are from the humanities - our work is to affirm life through our words, our art, our music. We cannot in good conscience participate in any way in technology that might destroy it,'' said Charles Haid of television's ''Hill Street Blues.''

''It's very difficult because I love this college,'' said a teary-eyed Barbara Bosson, a 1969 graduate who appeared on ''Hill Street Blues.'' Her husband, Steve Bochco, also an alumnus, created the Emmy award-winning series.

Haid, who received a bachelor of fine arts degree in 1968, said the five were unaware of the small, private university's $103 million contract with the Defense Department until they arrived in Pittsburgh on Friday to rehearse for Saturday night's show. The university received the contract in 1984 to establish a Software Engineering Institute.

''This isn't just CMU. We wouldn't do this anywhere,'' Haid said at a news conference 8 1/2 hours before the start of the show.

The five actors insisted they never would have agreed to take part in the two-hour variety show at Pittsburgh's Civic Arena had they known about Carnegie-Mellon's ties to the Defense Department. Ten thousand tickets were sold or given away for the event.

''It is not our intention to scuttle the event. It was a decision after hours of soul-searching that we had to make,'' Renee Auberjonois of television's ''Benson,'' a 1962 graduate, told reporters and about 100 cheering, clapping students.

Also pulling out of the program were Robert Foxworth of television's ''Falcon Crest,'' a 1965 graduate, and David L. Lander of ''Laverne and Shirley,'' who attended Carnegie-Mellon in 1965 and 1966.

Carnegie-Mellon spokesman Keith Moore said the program was revamped to account for the actors' absence. The rest of the cast indicated they would go on with the show, he said.

''We're very disappointed, of course. But the university has long stood for graduating students who can make up their own minds. I respect any decision of conscience,'' he said.

Moore said, however, that the actors' protest would not affect the university's acceptance of Defense Department money.

''Half of all basic research in higher education is through Defense Department grants,'' he said. Such research is ''to help all of society, not to maim and kill,'' he said.

Carnegie-Mellon drama alumni began planning the show, titled ''Carnegie Salutes Carnegie,'' about six months ago to celebrate the 150th anniversary of the birth of Andrew Carnegie, the university's founder, and to kick off a $200 million fund-raising drive.

Among those volunteering to perform with students, in addition to the five who pulled out Saturday, were Barbara Feldon, class of 1955; Nancy Marchand of television's ''Lou Grant,'' class of 1949; and Diane Fratantoni of Broadway's ''Cats,'' a 1978 graduate.

Entertainers Jerry Lewis and Andy Williams agreed to help out, even though they never attended Carnegie-Mellon. Actress Ellen Burstyn, who also has no ties to the school, agreed to read a tribute to astronaut Judith Resnik, a 1970 graduate who was killed aboard the space shuttle Challenger.