KBLaM icon indicating copy to clipboard operation
KBLaM copied to clipboard

cannot import name 'LlamaDynamicNTKScalingRotaryEmbedding'

Open ThomasHoppe opened this issue 10 months ago • 6 comments

Training as proposed in the README or executing the 3rd cell of the eval_acc.ipynb gives the following error:

File ~/Thomas/KBLaM/src/kblam/models/llama3_model.py:43 38 from transformers.modeling_outputs import ( 39 BaseModelOutputWithPast, 40 CausalLMOutputWithPast, 41 ) 42 from transformers.models.llama.configuration_llama import LlamaConfig ---> 43 from transformers.models.llama.modeling_llama import ( 44 _CONFIG_FOR_DOC, 45 LLAMA_INPUTS_DOCSTRING, 46 LLAMA_START_DOCSTRING, 47 LlamaDynamicNTKScalingRotaryEmbedding, 48 LlamaLinearScalingRotaryEmbedding, 49 LlamaMLP, 50 LlamaPreTrainedModel, 51 LlamaRMSNorm, 52 LlamaRotaryEmbedding, 53 apply_rotary_pos_emb, 54 repeat_kv, 55 ) 56 from transformers.utils import ( 57 add_start_docstrings, 58 add_start_docstrings_to_model_forward, 59 logging, 60 replace_return_docstrings, 61 ) 63 from kblam.models.kblam_config import KBLaMConfig

ImportError: cannot import name 'LlamaDynamicNTKScalingRotaryEmbedding' from 'transformers.models.llama.modeling_llama' (/home/fokus/miniforge3/envs/kblam/lib/python3.13/site-packages/transformers/models/llama/modeling_llama.py)

The transformers lib doesn't define LlamaDynamicNTKScalingRotaryEmbedding. Hence, the "transformers==4.48.0" in pyproject seems to be wrong.

ThomasHoppe avatar Mar 31 '25 11:03 ThomasHoppe

Ok downgrading to transformers=4.46.0 seems to solve the problem above. However, afterwards I get another error:

`---> 23 from kblam.utils.data_utils import aug_row, generate_multi_entity_qa 24 from kblam.utils.eval_utils import ( 25 instruction_prompts, 26 instruction_prompts_multi_entities, (...) 33 softmax, 34 ) 35 from kblam.utils.train_utils import get_kb_embd

ImportError: cannot import name 'aug_row' from 'kblam.utils.data_utils' (/home/fokus/Thomas/KBLaM/src/kblam/utils/data_utils.py)`

Seems that in data_util.py it is now called, if I try to execute the 3rd cell of eval_acc.ipynb:

def augment_row(row: dict[str, str]) -> list[dict[str, str]]: """Augment an entity with questions from pre-defined templates."""

ThomasHoppe avatar Apr 01 '25 13:04 ThomasHoppe

same issue!!!

JacksonPei avatar Apr 02 '25 12:04 JacksonPei

same issue

thunder95 avatar Apr 03 '25 03:04 thunder95

same issue

pip install transformers==4.46.0。 I have solved the above issue。

YHY0607 avatar Apr 03 '25 06:04 YHY0607

duplicate of https://github.com/microsoft/KBLaM/issues/32

getStRiCtd avatar Apr 03 '25 11:04 getStRiCtd

Thanks, let me make a PR pinning to transformers 4.46.0. We'll consider longer-term solutions as well in the meantime

ti250 avatar Apr 10 '25 09:04 ti250