CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-dev-langchain4j--langchain4j-hugging-face

LangChain4j integration library for Hugging Face inference capabilities including chat, language, and embedding models

Overview
Eval results
Files

model-names.mddocs/

Model Name Constants

Pre-defined constants for commonly used Hugging Face model identifiers (deprecated).

Deprecation Notice

This class is deprecated since version 1.7.0-beta13 and scheduled for removal.

Use model ID strings directly or define your own constants.

HuggingFaceModelName Class

package dev.langchain4j.model.huggingface;

@Deprecated(forRemoval = true, since = "1.7.0-beta13")
public final class HuggingFaceModelName {

    public static final String TII_UAE_FALCON_7B_INSTRUCT =
        "tiiuae/falcon-7b-instruct";

    public static final String MICROSOFT_PHI3_MINI_4K_INSTRUCT =
        "microsoft/Phi-3-mini-4k-instruct";

    public static final String SENTENCE_TRANSFORMERS_ALL_MINI_LM_L6_V2 =
        "sentence-transformers/all-MiniLM-L6-v2";
}

Constants

TII_UAE_FALCON_7B_INSTRUCT

public static final String TII_UAE_FALCON_7B_INSTRUCT = "tiiuae/falcon-7b-instruct"

Type: Language/Chat model Size: 7B parameters Use: General-purpose instruction-following

MICROSOFT_PHI3_MINI_4K_INSTRUCT

public static final String MICROSOFT_PHI3_MINI_4K_INSTRUCT = "microsoft/Phi-3-mini-4k-instruct"

Type: Language/Chat model Size: Small efficient model Context: 4K tokens Use: Efficient instruction-following

SENTENCE_TRANSFORMERS_ALL_MINI_LM_L6_V2

public static final String SENTENCE_TRANSFORMERS_ALL_MINI_LM_L6_V2 = "sentence-transformers/all-MiniLM-L6-v2"

Type: Embedding model Dimension: 384 Use: Fast general-purpose embeddings

Usage (Deprecated)

import dev.langchain4j.model.huggingface.HuggingFaceChatModel;
import dev.langchain4j.model.huggingface.HuggingFaceModelName;

HuggingFaceChatModel model = HuggingFaceChatModel.builder()
    .accessToken(apiKey)
    .modelId(HuggingFaceModelName.TII_UAE_FALCON_7B_INSTRUCT)
    .build();

Recommended Alternative

Define your own constants or use strings directly:

// Define constants
public class ModelConstants {
    public static final String FALCON_7B = "tiiuae/falcon-7b-instruct";
    public static final String PHI3_MINI = "microsoft/Phi-3-mini-4k-instruct";
    public static final String MINILM_L6 = "sentence-transformers/all-MiniLM-L6-v2";
}

// Or use strings directly
.modelId("tiiuae/falcon-7b-instruct")

Common Model IDs

Embedding Models

Model IDDimensionSpeedQuality
sentence-transformers/all-MiniLM-L6-v2384FastGood
sentence-transformers/all-mpnet-base-v2768MediumHigh
sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2384FastGood
BAAI/bge-small-en-v1.5384FastGood
BAAI/bge-base-en-v1.5768MediumHigh

Language/Chat Models (for OpenAI module)

Model IDSizeContextUse Case
tiiuae/falcon-7b-instruct7BVariesGeneral purpose
microsoft/Phi-3-mini-4k-instructSmall4KEfficient
mistralai/Mistral-7B-Instruct-v0.27B8KHigh quality
HuggingFaceH4/zephyr-7b-beta7B8KConversational

Finding Models

Browse Hugging Face Hub: https://huggingface.co/models

Filter by:

  • Task: text-generation, feature-extraction, etc.
  • Library: sentence-transformers, transformers
  • Language: en, multilingual, etc.

Use full path: organization/model-name

Related Documentation

  • Embedding Model API - For embeddings
  • Migration Guide - Migrate deprecated classes
  • Configuration Guide - Model configuration

Install with Tessl CLI

npx tessl i tessl/maven-dev-langchain4j--langchain4j-hugging-face

docs

chat-model.md

client-api.md

common-tasks.md

configuration.md

embedding-model.md

error-handling.md

index.md

language-model.md

migration-guide.md

model-names.md

quick-start.md

spi-extensions.md

tile.json