# [Error] ModernBERT기반 모델 사용할 때 발생하는 오류

## ModernBERT 사용 시 발생하는 오류

MTEB으로 ColBERT 모델 평가를 하다가 아래와 같은 에러가 발생했다..

`TypeError: ModernBertModel.forward() got an unexpected keyword argument 'token_type_ids'` 

해당 에러는 ModernBERT에서 발생하는 에러인데, ModernBERT 구조상 `token_type_ids` 를 리턴하지 않기 때문에 발생하는 에러이다.

Huggingface에서 ModernBERT를 소개하는 글에서 다음과 같이 말한다.

> Note: ModernBERT does not use token type IDs, unlike some earlier BERT models. Most downstream usage is identical to standard BERT models on the Hugging Face Hub, except you can omit the token_type_ids parameter.

따라서 모델을 로드하고 해당 부분을 사용하지 않도록 제거해주어야한다.

### Pylate

```javascript
from pylate import models
model = models.ColBERT(
    model_name_or_path=model_name,
)
model.tokenizer.model_input_names = ["input_ids", "attention_mask"]
```

### Sentence_Transformer

현재까지 테스트했던 모델들 중에서는 에러가 발생하는 경우가 없음.. 에러 발생시 바로 재작성 예정

### MTEB-ColBERTWrapper

`yjoonjang님 코드 참조`` ` 

```javascript
model = ColBERTWrapper(model_name, model_kwargs={"torch_dtype": torch.float32}, device=device)
if hasattr(model.model[0].tokenizer, 'model_max_length'):
  model.model[0].tokenizer.model_input_names = ['input_ids', 'attention_mask']

```

더 확실한 방법은 huggingface model들의 `tokenizer_config.json` 을 확인해보면 알 수 있다. 

---

## Ref

[https://huggingface.co/blog/modernbert](https://huggingface.co/blog/modernbert)

[https://huggingface.co/yjoonjang/colbert-ko-v1.0/discussions/1](https://huggingface.co/yjoonjang/colbert-ko-v1.0/discussions/1)

For the site tree, see the [root Markdown](https://slashpage.com/paperl.md).
