API: Language model adapters

For each no-code language model, Foundry provides a default model adapter. This default model adapter provides reasonable default parameters and structure for interacting with the language models. The default language model adapters listed below will correctly route to CPU and GPU devices, depending on availability in the deployment infrastructure.

The model adapter currently in use is viewable on the model submission page in the Modeling Objectives application.

Model submission page in the Modeling Objectives application showing the model adapter in use

Seq2SeqLMModelAdapter

Usage

This model adapter adds support for sequence-to-sequence language models ↗. The adapter generates text based on the provided input text.

Example: The expected input text and its structure depends on the selected model. We highly recommend reading the model details to ensure correct prompt engineering. The flan-t5-large ↗ model, for example, can perform a wide variety of prompts from translation to summarization to question answering.

Example sequence to sequence query in a live sandbox deployment

Model API

  • Input “text”: The text input for the language model to generate the output prediction.
  • Output “prediction”: The text generated by the model.

NerAdapter

Usage

This model adapter adds support for Named Entity Recognition pipelines ↗. The model adapter extracts the entities within the text and returns them in a list.

Example: When sending the text “My name is Max and I live in Germany” to the model through a sandbox or a live deployment, the model recognizes two entities: Max and Germany.

Example named entity recognition query in a live sandbox deployment

Model API

  • Input “text”: The text for which the language model generates the output prediction.
  • Output<list> “prediction”: The models output is a list of dictionaries where each dictionary provides detailed information about the extracted entity. In particular, the dictionary contains:
    • entity: The type of entity the that was recognized.
    • score: The numerical score of the specific entity.
    • index: The index of the entity’s token (for example, an index of 5 means the recognized entity is the fifth token in the input text).
    • word: The string representation of the recognized entity.
    • start: The start index of the recognized entity in the input string.
    • end: The end index of the recognized entity in the input string.

EmbeddingAdapter

Usage

This model adapter calculates the embedding for a given text based on the model's attention mask ↗. This adapter does "mean pooling" and normalization, which aligns with the sentenced-transformers ↗ defaults.

Example:

Example embedding query in a live sandbox deployment

Model API

  • Input “text”: The input text for the embedding model.
  • Output<list> “embedding”: The n-dimensional vector representing the input text.

TextClassificationAdapter

Usage

This model adapter classifies the input text for a predefined set of classes. Common examples for text classification are sentiment or language detection.

Example:

Example of text classification query in a live sandbox deployment

Model API

  • Input “text”: The input text for the language model to generate the output prediction.
  • Output “prediction”: The most likely class.
  • Output<list> “logits”: The logit values for each of the classes.
  • Output<list> “classes”: The classes the model can predict. The order is the same as the order of the logits (for example, the first logit entry corresponds to the first entry in the classes list).

ZeroShotClassificationAdapter

Usage

This model adapter classifies the input text based on a list of classes that are provided at prediction time. This behavior allows the model adapter to classify texts without the need for fine-tuning a language model to a specific use case.

Example: When sending the text “I love to develop new language models” and the candidate labels “Travel”, “Sports”, “Work”, and “Entertainment”, the model will score the labels and rank "Work" as the most likely classification.

Example of ZeroShot classification query in a live sandbox deployment

Model API

  • Input “text”: The input text for the language model to generate the output prediction.
  • Input<list> “candidate_labels”: A list of potential labels for the input text that the model scores.
  • Output “prediction”:
    • sequence: The text used for the zero-shot classification.
    • labels: The candidate labels ordered based on the models score, in descending order.
    • scores: The float number representing the classification score for the candidate labels. The order of the scores matches the order of the labels.