-
Couldn't load subscription status.
- Fork 221
Description
Describe the bug
I tried to replicate the genstruct task simple example using a local model instead of inference endpoint.
Got a strange error with jinja2 that I cannot understand.
Seeing the error, I'm not sure if it comes from special Genstruct task (since it asks for 'title' attribute) or if it come from something else.
anyway, obviously as the error says, dict does not have title attribute...
I think it should receive a TypedDict or pydantic model but receives a dict. I'm not sure.
EDIT: Just re-check the error. It seems to come from value = getattr(obj, attribute) that raises UndefinedError when the error handling expect an AttributeError
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ simple_test.py:10 in │
│ <module> │
│ │
│ 7 │ ) │
│ 8 ) │
│ 9 genstruct.load() │
│ ❱ 10 result = next( │
│ 11 │ genstruct.process( │
│ 12 │ │ [ │
│ 13 │ │ │ {"title": "common instruction", "content": "content of the document"}, │
│ │
│ ╭─────────────────────────────── locals ───────────────────────────────╮ │
│ │ genstruct = Genstruct( │ │
│ │ │ exclude_from_signature={ │ │
│ │ │ │ 'gpu_memory_utilization', │ │
│ │ │ │ 'input_batch_size', │ │
│ │ │ │ 'llm_jobs_ids', │ │
│ │ │ │ 'resources', │ │
│ │ │ │ 'llm_offline_batch_generation_block_until_done', │ │
│ │ │ │ 'disable_cuda_device_placement', │ │
│ │ │ │ 'exclude_from_signature', │ │
│ │ │ │ 'type_info' │ │
│ │ │ }, │ │
│ │ │ name='genstruct_0', │ │
│ │ │ resources=StepResources( │ │
│ │ │ │ replicas=1, │ │
│ │ │ │ cpus=None, │ │
│ │ │ │ gpus=None, │ │
│ │ │ │ memory=None, │ │
│ │ │ │ resources=None │ │
│ │ │ ), │ │
│ │ │ input_mappings={}, │ │
│ │ │ output_mappings={}, │ │
│ │ │ use_cache=True, │ │
│ │ │ input_batch_size=50, │ │
│ │ │ llm=TransformersLLM( │ │
│ │ │ │ cuda_devices='auto', │ │
│ │ │ │ disable_cuda_device_placement=False, │ │
│ │ │ │ use_magpie_template=False, │ │
│ │ │ │ magpie_pre_query_template=None, │ │
│ │ │ │ generation_kwargs={}, │ │
│ │ │ │ use_offline_batch_generation=False, │ │
│ │ │ │ offline_batch_generation_block_until_done=None, │ │
│ │ │ │ jobs_ids=None, │ │
│ │ │ │ model='/conteneur/models/genstruct7b_AWQ/', │ │
│ │ │ │ revision='main', │ │
│ │ │ │ torch_dtype='float16', │ │
│ │ │ │ trust_remote_code=False, │ │
│ │ │ │ model_kwargs=None, │ │
│ │ │ │ tokenizer=None, │ │
│ │ │ │ use_fast=True, │ │
│ │ │ │ chat_template=None, │ │
│ │ │ │ device='cuda:0', │ │
│ │ │ │ device_map=None, │ │
│ │ │ │ token=None, │ │
│ │ │ │ structured_output=None │ │
│ │ │ ), │ │
│ │ │ group_generations=False, │ │
│ │ │ add_raw_output=True, │ │
│ │ │ add_raw_input=True, │ │
│ │ │ num_generations=1, │ │
│ │ │ use_default_structured_output=False │ │
│ │ ) │ │
│ ╰──────────────────────────────────────────────────────────────────────╯ │
│ │
│ .venv/lib/python3.12/site-packages/distilabel/steps/tasks/base │
│ .py:451 in process │
│ │
│ 448 │ │ │
│ 449 │ │ # `outputs` is a dict containing the LLM outputs in the `generations` │
│ 450 │ │ # key and the statistics in the `statistics` key │
│ ❱ 451 │ │ outputs = self.llm.generate_outputs( │
│ 452 │ │ │ inputs=formatted_inputs, │
│ 453 │ │ │ num_generations=self.num_generations, # type: ignore │
│ 454 │ │ │ **self.llm.get_generation_kwargs(), # type: ignore │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ formatted_inputs = [ │ │
│ │ │ [ │ │
│ │ │ │ { │ │
│ │ │ │ │ 'role': 'user', │ │
│ │ │ │ │ 'content': '[[[Title]]] common instruction\n[[[Content]]] │ │
│ │ content of the document\n\nThe follow'+104 │ │
│ │ │ │ } │ │
│ │ │ ] │ │
│ │ ] │ │
│ │ inputs = [{'title': 'common instruction', 'content': 'content of the document'}] │ │
│ │ self = Genstruct( │ │
│ │ │ exclude_from_signature={ │ │
│ │ │ │ 'gpu_memory_utilization', │ │
│ │ │ │ 'input_batch_size', │ │
│ │ │ │ 'llm_jobs_ids', │ │
│ │ │ │ 'resources', │ │
│ │ │ │ 'llm_offline_batch_generation_block_until_done', │ │
│ │ │ │ 'disable_cuda_device_placement', │ │
│ │ │ │ 'exclude_from_signature', │ │
│ │ │ │ 'type_info' │ │
│ │ │ }, │ │
│ │ │ name='genstruct_0', │ │
│ │ │ resources=StepResources( │ │
│ │ │ │ replicas=1, │ │
│ │ │ │ cpus=None, │ │
│ │ │ │ gpus=None, │ │
│ │ │ │ memory=None, │ │
│ │ │ │ resources=None │ │
│ │ │ ), │ │
│ │ │ input_mappings={}, │ │
│ │ │ output_mappings={}, │ │
│ │ │ use_cache=True, │ │
│ │ │ input_batch_size=50, │ │
│ │ │ llm=TransformersLLM( │ │
│ │ │ │ cuda_devices='auto', │ │
│ │ │ │ disable_cuda_device_placement=False, │ │
│ │ │ │ use_magpie_template=False, │ │
│ │ │ │ magpie_pre_query_template=None, │ │
│ │ │ │ generation_kwargs={}, │ │
│ │ │ │ use_offline_batch_generation=False, │ │
│ │ │ │ offline_batch_generation_block_until_done=None, │ │
│ │ │ │ jobs_ids=None, │ │
│ │ │ │ model='/conteneur/models/genstruct7b_AWQ/', │ │
│ │ │ │ revision='main', │ │
│ │ │ │ torch_dtype='float16', │ │
│ │ │ │ trust_remote_code=False, │ │
│ │ │ │ model_kwargs=None, │ │
│ │ │ │ tokenizer=None, │ │
│ │ │ │ use_fast=True, │ │
│ │ │ │ chat_template=None, │ │
│ │ │ │ device='cuda:0', │ │
│ │ │ │ device_map=None, │ │
│ │ │ │ token=None, │ │
│ │ │ │ structured_output=None │ │
│ │ │ ), │ │
│ │ │ group_generations=False, │ │
│ │ │ add_raw_output=True, │ │
│ │ │ add_raw_input=True, │ │
│ │ │ num_generations=1, │ │
│ │ │ use_default_structured_output=False │ │
│ │ ) │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ .venv/lib/python3.12/site-packages/distilabel/models/llms/base │
│ .py:188 in generate_outputs │
│ │
│ 185 │ │ │ │ **kwargs, │
│ 186 │ │ │ ) │
│ 187 │ │ │
│ ❱ 188 │ │ return self.generate(inputs=inputs, num_generations=num_generations, **kwargs) │
│ 189 │ │
│ 190 │ def _offline_batch_generate_polling( │
│ 191 │ │ self, │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ inputs = [ │ │
│ │ │ [ │ │
│ │ │ │ { │ │
│ │ │ │ │ 'role': 'user', │ │
│ │ │ │ │ 'content': '[[[Title]]] common instruction\n[[[Content]]] │ │
│ │ content of the document\n\nThe follow'+104 │ │
│ │ │ │ } │ │
│ │ │ ] │ │
│ │ ] │ │
│ │ kwargs = {} │ │
│ │ num_generations = 1 │ │
│ │ self = TransformersLLM( │ │
│ │ │ cuda_devices='auto', │ │
│ │ │ disable_cuda_device_placement=False, │ │
│ │ │ use_magpie_template=False, │ │
│ │ │ magpie_pre_query_template=None, │ │
│ │ │ generation_kwargs={}, │ │
│ │ │ use_offline_batch_generation=False, │ │
│ │ │ offline_batch_generation_block_until_done=None, │ │
│ │ │ jobs_ids=None, │ │
│ │ │ model='/conteneur/models/genstruct7b_AWQ/', │ │
│ │ │ revision='main', │ │
│ │ │ torch_dtype='float16', │ │
│ │ │ trust_remote_code=False, │ │
│ │ │ model_kwargs=None, │ │
│ │ │ tokenizer=None, │ │
│ │ │ use_fast=True, │ │
│ │ │ chat_template=None, │ │
│ │ │ device='cuda:0', │ │
│ │ │ device_map=None, │ │
│ │ │ token=None, │ │
│ │ │ structured_output=None │ │
│ │ ) │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ .venv/lib/python3.12/site-packages/pydantic/_internal/_validat │
│ e_call.py:39 in wrapper_function │
│ │
│ 36 │ │ │
│ 37 │ │ @functools.wraps(wrapped) │
│ 38 │ │ def wrapper_function(*args, **kwargs): │
│ ❱ 39 │ │ │ return wrapper(*args, **kwargs) │
│ 40 │ │
│ 41 │ # We need to manually update this because `partial` object has no `__name__` and `__ │
│ 42 │ wrapper_function.__name__ = extract_function_name(wrapped) │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ args = ( │ │
│ │ │ TransformersLLM( │ │
│ │ │ │ cuda_devices='auto', │ │
│ │ │ │ disable_cuda_device_placement=False, │ │
│ │ │ │ use_magpie_template=False, │ │
│ │ │ │ magpie_pre_query_template=None, │ │
│ │ │ │ generation_kwargs={}, │ │
│ │ │ │ use_offline_batch_generation=False, │ │
│ │ │ │ offline_batch_generation_block_until_done=None, │ │
│ │ │ │ jobs_ids=None, │ │
│ │ │ │ model='/conteneur/models/genstruct7b_AWQ/', │ │
│ │ │ │ revision='main', │ │
│ │ │ │ torch_dtype='float16', │ │
│ │ │ │ trust_remote_code=False, │ │
│ │ │ │ model_kwargs=None, │ │
│ │ │ │ tokenizer=None, │ │
│ │ │ │ use_fast=True, │ │
│ │ │ │ chat_template=None, │ │
│ │ │ │ device='cuda:0', │ │
│ │ │ │ device_map=None, │ │
│ │ │ │ token=None, │ │
│ │ │ │ structured_output=None │ │
│ │ │ ), │ │
│ │ ) │ │
│ │ kwargs = { │ │
│ │ │ 'inputs': [ │ │
│ │ │ │ [ │ │
│ │ │ │ │ { │ │
│ │ │ │ │ │ 'role': 'user', │ │
│ │ │ │ │ │ 'content': '[[[Title]]] common instruction\n[[[Content]]] content │ │
│ │ of the document\n\nThe follow'+104 │ │
│ │ │ │ │ } │ │
│ │ │ │ ] │ │
│ │ │ ], │ │
│ │ │ 'num_generations': 1 │ │
│ │ } │ │
│ │ wrapper = <bound method ValidateCallWrapper.__call__ of │ │
│ │ <pydantic._internal._validate_call.ValidateCallWrapper object at 0x75b6b2e5e420>> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ .venv/lib/python3.12/site-packages/pydantic/_internal/_validat │
│ e_call.py:136 in __call__ │
│ │
│ 133 │ │ if not self.__pydantic_complete__: │
│ 134 │ │ │ self._create_validators() │
│ 135 │ │ │
│ ❱ 136 │ │ res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, │
│ 137 │ │ if self.__return_pydantic_validator__: │
│ 138 │ │ │ return self.__return_pydantic_validator__(res) │
│ 139 │ │ else: │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ args = ( │ │
│ │ │ TransformersLLM( │ │
│ │ │ │ cuda_devices='auto', │ │
│ │ │ │ disable_cuda_device_placement=False, │ │
│ │ │ │ use_magpie_template=False, │ │
│ │ │ │ magpie_pre_query_template=None, │ │
│ │ │ │ generation_kwargs={}, │ │
│ │ │ │ use_offline_batch_generation=False, │ │
│ │ │ │ offline_batch_generation_block_until_done=None, │ │
│ │ │ │ jobs_ids=None, │ │
│ │ │ │ model='/conteneur/models/genstruct7b_AWQ/', │ │
│ │ │ │ revision='main', │ │
│ │ │ │ torch_dtype='float16', │ │
│ │ │ │ trust_remote_code=False, │ │
│ │ │ │ model_kwargs=None, │ │
│ │ │ │ tokenizer=None, │ │
│ │ │ │ use_fast=True, │ │
│ │ │ │ chat_template=None, │ │
│ │ │ │ device='cuda:0', │ │
│ │ │ │ device_map=None, │ │
│ │ │ │ token=None, │ │
│ │ │ │ structured_output=None │ │
│ │ │ ), │ │
│ │ ) │ │
│ │ kwargs = { │ │
│ │ │ 'inputs': [ │ │
│ │ │ │ [ │ │
│ │ │ │ │ { │ │
│ │ │ │ │ │ 'role': 'user', │ │
│ │ │ │ │ │ 'content': '[[[Title]]] common instruction\n[[[Content]]] content │ │
│ │ of the document\n\nThe follow'+104 │ │
│ │ │ │ │ } │ │
│ │ │ │ ] │ │
│ │ │ ], │ │
│ │ │ 'num_generations': 1 │ │
│ │ } │ │
│ │ self = <pydantic._internal._validate_call.ValidateCallWrapper object at 0x75b6b2e5e420> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ .venv/lib/python3.12/site-packages/distilabel/models/llms/hugg │
│ ingface/transformers.py:233 in generate │
│ │
│ 230 │ │ Returns: │
│ 231 │ │ │ A list of lists of strings containing the generated responses for each input │
│ 232 │ │ """ │
│ ❱ 233 │ │ prepared_inputs = [self.prepare_input(input=input) for input in inputs] │
│ 234 │ │ │
│ 235 │ │ outputs: List[List[Dict[str, str]]] = self._pipeline( # type: ignore │
│ 236 │ │ │ prepared_inputs, │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ do_sample = True │ │
│ │ inputs = [ │ │
│ │ │ [ │ │
│ │ │ │ { │ │
│ │ │ │ │ 'role': 'user', │ │
│ │ │ │ │ 'content': '[[[Title]]] common instruction\n[[[Content]]] │ │
│ │ content of the document\n\nThe follow'+104 │ │
│ │ │ │ } │ │
│ │ │ ] │ │
│ │ ] │ │
│ │ max_new_tokens = 128 │ │
│ │ num_generations = 1 │ │
│ │ repetition_penalty = 1.1 │ │
│ │ self = TransformersLLM( │ │
│ │ │ cuda_devices='auto', │ │
│ │ │ disable_cuda_device_placement=False, │ │
│ │ │ use_magpie_template=False, │ │
│ │ │ magpie_pre_query_template=None, │ │
│ │ │ generation_kwargs={}, │ │
│ │ │ use_offline_batch_generation=False, │ │
│ │ │ offline_batch_generation_block_until_done=None, │ │
│ │ │ jobs_ids=None, │ │
│ │ │ model='/conteneur/models/genstruct7b_AWQ/', │ │
│ │ │ revision='main', │ │
│ │ │ torch_dtype='float16', │ │
│ │ │ trust_remote_code=False, │ │
│ │ │ model_kwargs=None, │ │
│ │ │ tokenizer=None, │ │
│ │ │ use_fast=True, │ │
│ │ │ chat_template=None, │ │
│ │ │ device='cuda:0', │ │
│ │ │ device_map=None, │ │
│ │ │ token=None, │ │
│ │ │ structured_output=None │ │
│ │ ) │ │
│ │ temperature = 0.1 │ │
│ │ top_k = 0 │ │
│ │ top_p = 1.0 │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ .venv/lib/python3.12/site-packages/distilabel/models/llms/hugg │
│ ingface/transformers.py:192 in prepare_input │
│ │
│ 189 │ │ │ return input[0]["content"] │
│ 190 │ │ │
│ 191 │ │ prompt: str = ( │
│ ❱ 192 │ │ │ self._pipeline.tokenizer.apply_chat_template( # type: ignore │
│ 193 │ │ │ │ input, # type: ignore │
│ 194 │ │ │ │ tokenize=False, │
│ 195 │ │ │ │ add_generation_prompt=True, │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ input = [ │ │
│ │ │ { │ │
│ │ │ │ 'role': 'user', │ │
│ │ │ │ 'content': '[[[Title]]] common instruction\n[[[Content]]] content of the │ │
│ │ document\n\nThe follow'+104 │ │
│ │ │ } │ │
│ │ ] │ │
│ │ self = TransformersLLM( │ │
│ │ │ cuda_devices='auto', │ │
│ │ │ disable_cuda_device_placement=False, │ │
│ │ │ use_magpie_template=False, │ │
│ │ │ magpie_pre_query_template=None, │ │
│ │ │ generation_kwargs={}, │ │
│ │ │ use_offline_batch_generation=False, │ │
│ │ │ offline_batch_generation_block_until_done=None, │ │
│ │ │ jobs_ids=None, │ │
│ │ │ model='/conteneur/models/genstruct7b_AWQ/', │ │
│ │ │ revision='main', │ │
│ │ │ torch_dtype='float16', │ │
│ │ │ trust_remote_code=False, │ │
│ │ │ model_kwargs=None, │ │
│ │ │ tokenizer=None, │ │
│ │ │ use_fast=True, │ │
│ │ │ chat_template=None, │ │
│ │ │ device='cuda:0', │ │
│ │ │ device_map=None, │ │
│ │ │ token=None, │ │
│ │ │ structured_output=None │ │
│ │ ) │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ .venv/lib/python3.12/site-packages/transformers/tokenization_u │
│ tils_base.py:1640 in apply_chat_template │
│ │
│ 1637 │ │ │ │ raise ValueError("continue_final_message is not compatible with return_a │
│ 1638 │ │ │
│ 1639 │ │ template_kwargs = {**self.special_tokens_map, **kwargs} # kwargs overwrite spec │
│ ❱ 1640 │ │ rendered_chat, generation_indices = render_jinja_template( │
│ 1641 │ │ │ conversations=conversations, │
│ 1642 │ │ │ tools=tools, │
│ 1643 │ │ │ documents=documents, │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ add_generation_prompt = True │ │
│ │ chat_template = "{% for message in messages %}{{ '[[[Title]]] ' + │ │
│ │ message['title'].strip() + '\n' "+191 │ │
│ │ continue_final_message = False │ │
│ │ conversation = [ │ │
│ │ │ { │ │
│ │ │ │ 'role': 'user', │ │
│ │ │ │ 'content': '[[[Title]]] common │ │
│ │ instruction\n[[[Content]]] content of the document\n\nThe │ │
│ │ follow'+104 │ │
│ │ │ } │ │
│ │ ] │ │
│ │ conversations = [ │ │
│ │ │ [ │ │
│ │ │ │ { │ │
│ │ │ │ │ 'role': 'user', │ │
│ │ │ │ │ 'content': '[[[Title]]] common │ │
│ │ instruction\n[[[Content]]] content of the document\n\nThe │ │
│ │ follow'+104 │ │
│ │ │ │ } │ │
│ │ │ ] │ │
│ │ ] │ │
│ │ documents = None │ │
│ │ is_batched = False │ │
│ │ kwargs = {} │ │
│ │ max_length = None │ │
│ │ padding = False │ │
│ │ return_assistant_tokens_mask = False │ │
│ │ return_dict = False │ │
│ │ return_tensors = None │ │
│ │ self = LlamaTokenizerFast(name_or_path='/conteneur/models/genstruct… │ │
│ │ vocab_size=32000, │ │
│ │ model_max_length=1000000000000000019884624838656, │ │
│ │ is_fast=True, padding_side='right', truncation_side='right', │ │
│ │ special_tokens={'bos_token': '<s>', 'eos_token': '</s>', │ │
│ │ 'unk_token': '<unk>', 'pad_token': '[PAD]'}, │ │
│ │ clean_up_tokenization_spaces=False, added_tokens_decoder={ │ │
│ │ │ │ 0: AddedToken("<unk>", rstrip=False, lstrip=False, │ │
│ │ single_word=False, normalized=False, special=True), │ │
│ │ │ │ 1: AddedToken("<s>", rstrip=False, lstrip=False, │ │
│ │ single_word=False, normalized=False, special=True), │ │
│ │ │ │ 2: AddedToken("</s>", rstrip=False, lstrip=False, │ │
│ │ single_word=False, normalized=False, special=True), │ │
│ │ │ │ 32000: AddedToken("[PAD]", rstrip=False, │ │
│ │ lstrip=False, single_word=False, normalized=False, │ │
│ │ special=True), │ │
│ │ } │ │
│ │ ) │ │
│ │ template_kwargs = { │ │
│ │ │ 'bos_token': '<s>', │ │
│ │ │ 'eos_token': '</s>', │ │
│ │ │ 'unk_token': '<unk>', │ │
│ │ │ 'pad_token': '[PAD]' │ │
│ │ } │ │
│ │ tokenize = False │ │
│ │ tokenizer_kwargs = {} │ │
│ │ tools = None │ │
│ │ truncation = False │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ .venv/lib/python3.12/site-packages/transformers/utils/chat_tem │
│ plate_utils.py:521 in render_jinja_template │
│ │
│ 518 │ │ │ ) │
│ 519 │ │ │ all_generation_indices.append(generation_indices) │
│ 520 │ │ else: │
│ ❱ 521 │ │ │ rendered_chat = compiled_template.render( │
│ 522 │ │ │ │ messages=chat, │
│ 523 │ │ │ │ tools=tool_schemas, │
│ 524 │ │ │ │ documents=documents, │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ add_generation_prompt = True │ │
│ │ all_generation_indices = [] │ │
│ │ chat = [ │ │
│ │ │ { │ │
│ │ │ │ 'role': 'user', │ │
│ │ │ │ 'content': '[[[Title]]] common │ │
│ │ instruction\n[[[Content]]] content of the document\n\nThe │ │
│ │ follow'+104 │ │
│ │ │ } │ │
│ │ ] │ │
│ │ chat_template = "{% for message in messages %}{{ '[[[Title]]] ' + │ │
│ │ message['title'].strip() + '\n' "+191 │ │
│ │ compiled_template = <Template memory:75b56c83ecc0> │ │
│ │ continue_final_message = False │ │
│ │ conversations = [ │ │
│ │ │ [ │ │
│ │ │ │ { │ │
│ │ │ │ │ 'role': 'user', │ │
│ │ │ │ │ 'content': '[[[Title]]] common │ │
│ │ instruction\n[[[Content]]] content of the document\n\nThe │ │
│ │ follow'+104 │ │
│ │ │ │ } │ │
│ │ │ ] │ │
│ │ ] │ │
│ │ documents = None │ │
│ │ kwargs = { │ │
│ │ │ 'bos_token': '<s>', │ │
│ │ │ 'eos_token': '</s>', │ │
│ │ │ 'unk_token': '<unk>', │ │
│ │ │ 'pad_token': '[PAD]' │ │
│ │ } │ │
│ │ rendered = [] │ │
│ │ return_assistant_tokens_mask = False │ │
│ │ tool_schemas = None │ │
│ │ tools = None │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ .venv/lib/python3.12/site-packages/jinja2/environment.py:1295 │
│ in render │
│ │
│ 1292 │ │ try: │
│ 1293 │ │ │ return self.environment.concat(self.root_render_func(ctx)) # type: ignore │
│ 1294 │ │ except Exception: │
│ ❱ 1295 │ │ │ self.environment.handle_exception() │
│ 1296 │ │
│ 1297 │ async def render_async(self, *args: t.Any, **kwargs: t.Any) -> str: │
│ 1298 │ │ """This works similar to :meth:`render` but returns a coroutine │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ args = () │ │
│ │ ctx = <Context {'range': <function safe_range at 0x75b5e3a4b880>, 'dict': <class 'dict'>, │ │
│ │ 'lipsum': <function generate_lorem_ipsum at 0x75b6b8439b20>, 'cycler': <class │ │
│ │ 'jinja2.utils.Cycler'>, 'joiner': <class 'jinja2.utils.Joiner'>, 'namespace': │ │
│ │ <class 'jinja2.utils.Namespace'>, 'raise_exception': <function │ │
│ │ _compile_jinja_template.<locals>.raise_exception at 0x75b56c549120>, │ │
│ │ 'strftime_now': <function _compile_jinja_template.<locals>.strftime_now at │ │
│ │ 0x75b56c549940>, 'messages': [{'role': 'user', 'content': '[[[Title]]] common │ │
│ │ instruction\n[[[Content]]] content of the document\n\nThe following is an │ │
│ │ interaction between a user and an AI assistant that is related to the above │ │
│ │ text.\n\n[[[User]]] '}], 'tools': None, 'documents': None, 'add_generation_prompt': │ │
│ │ True, 'bos_token': '<s>', 'eos_token': '</s>', 'unk_token': '<unk>', 'pad_token': │ │
│ │ '[PAD]'} of None> │ │
│ │ kwargs = { │ │
│ │ │ 'messages': [ │ │
│ │ │ │ { │ │
│ │ │ │ │ 'role': 'user', │ │
│ │ │ │ │ 'content': '[[[Title]]] common instruction\n[[[Content]]] content of │ │
│ │ the document\n\nThe follow'+104 │ │
│ │ │ │ } │ │
│ │ │ ], │ │
│ │ │ 'tools': None, │ │
│ │ │ 'documents': None, │ │
│ │ │ 'add_generation_prompt': True, │ │
│ │ │ 'bos_token': '<s>', │ │
│ │ │ 'eos_token': '</s>', │ │
│ │ │ 'unk_token': '<unk>', │ │
│ │ │ 'pad_token': '[PAD]' │ │
│ │ } │ │
│ │ self = <Template memory:75b56c83ecc0> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ .venv/lib/python3.12/site-packages/jinja2/environment.py:942 │
│ in handle_exception │
│ │
│ 939 │ │ """ │
│ 940 │ │ from .debug import rewrite_traceback_stack │
│ 941 │ │ │
│ ❱ 942 │ │ raise rewrite_traceback_stack(source=source) │
│ 943 │ │
│ 944 │ def join_path(self, template: str, parent: str) -> str: │
│ 945 │ │ """Join a template with the parent. By default all the lookups are │
│ │
│ ╭───────────────────────────────────── locals ─────────────────────────────────────╮ │
│ │ self = <jinja2.sandbox.ImmutableSandboxedEnvironment object at 0x75b56c83fad0> │ │
│ │ source = None │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────╯ │
│ in top-level template code:1 │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ add_generation_prompt = True │ │
│ │ bos_token = '<s>' │ │
│ │ documents = None │ │
│ │ eos_token = '</s>' │ │
│ │ message = { │ │
│ │ │ 'role': 'user', │ │
│ │ │ 'content': '[[[Title]]] common instruction\n[[[Content]]] │ │
│ │ content of the document\n\nThe follow'+104 │ │
│ │ } │ │
│ │ messages = [ │ │
│ │ │ { │ │
│ │ │ │ 'role': 'user', │ │
│ │ │ │ 'content': '[[[Title]]] common instruction\n[[[Content]]] │ │
│ │ content of the document\n\nThe follow'+104 │ │
│ │ │ } │ │
│ │ ] │ │
│ │ pad_token = '[PAD]' │ │
│ │ tools = None │ │
│ │ unk_token = '<unk>' │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ .venv/lib/python3.12/site-packages/jinja2/sandbox.py:319 in │
│ getattr │
│ │
│ 316 │ │ attribute. The attribute passed *must* be a bytestring. │
│ 317 │ │ """ │
│ 318 │ │ try: │
│ ❱ 319 │ │ │ value = getattr(obj, attribute) │
│ 320 │ │ except AttributeError: │
│ 321 │ │ │ try: │
│ 322 │ │ │ │ return obj[attribute] │
│ │
│ ╭────────────────────────────────────── locals ───────────────────────────────────────╮ │
│ │ attribute = 'strip' │ │
│ │ obj = Undefined │ │
│ │ self = <jinja2.sandbox.ImmutableSandboxedEnvironment object at 0x75b56c83fad0> │ │
│ ╰─────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
UndefinedError: 'dict object' has no attribute 'title'
To reproduce
from distilabel.models.llms import TransformersLLM ## I also tried with vLLM, but same result
from distilabel.steps.tasks import Genstruct
genstruct = Genstruct(
llm=TransformersLLM(
model="/path/to/models/genstruct7b_AWQ/", torch_dtype="float16", device="cuda:0", chat_template=None
)
)
genstruct.load()
result = next(
genstruct.process(
[
{"title": "common instruction", "content": "content of the document"},
]
)
)
print(result)Expected behavior
Should work, and should not ask a dict for title attribute.
Screenshots
No response
Environment
- Distilabel Version [1.5.3]:
- Python Version [3.12.3]:
Additional context
I successfully run genstruct7B in local using transformers (AutoModelForCausalLM & AutoTokenizer)