-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Models do not receive prompt_type or task_name #1491
Comments
Can you provide code to check? |
Sure. from mteb.encoder_interface import PromptType
import mteb
from mteb import MTEB
import numpy as np
class CustomModel:
def encode(
self,
sentences: list[str],
task_name: str,
prompt_type: PromptType | None = None,
**kwargs,
) -> np.ndarray:
"""Encodes the given sentences using the encoder.
Args:
sentences: The sentences to encode.
task_name: The name of the task.
prompt_type: The prompt type to use.
**kwargs: Additional arguments to pass to the encoder.
Returns:
The encoded sentences.
"""
pass
model = CustomModel()
tasks = [mteb.get_task("Banking77Classification") ] # README doesnt turn the tasks into a list, else it raises an error if get_task is used
evaluation = MTEB(tasks=tasks)
evaluation.run(model) It raises:
Printing the inputs of encode with: class CustomModel:
def encode(self, sentences, *inputs, **kwargs):
print(f'inputs: {inputs}')
print(f'kwargs: {kwargs}') outputs:
There might be some other variable that is not being forwarded. |
This is correct because |
Right now neither task_name nor prompt_type is passed to CustomModels, I did create a pull request, but sent task name as a keyword argument because any This is what I understand that was the expected behavior, sorry if I am misunderstanding something. |
You need to inherit custom model from Wrapper class like: import mteb
from mteb.encoder_interface import PromptType
import numpy as np
from mteb.models.wrapper import Wrapper
class CustomModel(Wrapper):
def encode(
self,
sentences: list[str],
task_name: str,
prompt_type: PromptType | None = None,
**kwargs,
) -> np.ndarray:
... I'll update Readme to make it more relevant. Thank you for report! |
Ok, Thanks! |
Specifically SentenceTransformerWrapper (from mteb/models/sentence_transformer_wrapper.py) does not forward these variables to Custom Model encode.
The text was updated successfully, but these errors were encountered: