This commit is contained in:
Roy Han 2024-07-01 16:29:54 -07:00
parent 1a0c8b363c
commit 512e0a7bde
3 changed files with 0 additions and 33 deletions

View File

@ -1206,7 +1206,6 @@ struct llama_server_context
res.result_json = json
{
{"embedding", std::vector<float>(n_embd, 0.0f)},
{"truncated", slot.truncated}
};
}
else
@ -1224,7 +1223,6 @@ struct llama_server_context
res.result_json = json
{
{"embedding", std::vector<float>(n_embd, 0.0f)},
{"truncated", slot.truncated}
};
continue;
}
@ -1233,7 +1231,6 @@ struct llama_server_context
res.result_json = json
{
{"embedding", std::vector<float>(embd, embd + n_embd)},
{"truncated", slot.truncated}
};
}
}
@ -3063,7 +3060,6 @@ int main(int argc, char **argv) {
if (!json_value(data, "stream", false)) {
std::string completion_text;
task_result result = llama.queue_results.recv(task_id);
LOG_INFO("completion", {{"result", result.result_json}});
if (!result.error && result.stop) {
res.set_content(result.result_json.dump(-1, ' ', false, json::error_handler_t::replace), "application/json; charset=utf-8");
}
@ -3079,7 +3075,6 @@ int main(int argc, char **argv) {
while (true)
{
task_result result = llama.queue_results.recv(task_id);
LOG_INFO("completion", {{"result", result.result_json}});
if (!result.error) {
const std::string str =
"data: " +

View File

@ -656,20 +656,3 @@ static json probs_vector_to_json(const llama_context *ctx, const std::vector<com
}
return out;
}
// // normalize a vector
// static std::vector<float> normalize_vector(const std::vector<float>& vec, int size) {
// double sum = 0.0;
// for (float value : vec) {
// sum += value * value;
// }
// sum = std::sqrt(sum);
// const float norm = sum > 0.0 ? 1.0f / sum : 0.0f;
// std::vector<float> normalized_vec(size);
// for (int i = 0; i < size; i++) {
// normalized_vec[i] = vec[i] * norm;
// }
// return normalized_vec;
// }

View File

@ -533,17 +533,6 @@ func (s *Server) EmbeddingsHandler(c *gin.Context) {
return
}
// assert that embedding is normalized
sum := 0.0
for _, v := range embedding {
sum += v * v
}
if math.Abs(sum-1) < 1e-6 {
slog.Info("embedding is normalized", "sum", sum)
} else {
slog.Info("embedding is not normalized", "sum", sum)
}
resp := api.EmbeddingResponse{
Embedding: embedding,
}