hf_formatter
langroid/language_models/prompt_formatter/hf_formatter.py
Prompt formatter based on HuggingFace AutoTokenizer.apply_chat_template method
from their Transformers library. It searches the hub for models matching the
specified name, most-downloaded first, and uses the first one whose tokenizer
loads and has a chat template. We assume that all matching models share the
same chat template.
try_import_hf_modules()
¶
Attempts to import the AutoTokenizer class from the transformers package. Returns: The AutoTokenizer class if successful. Raises: ImportError: If the transformers package is not installed.