Skip to content

Commit bb45cb8

Browse files
committed
move modeling.py and modeling_nv.py to transformers and fix test_modeling
1 parent d2c8d4f commit bb45cb8

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

tests/transformers/llm_embed/test_modeling.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@
1919

2020
from paddlenlp.transformers import AutoTokenizer, BiEncoderModel
2121

22+
from ...testing_utils import require_gpu, slow
23+
2224

2325
class BiEncoderModelIntegrationTest(unittest.TestCase):
26+
@slow
27+
@require_gpu(1)
2428
def test_model_tiny_logits(self):
2529
input_texts = [
2630
"This is a test",
2731
"This is another test",
2832
]
2933

30-
model_name_or_path = "bge-large-en-v1.5"
34+
model_name_or_path = "BAAI/bge-large-en-v1.5"
3135
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
3236
model = BiEncoderModel(model_name_or_path=model_name_or_path, dtype="float16", tokenizer=tokenizer)
3337
with paddle.no_grad():

tests/transformers/nv_embed/test_modeling.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,42 @@
1717

1818
import paddle
1919

20-
from paddlenlp.transformers import NVEncodeModel
20+
from paddlenlp.transformers import NVEncodeModel, PretrainedConfig
21+
22+
from ...testing_utils import require_gpu, slow
2123

2224

2325
class NVEncodeModelIntegrationTest(unittest.TestCase):
26+
@slow
27+
@require_gpu(1)
2428
def test_model_tiny_logits(self):
2529
input_texts = [
2630
"This is a test",
2731
"This is another test",
2832
]
2933

30-
model_name_or_path = "NV-Embed-v1-paddle"
31-
model = NVEncodeModel.from_pretrained(
32-
model_name_or_path,
33-
tokenizer_path=model_name_or_path,
34+
config = PretrainedConfig(
35+
attention_dropout=0.0,
36+
bos_token_id=1,
3437
dtype="float16",
38+
eos_token_id=2,
39+
hidden_act="silu",
40+
hidden_size=4096,
41+
initializer_range=0.02,
42+
intermediate_size=14336,
43+
max_position_embeddings=32768,
44+
num_attention_heads=32,
45+
num_hidden_layers=32,
46+
num_key_value_heads=8,
47+
rms_norm_eps=1e-05,
48+
rope_theta=10000.0,
49+
sliding_window=4096,
50+
tie_word_embeddings=False,
51+
vocab_size=32000,
52+
)
53+
model = NVEncodeModel(
54+
config=config,
55+
tokenizer_path="BAAI/bge-large-en-v1.5",
3556
query_instruction="",
3657
document_instruction="",
3758
)

0 commit comments

Comments
 (0)