Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Open compass VLMEvalKit HFChatModel

From Leeroopedia
Field Value
source VLMEvalKit
domain Vision, API_Integration

Overview

HFChatModel provides a VLMEvalKit wrapper for locally-loaded HuggingFace chat language models.

Description

HFChatModel is a standalone class (not inheriting from BaseAPI) that loads HuggingFace transformer-based chat models locally using AutoModelForCausalLM or model-specific loaders. It supports multiple model families including InternLM, Qwen, ChatGLM, Baichuan, Vicuna, and Llama, with automatic GPU allocation based on model size. The class manages context window detection, tokenization, and chat template formatting.

Usage

Use this wrapper when evaluating pure language models (not vision models) from HuggingFace that follow a chat format, loaded and run locally on GPU.

Code Reference

  • Source: vlmeval/api/hf_chat_model.py, Lines: L1-261
  • Import: from vlmeval.api.hf_chat_model import HFChatModel

Signature:

class HFChatModel:
    def __init__(self, model_path, system_prompt=None, **kwargs): ...
    def generate(self, input, **kwargs): ...

I/O Contract

Direction Description
Inputs input — string prompt or list of string messages for multi-turn conversation
Outputs generate() returns str prediction from the locally loaded model

Usage Examples

# Example instantiation
model = HFChatModel(model_path='internlm/internlm-chat-7b')
response = model.generate(input)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment