You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
请问有人遇到过这个问题么?在运行BAAI/bge-reranker-v2.5-gemma2-lightweight示例代码:
`from FlagEmbedding import LightWeightFlagLLMReranker
reranker = LightWeightFlagLLMReranker('BAAI/bge-reranker-v2.5-gemma2-lightweight', use_fp16=True) # Setting use_fp16 to True speeds up computation with a slight performance degradation
score = reranker.compute_score(['query', 'passage'], cutoff_layers=[28], compress_ratio=2, compress_layer=[24, 40]) # Adjusting 'cutoff_layers' to pick which layers are used for computing the score.
print(score)
scores = reranker.compute_score([['what is panda?', 'hi'], ['what is panda?', 'The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear or simply panda, is a bear species endemic to China.']], cutoff_layers=[28], compress_ratio=2, compress_layer=[24, 40])
print(scores) 报错:TypeError Traceback (most recent call last)
Cell In[1], line 4
1 from FlagEmbedding import LightWeightFlagLLMReranker
2 reranker = LightWeightFlagLLMReranker('bge-reranker-v2.5-gemma2-lightweight', use_fp16=True) # Setting use_fp16 to True speeds up computation with a slight performance degradation
----> 4 score = reranker.compute_score(['query', 'passage'], cutoff_layers=[28], compress_ratio=2, compress_layer=[24, 40]) # Adjusting 'cutoff_layers' to pick which layers are used for computing the score.
5 print(score)
7 scores = reranker.compute_score([['what is panda?', 'hi'], ['what is panda?', 'The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear or simply panda, is a bear species endemic to China.']], cutoff_layers=[28], compress_ratio=2, compress_layer=[24, 40])
File ~/autodl-tmp/FlagEmbedding/FlagEmbedding/abc/inference/AbsReranker.py:217, in AbsReranker.compute_score(self, sentence_pairs, **kwargs)
214 sentence_pairs = self.get_detailed_inputs(sentence_pairs)
216 if isinstance(sentence_pairs, str) or len(self.target_devices) == 1:
--> 217 return self.compute_score_single_gpu(
218 sentence_pairs,
219 device=self.target_devices[0],
220 **kwargs
221 )
223 if self.pool is None:
224 self.pool = self.start_multi_process_pool()
File ~/miniconda3/lib/python3.12/site-packages/torch/nn/modules/module.py:1541, in Module._call_impl(self, *args, **kwargs)
1536 # If we don't have any hooks, we want to skip the rest of the logic in
1537 # this function, and just call forward.
1538 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1539 or _global_backward_pre_hooks or _global_backward_hooks
1540 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1541 return forward_call(*args, **kwargs)
1543 try:
1544 result = None
File ~/miniconda3/lib/python3.12/site-packages/torch/nn/modules/module.py:1541, in Module._call_impl(self, *args, **kwargs)
1536 # If we don't have any hooks, we want to skip the rest of the logic in
1537 # this function, and just call forward.
1538 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1539 or _global_backward_pre_hooks or _global_backward_hooks
1540 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1541 return forward_call(*args, **kwargs)
1543 try:
1544 result = None
File ~/miniconda3/lib/python3.12/site-packages/torch/nn/modules/module.py:1541, in Module._call_impl(self, *args, **kwargs)
1536 # If we don't have any hooks, we want to skip the rest of the logic in
1537 # this function, and just call forward.
1538 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1539 or _global_backward_pre_hooks or _global_backward_hooks
1540 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1541 return forward_call(*args, **kwargs)
1543 try:
1544 result = None
请问有人遇到过这个问题么?在运行BAAI/bge-reranker-v2.5-gemma2-lightweight示例代码:
`from FlagEmbedding import LightWeightFlagLLMReranker
reranker = LightWeightFlagLLMReranker('BAAI/bge-reranker-v2.5-gemma2-lightweight', use_fp16=True) # Setting use_fp16 to True speeds up computation with a slight performance degradation
score = reranker.compute_score(['query', 'passage'], cutoff_layers=[28], compress_ratio=2, compress_layer=[24, 40]) # Adjusting 'cutoff_layers' to pick which layers are used for computing the score.
print(score)
scores = reranker.compute_score([['what is panda?', 'hi'], ['what is panda?', 'The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear or simply panda, is a bear species endemic to China.']], cutoff_layers=[28], compress_ratio=2, compress_layer=[24, 40])
print(scores)
报错:
TypeError Traceback (most recent call last)Cell In[1], line 4
1 from FlagEmbedding import LightWeightFlagLLMReranker
2 reranker = LightWeightFlagLLMReranker('bge-reranker-v2.5-gemma2-lightweight', use_fp16=True) # Setting use_fp16 to True speeds up computation with a slight performance degradation
----> 4 score = reranker.compute_score(['query', 'passage'], cutoff_layers=[28], compress_ratio=2, compress_layer=[24, 40]) # Adjusting 'cutoff_layers' to pick which layers are used for computing the score.
5 print(score)
7 scores = reranker.compute_score([['what is panda?', 'hi'], ['what is panda?', 'The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear or simply panda, is a bear species endemic to China.']], cutoff_layers=[28], compress_ratio=2, compress_layer=[24, 40])
File ~/autodl-tmp/FlagEmbedding/FlagEmbedding/abc/inference/AbsReranker.py:217, in AbsReranker.compute_score(self, sentence_pairs, **kwargs)
214 sentence_pairs = self.get_detailed_inputs(sentence_pairs)
216 if isinstance(sentence_pairs, str) or len(self.target_devices) == 1:
--> 217 return self.compute_score_single_gpu(
218 sentence_pairs,
219 device=self.target_devices[0],
220 **kwargs
221 )
223 if self.pool is None:
224 self.pool = self.start_multi_process_pool()
File ~/miniconda3/lib/python3.12/site-packages/torch/utils/_contextlib.py:115, in context_decorator..decorate_context(*args, **kwargs)
112 @functools.wraps(func)
113 def decorate_context(*args, **kwargs):
114 with ctx_factory():
--> 115 return func(*args, **kwargs)
File ~/autodl-tmp/FlagEmbedding/FlagEmbedding/inference/reranker/decoder_only/lightweight.py:359, in LightweightLLMReranker.compute_score_single_gpu(self, sentence_pairs, batch_size, query_max_length, max_length, cutoff_layers, compress_layer, compress_layers, compress_ratio, prompt, normalize, device, **kwargs)
348 batch_inputs = collater_instance([
349 [{
350 'input_ids': item['input_ids'],
(...)
354 prompt_lengths
355 ])[0]
357 batch_inputs = {key: val.to(device) for key, val in batch_inputs.items()}
--> 359 self.model(
360 **batch_inputs,
361 output_hidden_states=True,
362 compress_layer=compress_layers,
363 compress_ratio=compress_ratio,
364 query_lengths=query_lengths,
365 prompt_lengths=prompt_lengths,
366 cutoff_layers=cutoff_layers
367 )
368 flag = True
369 except RuntimeError as e:
File ~/miniconda3/lib/python3.12/site-packages/torch/nn/modules/module.py:1532, in Module._wrapped_call_impl(self, *args, **kwargs)
1530 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1531 else:
-> 1532 return self._call_impl(*args, **kwargs)
File ~/miniconda3/lib/python3.12/site-packages/torch/nn/modules/module.py:1541, in Module._call_impl(self, *args, **kwargs)
1536 # If we don't have any hooks, we want to skip the rest of the logic in
1537 # this function, and just call forward.
1538 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1539 or _global_backward_pre_hooks or _global_backward_hooks
1540 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1541 return forward_call(*args, **kwargs)
1543 try:
1544 result = None
File ~/autodl-tmp/FlagEmbedding/FlagEmbedding/inference/reranker/decoder_only/models/gemma_model.py:599, in CostWiseGemmaForCausalLM.forward(self, input_ids, attention_mask, position_ids, past_key_values, inputs_embeds, labels, use_cache, output_attentions, output_hidden_states, return_dict, cache_position, compress_layer, compress_ratio, cutoff_layers, query_lengths, prompt_lengths)
596 raise ValueError(f"Your cutoff layers must in [{self.config.start_layer}, {self.config.num_hidden_layers}]")
598 # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
--> 599 outputs = self.model(
600 input_ids=input_ids,
601 attention_mask=attention_mask,
602 position_ids=position_ids,
603 past_key_values=past_key_values,
604 inputs_embeds=inputs_embeds,
605 use_cache=use_cache,
606 output_attentions=output_attentions,
607 output_hidden_states=output_hidden_states,
608 return_dict=return_dict,
609 cache_position=cache_position,
610 compress_layer=compress_layer,
611 compress_ratio=compress_ratio,
612 query_lengths=query_lengths,
613 prompt_lengths=prompt_lengths,
614 cutoff_layers=cutoff_layers,
615 )
617 if not self.config.layer_wise:
618 hidden_states = outputs[0]
File ~/miniconda3/lib/python3.12/site-packages/torch/nn/modules/module.py:1532, in Module._wrapped_call_impl(self, *args, **kwargs)
1530 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1531 else:
-> 1532 return self._call_impl(*args, **kwargs)
File ~/miniconda3/lib/python3.12/site-packages/torch/nn/modules/module.py:1541, in Module._call_impl(self, *args, **kwargs)
1536 # If we don't have any hooks, we want to skip the rest of the logic in
1537 # this function, and just call forward.
1538 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1539 or _global_backward_pre_hooks or _global_backward_hooks
1540 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1541 return forward_call(*args, **kwargs)
1543 try:
1544 result = None
File ~/autodl-tmp/FlagEmbedding/FlagEmbedding/inference/reranker/decoder_only/models/gemma_model.py:395, in CostWiseGemmaModel.forward(self, input_ids, attention_mask, position_ids, past_key_values, inputs_embeds, use_cache, output_attentions, output_hidden_states, return_dict, cache_position, compress_layer, compress_ratio, cutoff_layers, query_lengths, prompt_lengths)
384 layer_outputs = self._gradient_checkpointing_func(
385 decoder_layer.call,
386 hidden_states,
(...)
392 cache_position,
393 )
394 else:
--> 395 layer_outputs = decoder_layer(
396 hidden_states,
397 attention_mask=causal_mask,
398 position_ids=position_ids,
399 past_key_value=past_key_values,
400 output_attentions=output_attentions,
401 use_cache=use_cache,
402 cache_position=cache_position,
403 )
405 hidden_states = layer_outputs[0]
407 if output_attentions:
File ~/miniconda3/lib/python3.12/site-packages/torch/nn/modules/module.py:1532, in Module._wrapped_call_impl(self, *args, **kwargs)
1530 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1531 else:
-> 1532 return self._call_impl(*args, **kwargs)
File ~/miniconda3/lib/python3.12/site-packages/torch/nn/modules/module.py:1541, in Module._call_impl(self, *args, **kwargs)
1536 # If we don't have any hooks, we want to skip the rest of the logic in
1537 # this function, and just call forward.
1538 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1539 or _global_backward_pre_hooks or _global_backward_hooks
1540 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1541 return forward_call(*args, **kwargs)
1543 try:
1544 result = None
TypeError: Gemma2DecoderLayer.forward() missing 1 required positional argument: 'position_embeddings'`
The text was updated successfully, but these errors were encountered: