IP Library Granted Patent US 11,763,082
Granted Patent B2
US 11,763,082 · App. 17/372,902 · Granted Sep 19, 2023

Accelerating inference of transformer-based models

Inventors: Saurabh Goyal (New Delhi, IN); Anamitra Roy Choudhury (New Delhi, IN); Saurabh Manish Raje (Gurgaon, IN); Venkatesan T. Chakaravarthy (New Delhi, IN); Yogish Sabharwal (Gurgaon, IN); Ashish Verma (Nanuet, NY)
Assignee: International Business Machines Corporation
G06F40/284G06N3/04G06N3/08
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,763,082
App. No.
17/372,902
Granted
Sep 19, 2023
Kind
B2
Abstract

Methods, systems, and computer program products for accelerating inference of transformer-based models are provided herein. A computer-implemented method includes obtaining a machine learning model comprising a plurality of transformer blocks, a task, and a natural language dataset; generating a compressed version of the machine learning model based on the task and the natural language dataset, wherein the generating comprises: obtaining at least one set of tokens, wherein each token in the set corresponds to one of the items in the natural language dataset, identifying and removing one or more redundant output activations of different ones of the plurality of transformer blocks for the at least one set of tokens, and adding one or more input activations corresponding to the one or more removed output activations into the machine learning model at subsequent ones of the plurality of the transformer blocks; and outputting the compressed version of the machine learning model to at least one user.

Claims (51)

1. A computer-implemented method, the method comprising:

obtaining a machine learning model comprising a plurality of transformer blocks, a task, and a natural language dataset;

generating a compressed version of the machine learning model based on the task and the natural language dataset, wherein the generating comprises:

obtaining at least one set of tokens, wherein each token in the set corresponds to one of the items in the natural language dataset,

identifying and removing one or more redundant output activations of different ones of the plurality of transformer blocks for the at least one set of tokens, and

adding one or more input activations corresponding to the one or more removed output activations into the machine learning model at subsequent ones of the plurality of the transformer blocks; and

outputting the compressed version of the machine learning model to at least one user;

wherein the method is carried out by at least one computing device.

2. The computer-implemented method of claim 1 , wherein the generating comprises:

inserting one or more extraction layers into a first subset of the plurality of transformer blocks and one or more introduction layers into a second subset of the plurality of transformer blocks; and

using the one or more extraction layers and the one or more introduction layers to perform the identifying, the removing, and the adding.

3. The computer-implemented method of claim 2 , wherein each of the one or more extraction layers and each of the one or more introduction layers learn a set of retention parameters, wherein the set of retention parameters corresponding to a given one of the layers indicates: (i) whether a given one of the tokens in the at least one set is to be retained and (ii) whether a given one of the tokens in the at least one set is to be processed at the given layer.

4. The computer-implemented method of claim 3 , wherein the set of retention parameters is determined based at least in part on significance scores computed for vector representations corresponding to the at least one set of tokens.

5. The computer-implemented method of claim 4 , wherein the significance score for a given one of the vector representations is computed based on an attention matrix obtained using a self-attention mechanism.

6. The computer-implemented method of claim 2 , wherein the machine learning model, with the one or more inserted extraction layers and the one or more inserted introduction layers, is finetuned using a loss function based at least in part on: (i) a total retention value determined for each of the transformer blocks of the machine learning model and (ii) a depth of each of the transformer blocks.

7. The computer-implemented method of claim 1 , comprising:

determining a set of values for the natural language dataset and the task, wherein the set of values comprise at least one of: frequencies of input sequence lengths of the natural language dataset, a number of classes in the natural language dataset, and a number of samples in each of the classes.

8. The computer-implemented method of claim 7 , wherein the generating is based at least in part on the set of values.

9. The computer-implemented method of claim 1 , wherein the task comprises at least one of:

a classification task;

an entity recognition task;

a text summarization task; and

a sentence embedding task.

10. The computer-implemented method of claim 1 , wherein the natural language dataset comprises a plurality of words.

