-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add embeddings output to model builder (#1127)
### Description This PR adds support for outputting the last hidden state in addition to the logits in ONNX models. Users can run their models with ONNX Runtime GenAI and use the generator's `GetOutput` API to obtain the hidden states. C/C++: ```c std::unique_ptr<OgaTensor> embeddings = generator->GetOutput("hidden_states"); ``` C#: ```csharp using var embeddings = generator.GetOutput("hidden_states"); ``` Java: ```java Tensor embeddings = generator.getOutput("hidden_states"); ``` Python: ```python embeddings = generator.get_output("hidden_states") ``` ### Motivation and Context In SLMs and LLMs, the last hidden state represents a model's embeddings for a particular input before the language modeling head is applied. Generating embeddings for a model is a popular task. These embeddings can be used for many scenarios such as text classification, sequence labeling, information retrieval using [retrieval-augmented generation (RAG)](https://en.wikipedia.org/wiki/Retrieval-augmented_generation), and more. This PR helps the following issues: - microsoft/onnxruntime#20969 - #442 - #474 - #713
- Loading branch information
1 parent
76f949d
commit c61aaa6
Showing
5 changed files
with
132 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.