Add llama.cpp support for loading llama based models in the gui. We now

support loading both gptj derived models and llama derived models.
This commit is contained in:
Adam Treat
2023-04-15 15:57:32 -04:00
parent 00cb5fe2a5
commit 71b308e914
13 changed files with 571 additions and 12 deletions

18
llm.cpp
View File

@@ -47,20 +47,32 @@ bool LLMObject::loadModelPrivate(const QString &modelName)
return true;
if (isModelLoaded()) {
resetContext();
delete m_llmodel;
m_llmodel = nullptr;
emit isModelLoadedChanged();
}
m_llmodel = new GPTJ;
bool isGPTJ = false;
QString filePath = QCoreApplication::applicationDirPath() + QDir::separator() +
"ggml-" + modelName + ".bin";
QFileInfo info(filePath);
if (info.exists()) {
auto fin = std::ifstream(filePath.toStdString(), std::ios::binary);
m_llmodel->loadModel(modelName.toStdString(), fin);
uint32_t magic;
fin.read((char *) &magic, sizeof(magic));
fin.seekg(0);
isGPTJ = magic == 0x67676d6c;
if (isGPTJ) {
m_llmodel = new GPTJ;
m_llmodel->loadModel(modelName.toStdString(), fin);
} else {
m_llmodel = new LLamaModel;
m_llmodel->loadModel(filePath.toStdString());
}
emit isModelLoadedChanged();
emit threadCountChanged();
}