llamamodel: fix macOS build (#2125)

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
Jared Van Bortel 2024-03-14 12:06:07 -04:00 committed by GitHub
parent 667f29c2a1
commit 53f109f519
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -791,14 +791,16 @@ void LLamaModel::embedInternal(
}
// split into max_len-sized chunks
struct split_batch { int idx; TokenString batch; };
struct split_batch { unsigned idx; TokenString batch; };
std::vector<split_batch> batches;
for (unsigned i = 0; i < inputs.size(); i++) {
auto &input = inputs[i];
for (auto it = input.begin(); it < input.end(); it += max_len) {
if (it > input.begin()) { it -= chunkOverlap; }
auto end = std::min(it + max_len, input.end());
auto &batch = batches.emplace_back(i, prefixTokens).batch;
batches.push_back({ i, {} });
auto &batch = batches.back().batch;
batch = prefixTokens;
batch.insert(batch.end(), it, end);
batch.push_back(eos_token);
if (!doMean) { break; /* limit text to one chunk */ }