11. The computer-implemented method of claim 1 , wherein software is provided as a service in a cloud environment.

12. A computer program product comprising a computer readable storage medium having program instructions embodied therewith, the program instructions executable by a computing device to cause the computing device to:

obtain a machine learning model comprising a plurality of transformer blocks, a task, and a natural language dataset;

generate a compressed version of the machine learning model based on the task and the natural language dataset, wherein the generating comprises:

obtaining at least one set of tokens, wherein each token in the set corresponds to one of the items in the natural language dataset,

identifying and removing one or more redundant output activations of different ones of the plurality of transformer blocks for the at least one set of tokens, and

adding one or more input activations corresponding to the one or more removed output activations into the machine learning model at subsequent ones of the plurality of the transformer blocks; and

output the compressed version of the machine learning model to at least one user.

13. The computer program product of claim 12 , wherein the generating comprises:

inserting one or more extraction layers into a first subset of the plurality of transformer blocks and one or more introduction layers into a second subset of the plurality of transformer blocks; and

using the one or more extraction layers and the one or more introduction layers to perform the identifying, the removing, and the adding.

14. The computer program product of claim 13 , wherein each of the one or more extraction layers and each of the one or more introduction layers learn a set of retention parameters, wherein the set of retention parameters corresponding to a given one of the layers indicates: (i) whether a given one of the tokens in the at least one set is to be retained and (ii) whether a given one of the tokens in the at least one set is to be processed at the given layer.

15. The computer program product of claim 14 , wherein the set of retention parameters is determined based at least in part on significance scores computed for vector representations corresponding to the at least one set of tokens.

16. The computer program product of claim 15 , wherein the significance score for a given one of the vector representations is computed based on an attention matrix obtained using a self-attention mechanism.

17. The computer program product of claim 13 , wherein the machine learning model, with the one or more inserted extraction layers and the one or more inserted introduction layers, is finetuned using a loss function based at least in part on: (i) a total retention value determined for each of the transformer blocks of the machine learning model and (ii) a depth of each of the transformers.

18. The computer program product of claim 12 , wherein the program instructions executable by a computing device further cause the computing device to:

determine a set of values for the natural language dataset and the task, wherein the set of values comprise at least one of: frequencies of input sequence lengths of the natural language dataset, a number of classes in the natural language dataset, and a number of samples in each of the classes.

19. The computer program product of claim 18 , wherein the generating is based at least in part on the set of values.

20. A system comprising:

a memory configured to store program instructions;

a processor operatively coupled to the memory to execute the program instructions to:

obtain a machine learning model comprising a plurality of transformer blocks, a task, and a natural language dataset;

generate a compressed version of the machine learning model based on the task and the natural language dataset, wherein the generating comprises:

obtaining at least one set of tokens, wherein each token in the set corresponds to one of the items in the natural language dataset,

identifying and removing one or more redundant output activations of different ones of the plurality of transformer blocks for the at least one set of tokens, and

adding one or more input activations corresponding to the one or more removed output activations into the machine learning model at subsequent ones of the plurality of the transformer blocks; and

output the compressed version of the machine learning model to at least one user.

Assignments (3)
SECURITY INTEREST Recorded Jul 8, 2025
From: ANTHROPIC, PBC
To: MORGAN STANLEY SENIOR FUNDING, INC., AS COLLATERAL AGENT
Reel/Frame 071626/0234 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded May 22, 2025
From: INTERNATIONAL BUSINESS MACHINES CORPORATION
To: ANTHROPIC, PBC
Reel/Frame 071201/0198 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jul 12, 2021
From: GOYAL, SAURABH; CHOUDHURY, ANAMITRA ROY; RAJE, SAURABH MANISH; CHAKARAVARTHY, VENKATESAN T.; SABHARWAL, YOGISH; VERMA, ASHISH
To: INTERNATIONAL BUSINESS MACHINES CORPORATION
Reel/Frame 056824/0056 →
Continuity (1)
Related Publication 20230015895A1 · Jan 19, 2023