-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #442 from TylunasLi/llama
Llama支持分组查询注意力,支持书生2模型
- Loading branch information
Showing
18 changed files
with
713 additions
and
122 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
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
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
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,54 @@ | ||
// | ||
// Created by tylunasli on 3/14/24. | ||
// | ||
|
||
#ifndef FASTLLM_INTERNLM2_H | ||
#define FASTLLM_INTERNLM2_H | ||
|
||
#include "basellm.h" | ||
#include "llama.h" | ||
#include "cmath" | ||
|
||
#include <iostream> | ||
|
||
namespace fastllm { | ||
class Internlm2Model : public LlamaModel { | ||
public: | ||
Internlm2Model(); // 构造函数 | ||
|
||
virtual void InitParams(); // 初始化参数信息 | ||
|
||
// 推理 | ||
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); | ||
}; | ||
} | ||
|
||
#endif //FASTLLM_INTERNLM2_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
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
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.