forked from ztxz16/fastllm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
1,191 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// | ||
// Created by huangyuyang on 6/1/23. | ||
// | ||
|
||
#ifndef FASTLLM_MINICPM_H | ||
#define FASTLLM_MINICPM_H | ||
|
||
#include "basellm.h" | ||
#include "cmath" | ||
|
||
#include <iostream> | ||
|
||
namespace fastllm { | ||
class MiniCpmModel: public basellm { | ||
public: | ||
MiniCpmModel(); // 构造函数 | ||
|
||
// 推理 | ||
virtual int Forward( | ||
const Data &inputIds, | ||
const Data &attentionMask, | ||
const Data &positionIds, | ||
std::vector <std::pair <Data, Data> > &pastKeyValues, | ||
const GenerationConfig &generationConfig = GenerationConfig(), | ||
const LastTokensManager &lastTokens = LastTokensManager(), | ||
std::vector <float> *logits = nullptr); | ||
|
||
std::vector <int> ForwardBatch( | ||
int batch, | ||
const Data &inputIds, | ||
const Data &attentionMask, | ||
const Data &positionIds, | ||
std::vector <std::pair <Data, Data> > &pastKeyValues, | ||
const GenerationConfig &generationConfig = GenerationConfig(), | ||
const LastTokensManager &lastTokens = LastTokensManager(), | ||
std::vector <std::vector <float>*> *logits = nullptr); | ||
|
||
std::vector <int> ForwardBatch( | ||
int batch, | ||
const Data &inputIds, | ||
const std::vector <Data*> &attentionMask, | ||
const std::vector <Data*> &positionIds, | ||
const std::vector <int> &seqLens, | ||
std::vector <std::pair <Data*, Data*> > &pastKeyValues, | ||
const std::vector <GenerationConfig> &generationConfigs, | ||
const LastTokensManager &lastTokens = LastTokensManager(), | ||
std::vector <std::vector <float>*> *logits = nullptr); | ||
|
||
virtual std::string Response(const std::string& input, | ||
RuntimeResult retCb, | ||
const GenerationConfig &generationConfig = GenerationConfig()); // 根据给出的内容回复 | ||
|
||
virtual void ResponseBatch(const std::vector <std::string> &inputs, | ||
std::vector <std::string> &outputs, | ||
RuntimeResultBatch retCb, | ||
const GenerationConfig &generationConfig = GenerationConfig()); | ||
|
||
virtual int LaunchResponseTokens(const std::vector <int> &inputTokens, | ||
const GenerationConfig &generationConfig = GenerationConfig()); // 启动一个response任务,返回分配的handleId | ||
|
||
virtual int FetchResponseTokens(int handelId); // 获取指定handle的输出, -1代表输出结束了 | ||
|
||
virtual void WarmUp(); // 预热 | ||
|
||
virtual std::string MakeInput(const std::string &history, int round, const std::string &input); // 根据历史信息和当前输入生成prompt | ||
|
||
virtual std::string MakeHistory(const std::string &history, int round, const std::string &input, const std::string &output); // 根据当前回复更新history | ||
}; | ||
} | ||
|
||
#endif //FASTLLM_MINICPM_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.