Unable to load model “apple/DCLM-7B” - KeyError: ‘openlm’

#7
by orha - opened

I am trying to load the model "apple/DCLM-7B" using the transformers library, but I am encountering a KeyError: 'openlm' when attempting to load the model. It seems that the model type openlm is not recognized by the current version of the transformers library.

Environment

  • Transformers and Tokenizer versions: transformers-4.43.3 tokenizers-0.19.1
  • Platform: Python 3 Google Compute Engine backend (GPU)
  • Hardware accelerator: A100 GPU
  • Python version: Python 3.10.12

Code Snippet

Here is the code I used to load the model:

# Importing necessary libraries from Hugging Face Transformers
from transformers import AutoModel, AutoTokenizer

# Specifying the model name
model_name = "apple/DCLM-7B"

# Loading the pre-trained model
model = AutoModel.from_pretrained(model_name)

# Loading the corresponding tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_name)

# Example input text
input_text = "Hello, world!"

# Tokenizing the input text
inputs = tokenizer(input_text, return_tensors="pt")

# Getting the model's output
outputs = model(**inputs)

# Print the output
print(outputs)

Error Traceback

Here is the error traceback I received:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/transformers/models/auto/configuration_auto.py in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    981         fn.__doc__ = docstrings
--> 982         return fn
    983 

3 frames
KeyError: 'openlm'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/transformers/models/auto/configuration_auto.py in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    982         return fn
    983 
--> 984     return docstring_decorator
    985 
    986 

ValueError: The checkpoint you are trying to load has model type `openlm` but Transformers does not recognize this architecture. 

This could be because of an issue with the checkpoint, or because your version of Transformers is out of date.

Steps to Reproduce

  1. Install the transformers library: pip install transformers
  2. Run the code snippet provided above to load the model apple/DCLM-7B

Additional Context

I have also tried updating the transformers library to the latest version using pip install --upgrade transformers, but the issue persists.

Apple org

try this:

from open_lm.hf import *
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("apple/DCLM-Baseline-7B")
model = AutoModelForCausalLM.from_pretrained("apple/DCLM-Baseline-7B")

inputs = tokenizer(["Machine learning is"], return_tensors="pt")
gen_kwargs = {"max_new_tokens": 50, "top_p": 0.8, "temperature": 0.8, "do_sample": True, "repetition_penalty": 1.1}
output = model.generate(inputs['input_ids'], **gen_kwargs)
output = tokenizer.decode(output[0].tolist(), skip_special_tokens=True)
print(output)

I got an error in open lm installation

I ran
pip install git+https://github.com/mlfoundations/open_lm.git

Here is the error traceback I received:

Collecting pyyaml>=5.1 (from datasets->open_lm==0.0.34)
Using cached PyYAML-5.4.1.tar.gz (175 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error

IMG_0359.jpeg

What is the chat template for DCLM, and will you support VLLM in the future?

Sign up or log in to comment