MCPcopy Create free account
hub / github.com/davisking/dlib / get_input_sequence

Method get_input_sequence

examples/slm_advanced_train_ex.cpp:696–715  ·  view source on GitHub ↗

Get the next input sequence for the model

Source from the content-addressed store, hash-verified

694
695 // Get the next input sequence for the model
696 matrix<int, 0, 1> get_input_sequence(size_t desired_length) const {
697 if (desired_length < min_prompt_size_)
698 throw std::invalid_argument("Requested length is smaller than minimum prompt size");
699 matrix<int, 0, 1> input_sequence(desired_length, 1);
700
701 // Determine how many tokens we'll copy from context
702 size_t tokens_to_copy = std::min(current_context_.size(), desired_length);
703 size_t start_pos = current_context_.size() > desired_length ?
704 current_context_.size() - desired_length : 0;
705
706 // Fill the matrix with tokens from context
707 for (size_t i = 0; i < tokens_to_copy; ++i)
708 input_sequence(i, 0) = current_context_[start_pos + i];
709
710 // Fill remaining positions with padding token if needed
711 for (size_t i = tokens_to_copy; i < desired_length; ++i)
712 input_sequence(i, 0) = padding_token_;
713
714 return input_sequence;
715 }
716
717 // Calculate maximum output tokens that can be generated
718 size_t get_max_output_tokens() const {

Callers 1

mainFunction · 0.80

Calls 2

minFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected