Skip to content

Commit d987999

Browse files
committed
Revert "Add vision support in llama-server (ikawrakow#901)"
This reverts commit 15159a8.
1 parent 9c91846 commit d987999

26 files changed

+730
-2457
lines changed

common/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ add_library(${TARGET} STATIC
5757
chat-parser.cpp
5858
chat-parser.h
5959
common.cpp
60+
chat.h
61+
chat.cpp
6062
sampling.h
6163
sampling.cpp
6264
console.h

common/common.cpp

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,6 @@ static std::string parse_device_list(const std::string& value) {
270270
return value;
271271
}
272272

273-
274-
std::pair<long, std::vector<char>> common_remote_get_content(const std::string& url, const common_remote_params&) {
275-
if (!url.empty()) {
276-
throw std::runtime_error("error: built without CURL, cannot download file from the internet");
277-
}
278-
return {};
279-
}
280-
281273
//
282274
// CLI argument parsing
283275
//
@@ -1740,11 +1732,6 @@ bool gpt_params_find_arg(int argc, char ** argv, const std::string & arg, gpt_pa
17401732
params.n_junk = std::stoi(argv[i]);
17411733
return true;
17421734
}
1743-
if (arg == "--no-context-shift") {
1744-
CHECK_ARG
1745-
params.ctx_shift = false;
1746-
return true;
1747-
}
17481735
if (arg == "--pos") {
17491736
CHECK_ARG
17501737
params.i_pos = std::stoi(argv[i]);
@@ -2078,7 +2065,7 @@ void gpt_params_print_usage(int /*argc*/, char ** argv, const gpt_params & param
20782065
options.push_back({ "multi-modality" });
20792066
options.push_back({ "*", " --mmproj FILE", "path to a multimodal projector file for LLaVA. see examples/llava/README.md" });
20802067
options.push_back({ "*", " --image FILE", "path to an image file. use with multimodal models. Specify multiple times for batching" });
2081-
options.push_back({ "*", " --no-context-shift", "disable context-shift." });
2068+
20822069
options.push_back({ "backend" });
20832070
options.push_back({ "*", " --rpc SERVERS", "comma separated list of RPC servers" });
20842071
options.push_back({ "*", "-cuda, --cuda-params", "comma separate list of cuda parameters" });
@@ -3331,29 +3318,6 @@ std::vector<llama_token> llama_tokenize(
33313318
return result;
33323319
}
33333320

3334-
std::vector<llama_token> llama_tokenize(
3335-
const struct llama_vocab* vocab,
3336-
const std::string& text,
3337-
bool add_special,
3338-
bool parse_special) {
3339-
// upper limit for the number of tokens
3340-
int n_tokens = text.length() + 2 * add_special;
3341-
std::vector<llama_token> result(n_tokens);
3342-
n_tokens = llama_vocab_tokenize(vocab, text.data(), text.length(), result.data(), result.size(), add_special, parse_special);
3343-
if (n_tokens == std::numeric_limits<int32_t>::min()) {
3344-
throw std::runtime_error("Tokenization failed: input text too large, tokenization result exceeds int32_t limit");
3345-
}
3346-
if (n_tokens < 0) {
3347-
result.resize(-n_tokens);
3348-
int check = llama_vocab_tokenize(vocab, text.data(), text.length(), result.data(), result.size(), add_special, parse_special);
3349-
GGML_ASSERT(check == -n_tokens);
3350-
}
3351-
else {
3352-
result.resize(n_tokens);
3353-
}
3354-
return result;
3355-
}
3356-
33573321
std::string llama_token_to_piece(const struct llama_context * ctx, llama_token token, bool special) {
33583322
std::string piece;
33593323
piece.resize(piece.capacity()); // using string internal cache, 15 bytes + '\n'
@@ -3386,7 +3350,7 @@ std::string llama_token_to_piece(const struct llama_model* model, llama_token to
33863350
return piece;
33873351
}
33883352

3389-
std::string llama_detokenize(const llama_context * ctx, const std::vector<llama_token> & tokens, bool special) {
3353+
std::string llama_detokenize(llama_context * ctx, const std::vector<llama_token> & tokens, bool special) {
33903354
std::string text;
33913355
text.resize(std::max(text.capacity(), tokens.size()));
33923356
int32_t n_chars = llama_detokenize(llama_get_model(ctx), tokens.data(), (int32_t)tokens.size(), &text[0], (int32_t)text.size(), false, special);
@@ -3402,7 +3366,6 @@ std::string llama_detokenize(const llama_context * ctx, const std::vector<llama_
34023366
return text;
34033367
}
34043368

3405-
34063369
bool llama_should_add_bos_token(const llama_model * model) {
34073370
const int add_bos = llama_add_bos_token(model);
34083371

common/common.h

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ struct llama_lora_adapter_container : llama_lora_adapter_info {
5353
struct llama_lora_adapter * adapter;
5454
};
5555

56-
using llama_tokens = std::vector<llama_token>;
57-
5856
// build info
5957
extern int LLAMA_BUILD_NUMBER;
6058
extern char const * LLAMA_COMMIT;
@@ -240,7 +238,7 @@ struct gpt_params {
240238
bool conversation = false; // conversation mode (does not print special tokens and suffix/prefix)
241239
bool prompt_cache_all = false; // save user input and generations to prompt cache
242240
bool prompt_cache_ro = false; // open the prompt cache read-only and do not update it
243-
bool ctx_shift = true;
241+
244242
bool escape = true; // escape "\n", "\r", "\t", "\'", "\"", and "\\"
245243
bool multiline_input = false; // reverse the usage of `\`
246244
bool simple_io = false; // improves compatibility with subprocesses and limited consoles
@@ -374,9 +372,6 @@ struct gpt_params {
374372
bool sweep_bench_output_jsonl = false;
375373
};
376374

377-
378-
379-
void gpt_params_handle_hf_token(gpt_params & params);
380375
void gpt_params_parse_from_env(gpt_params & params);
381376
void gpt_params_handle_model_default(gpt_params & params);
382377

@@ -387,15 +382,6 @@ void gpt_params_print_usage(int argc, char ** argv, const gpt_params & params);
387382

388383
std::string gpt_params_get_system_info(const gpt_params & params);
389384

390-
391-
struct common_remote_params {
392-
std::vector<std::string> headers;
393-
long timeout = 0; // CURLOPT_TIMEOUT, in seconds ; 0 means no timeout
394-
long max_size = 0; // max size of the response ; unlimited if 0 ; max is 2GB
395-
};
396-
// get remote file content, returns <http_code, raw_response_body>
397-
std::pair<long, std::vector<char>> common_remote_get_content(const std::string& url, const common_remote_params& params);
398-
399385
//
400386
// String utils
401387
//
@@ -512,12 +498,6 @@ std::vector<llama_token> llama_tokenize(
512498
bool add_special,
513499
bool parse_special = false);
514500

515-
std::vector<llama_token> llama_tokenize(
516-
const struct llama_vocab* vocab,
517-
const std::string& text,
518-
bool add_special,
519-
bool parse_special = false);
520-
521501
// tokenizes a token into a piece, optionally renders special/control tokens
522502
// should work similar to Python's `tokenizer.id_to_piece`
523503
std::string llama_token_to_piece(
@@ -534,16 +514,70 @@ std::string llama_token_to_piece(
534514
// should work similar to Python's `tokenizer.decode`
535515
// optionally renders special/control tokens
536516
std::string llama_detokenize(
537-
const llama_context * ctx,
517+
llama_context * ctx,
538518
const std::vector<llama_token> & tokens,
539519
bool special = true);
540520

541-
542521
// Uses the value from the model metadata if possible, otherwise
543522
// defaults to true when model type is SPM, otherwise false.
544523
bool llama_should_add_bos_token(const llama_model * model);
545524

546-
525+
//
526+
// Chat template utils
527+
//
528+
//struct common_tool_call {
529+
// std::string name;
530+
// std::string arguments;
531+
// std::string id;
532+
//};
533+
//
534+
//// same with llama_chat_message, but uses std::string
535+
//struct common_chat_msg {
536+
// std::string role;
537+
// std::string content;
538+
// std::vector<common_tool_call> tool_calls;
539+
// std::string reasoning_content = "";
540+
//};
541+
542+
//// Check if the template supplied via "--chat-template" is supported or not. Returns true if it's valid
543+
//bool llama_chat_verify_template(const struct llama_model* , const std::string& tmpl, bool use_jinja);
544+
//
545+
//namespace minja {
546+
// class chat_template;
547+
//}
548+
//
549+
//typedef minja::chat_template common_chat_template;
550+
//
551+
//struct common_chat_templates {
552+
// bool has_explicit_template; // Model had builtin template or template overridde was specified.
553+
// std::unique_ptr<common_chat_template> template_default; // always set (defaults to chatml)
554+
// std::unique_ptr<common_chat_template> template_tool_use;
555+
//};
556+
//
557+
//
558+
//// CPP wrapper for llama_chat_apply_template
559+
//// If the built-in template is not supported, we default to chatml
560+
//// If the custom "tmpl" is not supported, we throw an error
561+
//std::string llama_chat_apply_template(
562+
// const struct llama_model* model,
563+
// const common_chat_template& tmpl,
564+
// const std::vector< common_chat_msg>& chat,
565+
// bool add_ass,
566+
// bool use_jinja);
567+
//
568+
//// Format single message, while taking into account the position of that message in chat history
569+
//std::string llama_chat_format_single(const struct llama_model* model,
570+
// const common_chat_template& tmpl,
571+
// const std::vector< common_chat_msg>& past_msg,
572+
// const common_chat_msg& new_msg,
573+
// bool add_ass,
574+
// bool use_jinja);
575+
//
576+
//// Returns an example of formatted chat
577+
//std::string llama_chat_format_example(const struct llama_model* model,
578+
// const common_chat_template& tmpl, bool use_jinja);
579+
//
580+
//common_chat_templates llama_chat_templates_from_model(const struct llama_model* model, const std::string& chat_template_override);
547581

548582

549583
//

examples/mtmd/clip.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3331,7 +3331,7 @@ struct image_manipulation {
33313331
dst.buf.resize(3 * target_width * target_height);
33323332

33333333
float Cc;
3334-
float C[5] = {};
3334+
float C[5];
33353335
float d0, d2, d3, a0, a1, a2, a3;
33363336
int i, j, k, jj;
33373337
int x, y;

examples/server/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ endif()
7070
target_include_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR})
7171
target_link_libraries(${TARGET} PRIVATE common ${CMAKE_THREAD_LIBS_INIT})
7272

73-
target_include_directories(${TARGET} PRIVATE ../mtmd)
74-
target_link_libraries(${TARGET} PRIVATE common mtmd ${CMAKE_THREAD_LIBS_INIT})
75-
7673
if (LLAMA_SERVER_SSL)
7774
find_package(OpenSSL REQUIRED)
7875
target_link_libraries(${TARGET} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
-572 KB
Binary file not shown.

0 commit comments

Comments
 (0)