Xenith/xenith/core/generate.h
2026-09-29 19:55:06 +07:00

29 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// generate.h — генерация текста с KV-кэшем
#pragma once
#include "checkpoint.h"
#include <string>
#include <vector>
namespace xt {
struct GenConfig {
int max_new_tokens = 200;
float temperature = 0.8f; // <= 0 => greedy
int top_k = 40; // 0 => выключить
float top_p = 0.95f; // >= 1 => выключить
int seed = -1; // -1 => случайный
bool stream = true; // печатать по мере генерации
int repeat_penalty = 1; // штраф за повтор (окно = 64)
};
std::string generate(const Params& p, const Tokenizer& tok,
const std::string& prompt, const GenConfig& gc,
std::vector<int>* out_ids = nullptr);
// Батч из нескольких промптов — переиспользует один набор весов
std::vector<std::string> generate_batch(const Params& p, const Tokenizer& tok,
const std::vector<std::string>& prompts,
const GenConfig& gc);
} // namespace xt