Two security sources told Reuters that the soldiers were on routine patrol in the Damasak area of Borno State on Monday at about 2:00 p.m. (1400 GMT) when they encountered the militants.
According to the sources, a gun battle followed, during which seven soldiers were killed.
Eleven troops reportedly escaped, while 13 others, including a major who was commanding the patrol, were captured.

“The major fought hard, but in the end, he was captured, and his phone was taken by Boko Haram,” one security source said.
The sources said that when troops later returned to their base and tried calling the major’s phone, the call was answered by someone who claimed to be a member of Boko Haram, confirming that the officer and other soldiers were being held by the group.
A military rescue team has since recovered the bodies of the seven soldiers killed in the clash, but the captured troops have not yet been located, the sources added.
A request for comment was not immediately answered by a Nigerian Army spokesperson, according to a Reuters report.
Trending 