MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / _create_default_sampling_metadata

Function _create_default_sampling_metadata

tests/layers/test_sampler.py:54–81  ·  view source on GitHub ↗
(
    batch_size: int,
    min_seq_len: int,
    max_seq_len: int,
    max_num_logprobs: int = None,
)

Source from the content-addressed store, hash-verified

52
53
54def _create_default_sampling_metadata(
55 batch_size: int,
56 min_seq_len: int,
57 max_seq_len: int,
58 max_num_logprobs: int = None,
59) -> SamplingMetadata:
60
61 fake_sampling_metadata = SamplingMetadata(
62 temperature=paddle.full(shape=[batch_size, 1], fill_value=0.9, dtype="float32"),
63 top_p=paddle.full(shape=[batch_size, 1], fill_value=0.7, dtype="float32"),
64 prompt_ids=paddle.full(shape=[batch_size, max_seq_len], fill_value=0, dtype="int64"),
65 prompt_lens=paddle.full(shape=[batch_size, 1], fill_value=5, dtype="int64"),
66 step_idx=paddle.full(shape=[batch_size, 1], fill_value=0, dtype="int64"),
67 pre_token_ids=_create_tokens_tensor(batch_size, max_seq_len),
68 frequency_penalties=_create_penalty_tensor(batch_size, 0.0),
69 presence_penalties=_create_penalty_tensor(batch_size, 0.0),
70 repetition_penalties=_create_penalty_tensor(batch_size, 1.0),
71 min_dec_lens=paddle.full(shape=[batch_size, 1], fill_value=min_seq_len, dtype="int64"),
72 bad_words_token_ids=paddle.full(shape=[batch_size], fill_value=-1, dtype="int64"),
73 bad_words_token_len=paddle.full(shape=[batch_size, 1], fill_value=0, dtype="int64"),
74 eos_token_ids=paddle.full(shape=[batch_size], fill_value=-2, dtype="int64"),
75 min_p=paddle.randn([batch_size]),
76 seed=paddle.to_tensor([[2025]]),
77 logits_processors=None,
78 )
79 if max_num_logprobs is not None:
80 fake_sampling_metadata.max_num_logprobs = max_num_logprobs
81 return fake_sampling_metadata
82
83
84def build_config_json() -> str:

Callers 2

test_samplerFunction · 0.70
test_sampler_logprobsFunction · 0.70

Calls 3

SamplingMetadataClass · 0.90
_create_tokens_tensorFunction · 0.70
_create_penalty_tensorFunction · 0.70

Tested by

no test coverage detected