mirror of https://github.com/google/gemma.cpp.git
Update run.cc, CMakeLists and README for incompatible code, dependency changes and argument updates
This commit is contained in:
parent
4a924f1794
commit
0ea118ebbe
|
|
@ -14,12 +14,13 @@
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.11)
|
cmake_minimum_required(VERSION 3.11)
|
||||||
project(hello_world)
|
project(hello_world)
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG c5bebf84ad01edec97e336f5c97ca4e0df6b4d06)
|
FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG bfc36a6e633af94e63ac4b91c687bf0354cb24e0)
|
||||||
FetchContent_MakeAvailable(highway)
|
FetchContent_MakeAvailable(highway)
|
||||||
FetchContent_Declare(sentencepiece GIT_REPOSITORY https://github.com/google/sentencepiece GIT_TAG 53de76561cfc149d3c01037f0595669ad32a5e7c)
|
FetchContent_Declare(sentencepiece GIT_REPOSITORY https://github.com/google/sentencepiece GIT_TAG 9045b2f60fa2b323dfac0eaef8fc17565036f9f9)
|
||||||
FetchContent_MakeAvailable(sentencepiece)
|
FetchContent_MakeAvailable(sentencepiece)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -33,7 +34,7 @@ if (BUILD_MODE STREQUAL "local")
|
||||||
# Relative path to gemma.cpp from examples/hello_world/build/
|
# Relative path to gemma.cpp from examples/hello_world/build/
|
||||||
FetchContent_Declare(gemma SOURCE_DIR ../../..)
|
FetchContent_Declare(gemma SOURCE_DIR ../../..)
|
||||||
else()
|
else()
|
||||||
FetchContent_Declare(gemma GIT_REPOSITORY https://github.com/google/gemma.cpp.git GIT_TAG a9aa63fd2ea6b786ed0706d619588bfe2d43370e)
|
FetchContent_Declare(gemma GIT_REPOSITORY https://github.com/google/gemma.cpp.git GIT_TAG 4a924f179448dc83e46a2af9520c61b4ef56174c)
|
||||||
endif()
|
endif()
|
||||||
FetchContent_MakeAvailable(gemma)
|
FetchContent_MakeAvailable(gemma)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ gemma.cpp specifying the tokenizer, compressed weights file, and model type, for
|
||||||
example:
|
example:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./hello_world --tokenizer tokenizer.spm --compressed_weights 2b-it-sfp.sbs --model 2b-it
|
./hello_world --tokenizer tokenizer.spm --weights 2b-it-sfp.sbs --model 2b-it
|
||||||
```
|
```
|
||||||
|
|
||||||
Should print a greeting to the terminal:
|
Should print a greeting to the terminal:
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,7 @@
|
||||||
#include "hwy/base.h"
|
#include "hwy/base.h"
|
||||||
#include "hwy/contrib/thread_pool/thread_pool.h"
|
#include "hwy/contrib/thread_pool/thread_pool.h"
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char **argv) { {
|
||||||
{
|
|
||||||
// Placeholder for internal init, do not modify.
|
// Placeholder for internal init, do not modify.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,7 +42,7 @@ int main(int argc, char** argv) {
|
||||||
if (gcpp::HasHelp(argc, argv)) {
|
if (gcpp::HasHelp(argc, argv)) {
|
||||||
loader.Help();
|
loader.Help();
|
||||||
return 0;
|
return 0;
|
||||||
} else if (const char* error = loader.Validate()) {
|
} else if (const char *error = loader.Validate()) {
|
||||||
loader.Help();
|
loader.Help();
|
||||||
HWY_ABORT("\nInvalid args: %s", error);
|
HWY_ABORT("\nInvalid args: %s", error);
|
||||||
}
|
}
|
||||||
|
|
@ -99,9 +98,10 @@ int main(int argc, char** argv) {
|
||||||
.verbosity = 0,
|
.verbosity = 0,
|
||||||
.stream_token = stream_token,
|
.stream_token = stream_token,
|
||||||
.accept_token =
|
.accept_token =
|
||||||
|
std::function<bool(int, float)>(
|
||||||
[&](int token, float /* prob */) {
|
[&](int token, float /* prob */) {
|
||||||
return !reject_tokens.contains(token);
|
return reject_tokens.find(token) == reject_tokens.end();
|
||||||
},
|
}),
|
||||||
};
|
};
|
||||||
model.Generate(runtime_config, tokens, 0, kv_cache, timing_info);
|
model.Generate(runtime_config, tokens, 0, kv_cache, timing_info);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue