bigdl-core-cpp 2.5.0rc1__py3-none-win_amd64.whl → 2.6.0__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bigdl/cpp/{convert-hf-to-gguf.py → convert_hf_to_gguf.py} +1673 -278
- bigdl/cpp/convert_hf_to_gguf_update.py +381 -0
- bigdl/cpp/convert_llama_ggml_to_gguf.py +450 -0
- bigdl/cpp/convert_lora_to_gguf.py +461 -0
- bigdl/cpp/gguf-py/gguf/__init__.py +1 -1
- bigdl/cpp/gguf-py/gguf/constants.py +698 -171
- bigdl/cpp/gguf-py/gguf/gguf.py +1 -1
- bigdl/cpp/gguf-py/gguf/gguf_reader.py +5 -6
- bigdl/cpp/gguf-py/gguf/gguf_writer.py +108 -17
- bigdl/cpp/gguf-py/gguf/lazy.py +3 -1
- bigdl/cpp/gguf-py/gguf/metadata.py +195 -76
- bigdl/cpp/gguf-py/gguf/quants.py +1210 -64
- bigdl/cpp/gguf-py/gguf/tensor_mapping.py +262 -43
- bigdl/cpp/gguf-py/gguf/utility.py +2 -2
- bigdl/cpp/gguf-py/gguf/vocab.py +325 -3
- bigdl/cpp/libs/common.lib +0 -0
- bigdl/cpp/libs/ggml-base.dll +0 -0
- bigdl/cpp/libs/ggml-cpu.dll +0 -0
- bigdl/cpp/libs/ggml-sycl.dll +0 -0
- bigdl/cpp/libs/ggml.dll +0 -0
- bigdl/cpp/libs/libc++.dll +0 -0
- bigdl/cpp/libs/llama-batched.exe +0 -0
- bigdl/cpp/libs/llama-bench.exe +0 -0
- bigdl/cpp/libs/llama-cli.exe +0 -0
- bigdl/cpp/libs/llama-embedding.exe +0 -0
- bigdl/cpp/libs/llama-gemma3-cli.exe +0 -0
- bigdl/cpp/libs/llama-gguf.exe +0 -0
- bigdl/cpp/libs/llama-llava-cli.exe +0 -0
- bigdl/cpp/libs/llama-lookup.exe +0 -0
- bigdl/cpp/libs/llama-ls-sycl-device.exe +0 -0
- bigdl/cpp/libs/llama-minicpmv-cli.exe +0 -0
- bigdl/cpp/libs/llama-perplexity.exe +0 -0
- bigdl/cpp/libs/llama-quantize.exe +0 -0
- bigdl/cpp/libs/llama-server.exe +0 -0
- bigdl/cpp/libs/llama-simple.exe +0 -0
- bigdl/cpp/libs/llama-speculative.exe +0 -0
- bigdl/cpp/libs/llama-tokenize.exe +0 -0
- bigdl/cpp/libs/llama.dll +0 -0
- bigdl/cpp/libs/llava_shared.dll +0 -0
- bigdl/cpp/libs/ollama-ggml-base.dll +0 -0
- bigdl/cpp/libs/ollama-ggml-cpu.dll +0 -0
- bigdl/cpp/libs/ollama-ggml-sycl.dll +0 -0
- bigdl/cpp/libs/ollama-lib.exe +0 -0
- bigdl/cpp/libs/ollama.exe +0 -0
- bigdl/cpp/libs/ollama_ggml.dll +0 -0
- bigdl/cpp/libs/ollama_llama.dll +0 -0
- bigdl/cpp/libs/ollama_llava_shared.dll +0 -0
- {bigdl_core_cpp-2.5.0rc1.data → bigdl_core_cpp-2.6.0.data}/scripts/init-llama-cpp.bat +7 -2
- bigdl_core_cpp-2.6.0.data/scripts/init-ollama.bat +16 -0
- {bigdl_core_cpp-2.5.0rc1.dist-info → bigdl_core_cpp-2.6.0.dist-info}/METADATA +9 -5
- bigdl_core_cpp-2.6.0.dist-info/RECORD +57 -0
- {bigdl_core_cpp-2.5.0rc1.dist-info → bigdl_core_cpp-2.6.0.dist-info}/WHEEL +1 -1
- bigdl/cpp/convert.py +0 -1714
- bigdl/cpp/libs/baby-llama.exe +0 -0
- bigdl/cpp/libs/batched-bench.exe +0 -0
- bigdl/cpp/libs/batched.exe +0 -0
- bigdl/cpp/libs/beam-search.exe +0 -0
- bigdl/cpp/libs/benchmark.exe +0 -0
- bigdl/cpp/libs/convert-llama2c-to-ggml.exe +0 -0
- bigdl/cpp/libs/dist/windows-amd64/ollama_runners/cpu/ollama_llama_server.exe +0 -0
- bigdl/cpp/libs/dist/windows-amd64/ollama_runners/cpu_avx/ollama_llama_server.exe +0 -0
- bigdl/cpp/libs/dist/windows-amd64/ollama_runners/cpu_avx2/ollama_llama_server.exe +0 -0
- bigdl/cpp/libs/embedding.exe +0 -0
- bigdl/cpp/libs/export-lora.exe +0 -0
- bigdl/cpp/libs/finetune.exe +0 -0
- bigdl/cpp/libs/ggml_shared.dll +0 -0
- bigdl/cpp/libs/gguf.exe +0 -0
- bigdl/cpp/libs/gritlm.exe +0 -0
- bigdl/cpp/libs/imatrix.exe +0 -0
- bigdl/cpp/libs/infill.exe +0 -0
- bigdl/cpp/libs/llava-cli.exe +0 -0
- bigdl/cpp/libs/lookahead.exe +0 -0
- bigdl/cpp/libs/lookup.exe +0 -0
- bigdl/cpp/libs/ls-sycl-device.exe +0 -0
- bigdl/cpp/libs/main.exe +0 -0
- bigdl/cpp/libs/parallel.exe +0 -0
- bigdl/cpp/libs/passkey.exe +0 -0
- bigdl/cpp/libs/perplexity.exe +0 -0
- bigdl/cpp/libs/q8dot.exe +0 -0
- bigdl/cpp/libs/quantize-stats.exe +0 -0
- bigdl/cpp/libs/quantize.exe +0 -0
- bigdl/cpp/libs/save-load-state.exe +0 -0
- bigdl/cpp/libs/server.exe +0 -0
- bigdl/cpp/libs/simple.exe +0 -0
- bigdl/cpp/libs/speculative.exe +0 -0
- bigdl/cpp/libs/tokenize.exe +0 -0
- bigdl/cpp/libs/train-text-from-scratch.exe +0 -0
- bigdl/cpp/libs/vdot.exe +0 -0
- bigdl_core_cpp-2.5.0rc1.data/scripts/init-ollama.bat +0 -13
- bigdl_core_cpp-2.5.0rc1.dist-info/RECORD +0 -63
- {bigdl_core_cpp-2.5.0rc1.data → bigdl_core_cpp-2.6.0.data}/scripts/init-llama-cpp.ps1 +0 -0
- {bigdl_core_cpp-2.5.0rc1.dist-info → bigdl_core_cpp-2.6.0.dist-info}/top_level.txt +0 -0
bigdl/cpp/gguf-py/gguf/vocab.py
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
import re
|
3
4
|
import logging
|
4
5
|
import json
|
5
6
|
import os
|
6
7
|
from pathlib import Path
|
7
|
-
from typing import Any, Callable, Sequence, Mapping, Iterable
|
8
|
+
from typing import Any, Callable, Sequence, Mapping, Iterable, Protocol, ClassVar, runtime_checkable
|
9
|
+
|
10
|
+
from sentencepiece import SentencePieceProcessor
|
11
|
+
|
12
|
+
import gguf
|
8
13
|
|
9
14
|
from .gguf_writer import GGUFWriter
|
10
15
|
|
@@ -117,8 +122,30 @@ class SpecialVocab:
|
|
117
122
|
tokenizer = json.load(f)
|
118
123
|
if self.load_merges:
|
119
124
|
merges = tokenizer.get('model', {}).get('merges')
|
120
|
-
if isinstance(merges, list) and merges
|
121
|
-
|
125
|
+
if isinstance(merges, list) and merges:
|
126
|
+
if isinstance(merges[0], str):
|
127
|
+
self.merges = merges
|
128
|
+
elif isinstance(merges[0], list) and len(merges[0]) == 2 and isinstance(merges[0][0], str):
|
129
|
+
# New format since transformers 4.45 to support spaces in merges
|
130
|
+
# ref: https://github.com/ggml-org/llama.cpp/issues/9692
|
131
|
+
# TODO: internally store as the new format instead of converting to old
|
132
|
+
if any(' ' in s for pair in merges for s in pair):
|
133
|
+
logger.warning(f'Spaces in merges detected, encoding as {chr(ord(" ") + 256)!r}')
|
134
|
+
self.merges = [
|
135
|
+
' '.join(
|
136
|
+
[
|
137
|
+
# ensure the spaces are properly encoded
|
138
|
+
''.join(
|
139
|
+
chr(ord(c) + 256) if c == ' ' else c
|
140
|
+
for c in part
|
141
|
+
)
|
142
|
+
for part in pair
|
143
|
+
]
|
144
|
+
)
|
145
|
+
for pair in merges
|
146
|
+
]
|
147
|
+
else:
|
148
|
+
raise ValueError("Unknown tokenizer merges format")
|
122
149
|
added_tokens = tokenizer.get('added_tokens', {})
|
123
150
|
else:
|
124
151
|
added_tokens = {}
|
@@ -163,3 +190,298 @@ class SpecialVocab:
|
|
163
190
|
for typ in self.special_token_types:
|
164
191
|
self._set_special_token(typ, config.get(f'{typ}_token_id'))
|
165
192
|
return True
|
193
|
+
|
194
|
+
|
195
|
+
@runtime_checkable
|
196
|
+
class BaseVocab(Protocol):
|
197
|
+
tokenizer_model: ClassVar[str]
|
198
|
+
name: ClassVar[str]
|
199
|
+
|
200
|
+
|
201
|
+
@runtime_checkable
|
202
|
+
class Vocab(BaseVocab, Protocol):
|
203
|
+
vocab_size: int
|
204
|
+
added_tokens_dict: dict[str, int]
|
205
|
+
added_tokens_list: list[str]
|
206
|
+
fname_tokenizer: Path
|
207
|
+
|
208
|
+
def __init__(self, base_path: Path): ...
|
209
|
+
def all_tokens(self) -> Iterable[tuple[bytes, float, gguf.TokenType]]: ...
|
210
|
+
|
211
|
+
|
212
|
+
class NoVocab(BaseVocab):
|
213
|
+
tokenizer_model = "no_vocab"
|
214
|
+
name = "no_vocab"
|
215
|
+
|
216
|
+
def __repr__(self) -> str:
|
217
|
+
return "<NoVocab for a model without integrated vocabulary>"
|
218
|
+
|
219
|
+
|
220
|
+
class BpeVocab(Vocab):
|
221
|
+
tokenizer_model = "gpt2"
|
222
|
+
name = "bpe"
|
223
|
+
|
224
|
+
def __init__(self, base_path: Path):
|
225
|
+
added_tokens: dict[str, int] = {}
|
226
|
+
|
227
|
+
if (fname_tokenizer := base_path / 'vocab.json').exists():
|
228
|
+
# "slow" tokenizer
|
229
|
+
with open(fname_tokenizer, encoding="utf-8") as f:
|
230
|
+
self.vocab = json.load(f)
|
231
|
+
|
232
|
+
try:
|
233
|
+
# FIXME: Verify that added tokens here _cannot_ overlap with the main vocab.
|
234
|
+
with open(base_path / 'added_tokens.json', encoding="utf-8") as f:
|
235
|
+
added_tokens = json.load(f)
|
236
|
+
except FileNotFoundError:
|
237
|
+
pass
|
238
|
+
else:
|
239
|
+
# "fast" tokenizer
|
240
|
+
fname_tokenizer = base_path / 'tokenizer.json'
|
241
|
+
|
242
|
+
# if this fails, FileNotFoundError propagates to caller
|
243
|
+
with open(fname_tokenizer, encoding="utf-8") as f:
|
244
|
+
tokenizer_json = json.load(f)
|
245
|
+
|
246
|
+
tokenizer_model: dict[str, Any] = tokenizer_json['model']
|
247
|
+
if (
|
248
|
+
tokenizer_model['type'] != 'BPE' or tokenizer_model.get('byte_fallback', False)
|
249
|
+
or tokenizer_json['decoder']['type'] != 'ByteLevel'
|
250
|
+
):
|
251
|
+
raise FileNotFoundError('Cannot find GPT-2 BPE tokenizer')
|
252
|
+
|
253
|
+
self.vocab = tokenizer_model["vocab"]
|
254
|
+
|
255
|
+
if (added := tokenizer_json.get('added_tokens')) is not None:
|
256
|
+
# Added tokens here can be duplicates of the main vocabulary.
|
257
|
+
added_tokens = {item['content']: item['id']
|
258
|
+
for item in added
|
259
|
+
if item['content'] not in self.vocab}
|
260
|
+
|
261
|
+
vocab_size = len(self.vocab)
|
262
|
+
expected_ids = list(range(vocab_size, vocab_size + len(added_tokens)))
|
263
|
+
actual_ids = sorted(added_tokens.values())
|
264
|
+
if expected_ids != actual_ids:
|
265
|
+
expected_end_id = vocab_size + len(actual_ids) - 1
|
266
|
+
raise ValueError(f"Expected the {len(actual_ids)} added token ID(s) to be sequential in the range "
|
267
|
+
f"{vocab_size} - {expected_end_id}; got {actual_ids}")
|
268
|
+
|
269
|
+
items = sorted(added_tokens.items(), key=lambda text_idx: text_idx[1])
|
270
|
+
self.added_tokens_dict = added_tokens
|
271
|
+
self.added_tokens_list = [text for (text, idx) in items]
|
272
|
+
self.vocab_size_base = vocab_size
|
273
|
+
self.vocab_size = self.vocab_size_base + len(self.added_tokens_list)
|
274
|
+
self.fname_tokenizer = fname_tokenizer
|
275
|
+
|
276
|
+
def bpe_tokens(self) -> Iterable[tuple[bytes, float, gguf.TokenType]]:
|
277
|
+
reverse_vocab = {id: encoded_tok for encoded_tok, id in self.vocab.items()}
|
278
|
+
|
279
|
+
for i, _ in enumerate(self.vocab):
|
280
|
+
yield reverse_vocab[i], 0.0, gguf.TokenType.NORMAL
|
281
|
+
|
282
|
+
def added_tokens(self) -> Iterable[tuple[bytes, float, gguf.TokenType]]:
|
283
|
+
for text in self.added_tokens_list:
|
284
|
+
score = -1000.0
|
285
|
+
yield text.encode("utf-8"), score, gguf.TokenType.CONTROL
|
286
|
+
|
287
|
+
def all_tokens(self) -> Iterable[tuple[bytes, float, gguf.TokenType]]:
|
288
|
+
yield from self.bpe_tokens()
|
289
|
+
yield from self.added_tokens()
|
290
|
+
|
291
|
+
def __repr__(self) -> str:
|
292
|
+
return f"<BpeVocab with {self.vocab_size_base} base tokens and {len(self.added_tokens_list)} added tokens>"
|
293
|
+
|
294
|
+
|
295
|
+
class SentencePieceVocab(Vocab):
|
296
|
+
tokenizer_model = "llama"
|
297
|
+
name = "spm"
|
298
|
+
|
299
|
+
def __init__(self, base_path: Path):
|
300
|
+
added_tokens: dict[str, int] = {}
|
301
|
+
if (fname_tokenizer := base_path / 'tokenizer.model').exists():
|
302
|
+
# normal location
|
303
|
+
try:
|
304
|
+
with open(base_path / 'added_tokens.json', encoding="utf-8") as f:
|
305
|
+
added_tokens = json.load(f)
|
306
|
+
except FileNotFoundError:
|
307
|
+
pass
|
308
|
+
elif not (fname_tokenizer := base_path.parent / 'tokenizer.model').exists():
|
309
|
+
# not found in alternate location either
|
310
|
+
raise FileNotFoundError('Cannot find tokenizer.model')
|
311
|
+
|
312
|
+
self.sentencepiece_tokenizer = SentencePieceProcessor()
|
313
|
+
self.sentencepiece_tokenizer.LoadFromFile(str(fname_tokenizer))
|
314
|
+
vocab_size = self.sentencepiece_tokenizer.vocab_size()
|
315
|
+
|
316
|
+
new_tokens = {id: piece for piece, id in added_tokens.items() if id >= vocab_size}
|
317
|
+
expected_new_ids = list(range(vocab_size, vocab_size + len(new_tokens)))
|
318
|
+
actual_new_ids = sorted(new_tokens.keys())
|
319
|
+
|
320
|
+
if expected_new_ids != actual_new_ids:
|
321
|
+
raise ValueError(f"Expected new token IDs {expected_new_ids} to be sequential; got {actual_new_ids}")
|
322
|
+
|
323
|
+
# Token pieces that were added to the base vocabulary.
|
324
|
+
self.added_tokens_dict = added_tokens
|
325
|
+
self.added_tokens_list = [new_tokens[id] for id in actual_new_ids]
|
326
|
+
self.vocab_size_base = vocab_size
|
327
|
+
self.vocab_size = self.vocab_size_base + len(self.added_tokens_list)
|
328
|
+
self.fname_tokenizer = fname_tokenizer
|
329
|
+
|
330
|
+
def sentencepiece_tokens(self) -> Iterable[tuple[bytes, float, gguf.TokenType]]:
|
331
|
+
tokenizer = self.sentencepiece_tokenizer
|
332
|
+
for i in range(tokenizer.vocab_size()):
|
333
|
+
piece = tokenizer.IdToPiece(i)
|
334
|
+
text = piece.encode("utf-8")
|
335
|
+
score: float = tokenizer.GetScore(i)
|
336
|
+
|
337
|
+
toktype = gguf.TokenType.NORMAL
|
338
|
+
if tokenizer.IsUnknown(i):
|
339
|
+
toktype = gguf.TokenType.UNKNOWN
|
340
|
+
if tokenizer.IsControl(i):
|
341
|
+
toktype = gguf.TokenType.CONTROL
|
342
|
+
|
343
|
+
# NOTE: I think added_tokens are user defined.
|
344
|
+
# ref: https://github.com/google/sentencepiece/blob/master/src/sentencepiece_model.proto
|
345
|
+
# if tokenizer.is_user_defined(i): toktype = gguf.TokenType.USER_DEFINED
|
346
|
+
|
347
|
+
if tokenizer.IsUnused(i):
|
348
|
+
toktype = gguf.TokenType.UNUSED
|
349
|
+
if tokenizer.IsByte(i):
|
350
|
+
toktype = gguf.TokenType.BYTE
|
351
|
+
|
352
|
+
yield text, score, toktype
|
353
|
+
|
354
|
+
def added_tokens(self) -> Iterable[tuple[bytes, float, gguf.TokenType]]:
|
355
|
+
for text in self.added_tokens_list:
|
356
|
+
score = -1000.0
|
357
|
+
yield text.encode("utf-8"), score, gguf.TokenType.USER_DEFINED
|
358
|
+
|
359
|
+
def all_tokens(self) -> Iterable[tuple[bytes, float, gguf.TokenType]]:
|
360
|
+
yield from self.sentencepiece_tokens()
|
361
|
+
yield from self.added_tokens()
|
362
|
+
|
363
|
+
def __repr__(self) -> str:
|
364
|
+
return f"<SentencePieceVocab with {self.vocab_size_base} base tokens and {len(self.added_tokens_list)} added tokens>"
|
365
|
+
|
366
|
+
|
367
|
+
class LlamaHfVocab(Vocab):
|
368
|
+
tokenizer_model = "llama"
|
369
|
+
name = "hfft"
|
370
|
+
|
371
|
+
def __init__(self, base_path: Path):
|
372
|
+
fname_tokenizer = base_path / 'tokenizer.json'
|
373
|
+
# if this fails, FileNotFoundError propagates to caller
|
374
|
+
with open(fname_tokenizer, encoding='utf-8') as f:
|
375
|
+
tokenizer_json = json.load(f)
|
376
|
+
|
377
|
+
# pre-check so we know if we need transformers
|
378
|
+
tokenizer_model: dict[str, Any] = tokenizer_json['model']
|
379
|
+
is_llama3 = (
|
380
|
+
tokenizer_model['type'] == 'BPE' and tokenizer_model.get('ignore_merges', False)
|
381
|
+
and not tokenizer_model.get('byte_fallback', True)
|
382
|
+
)
|
383
|
+
if is_llama3:
|
384
|
+
raise TypeError('Llama 3 must be converted with BpeVocab')
|
385
|
+
|
386
|
+
if not is_llama3 and (
|
387
|
+
tokenizer_model['type'] != 'BPE' or not tokenizer_model.get('byte_fallback', False)
|
388
|
+
or tokenizer_json['decoder']['type'] != 'Sequence'
|
389
|
+
):
|
390
|
+
raise FileNotFoundError('Cannot find Llama BPE tokenizer')
|
391
|
+
|
392
|
+
try:
|
393
|
+
from transformers import AutoTokenizer
|
394
|
+
except ImportError as e:
|
395
|
+
raise ImportError(
|
396
|
+
"To use LlamaHfVocab, please install the `transformers` package. "
|
397
|
+
"You can install it with `pip install transformers`."
|
398
|
+
) from e
|
399
|
+
|
400
|
+
# Allow the tokenizer to default to slow or fast versions.
|
401
|
+
# Explicitly set tokenizer to use local paths.
|
402
|
+
self.tokenizer = AutoTokenizer.from_pretrained(
|
403
|
+
base_path,
|
404
|
+
cache_dir=base_path,
|
405
|
+
local_files_only=True,
|
406
|
+
)
|
407
|
+
assert self.tokenizer.is_fast # assume tokenizer.json is used
|
408
|
+
|
409
|
+
# Initialize lists and dictionaries for added tokens
|
410
|
+
self.added_tokens_list = []
|
411
|
+
self.added_tokens_dict = dict()
|
412
|
+
self.added_tokens_ids = set()
|
413
|
+
|
414
|
+
# Process added tokens
|
415
|
+
for tok, tokidx in sorted(
|
416
|
+
self.tokenizer.get_added_vocab().items(), key=lambda x: x[1]
|
417
|
+
):
|
418
|
+
# Only consider added tokens that are not in the base vocabulary
|
419
|
+
if tokidx >= self.tokenizer.vocab_size:
|
420
|
+
self.added_tokens_list.append(tok)
|
421
|
+
self.added_tokens_dict[tok] = tokidx
|
422
|
+
self.added_tokens_ids.add(tokidx)
|
423
|
+
|
424
|
+
# Store special tokens and their IDs
|
425
|
+
self.specials = {
|
426
|
+
tok: self.tokenizer.get_vocab()[tok]
|
427
|
+
for tok in self.tokenizer.all_special_tokens
|
428
|
+
}
|
429
|
+
self.special_ids = set(self.tokenizer.all_special_ids)
|
430
|
+
|
431
|
+
# Set vocabulary sizes
|
432
|
+
self.vocab_size_base = self.tokenizer.vocab_size
|
433
|
+
self.vocab_size = self.vocab_size_base + len(self.added_tokens_list)
|
434
|
+
|
435
|
+
self.fname_tokenizer = fname_tokenizer
|
436
|
+
|
437
|
+
def hf_tokens(self) -> Iterable[tuple[bytes, float, gguf.TokenType]]:
|
438
|
+
reverse_vocab = {
|
439
|
+
id: encoded_tok for encoded_tok, id in self.tokenizer.get_vocab().items()
|
440
|
+
}
|
441
|
+
|
442
|
+
for token_id in range(self.vocab_size_base):
|
443
|
+
# Skip processing added tokens here
|
444
|
+
if token_id in self.added_tokens_ids:
|
445
|
+
continue
|
446
|
+
|
447
|
+
# Convert token text to bytes
|
448
|
+
token_text = reverse_vocab[token_id].encode("utf-8")
|
449
|
+
|
450
|
+
# Yield token text, score, and type
|
451
|
+
yield token_text, self.get_token_score(token_id), self.get_token_type(
|
452
|
+
token_id, token_text, self.special_ids # Reuse already stored special IDs
|
453
|
+
)
|
454
|
+
|
455
|
+
def get_token_type(self, token_id: int, token_text: bytes, special_ids: set[int]) -> gguf.TokenType:
|
456
|
+
# Special case for byte tokens
|
457
|
+
if re.fullmatch(br"<0x[0-9A-Fa-f]{2}>", token_text):
|
458
|
+
return gguf.TokenType.BYTE
|
459
|
+
|
460
|
+
# Determine token type based on whether it's a special token
|
461
|
+
return gguf.TokenType.CONTROL if token_id in special_ids else gguf.TokenType.NORMAL
|
462
|
+
|
463
|
+
def get_token_score(self, token_id: int) -> float:
|
464
|
+
# Placeholder for actual logic to determine the token's score
|
465
|
+
# This needs to be implemented based on specific requirements
|
466
|
+
return -1000.0 # Default score
|
467
|
+
|
468
|
+
def added_tokens(self) -> Iterable[tuple[bytes, float, gguf.TokenType]]:
|
469
|
+
for text in self.added_tokens_list:
|
470
|
+
if text in self.specials:
|
471
|
+
toktype = self.get_token_type(self.specials[text], b'', self.special_ids)
|
472
|
+
score = self.get_token_score(self.specials[text])
|
473
|
+
else:
|
474
|
+
toktype = gguf.TokenType.USER_DEFINED
|
475
|
+
score = -1000.0
|
476
|
+
|
477
|
+
yield text.encode("utf-8"), score, toktype
|
478
|
+
|
479
|
+
def has_newline_token(self):
|
480
|
+
return "<0x0A>" in self.tokenizer.vocab or "\n" in self.tokenizer.vocab
|
481
|
+
|
482
|
+
def all_tokens(self) -> Iterable[tuple[bytes, float, gguf.TokenType]]:
|
483
|
+
yield from self.hf_tokens()
|
484
|
+
yield from self.added_tokens()
|
485
|
+
|
486
|
+
def __repr__(self) -> str:
|
487
|
+
return f"<LlamaHfVocab with {self.vocab_size_base} base tokens and {len(self.added_tokens_list)} added tokens>"
|
bigdl/cpp/libs/common.lib
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
bigdl/cpp/libs/ggml.dll
ADDED
Binary file
|
Binary file
|
Binary file
|
bigdl/cpp/libs/llama-bench.exe
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
bigdl/cpp/libs/llama.dll
CHANGED
Binary file
|
bigdl/cpp/libs/llava_shared.dll
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
bigdl/cpp/libs/ollama.exe
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -9,11 +9,16 @@ set "destination_folder=%cd%"
|
|
9
9
|
pushd "%lib_dir%"
|
10
10
|
for %%f in (*) do (
|
11
11
|
if not "%%f"=="ollama.exe" (
|
12
|
+
if exist "%destination_folder%\%%~nxf" (
|
13
|
+
del /f "%destination_folder%\%%~nxf"
|
14
|
+
)
|
12
15
|
mklink "%destination_folder%\%%~nxf" "%%~ff"
|
13
16
|
)
|
14
17
|
)
|
15
18
|
popd
|
16
19
|
|
17
|
-
copy "%cpp_dir%\
|
18
|
-
copy "%cpp_dir%\
|
20
|
+
copy "%cpp_dir%\convert_hf_to_gguf.py" .
|
21
|
+
copy "%cpp_dir%\convert_hf_to_gguf_update.py" .
|
22
|
+
copy "%cpp_dir%\convert_llama_ggml_to_gguf.py" .
|
23
|
+
copy "%cpp_dir%\convert_lora_to_gguf.py" .
|
19
24
|
xcopy /E /I "%cpp_dir%\gguf-py\" .\gguf-py
|
@@ -0,0 +1,16 @@
|
|
1
|
+
@echo off
|
2
|
+
for /f "delims=" %%i in ('python -c "import bigdl.cpp; print(bigdl.cpp.__file__)"') do set "cpp_file=%%i"
|
3
|
+
for %%a in ("%cpp_file%") do set "cpp_dir=%%~dpa"
|
4
|
+
|
5
|
+
set "cpp_dir=%cpp_dir:~0,-1%"
|
6
|
+
set "lib_dir=%cpp_dir%\libs"
|
7
|
+
|
8
|
+
:: Create symlinks for DLLs and EXE
|
9
|
+
for %%f in (ollama.exe ollama-lib.exe ollama_llama.dll ollama_ggml.dll ollama_llava_shared.dll ollama-ggml-base.dll ollama-ggml-cpu.dll ollama-ggml-sycl.dll libc++.dll) do (
|
10
|
+
if exist "%cd%\%%f" del /f "%cd%\%%f"
|
11
|
+
mklink "%cd%\%%f" "%lib_dir%\%%f"
|
12
|
+
)
|
13
|
+
|
14
|
+
:: Create symlink for dist directory
|
15
|
+
if exist "%cd%\dist" rmdir /s /q "%cd%\dist"
|
16
|
+
mklink /D "%cd%\dist" "%lib_dir%\dist"
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: bigdl-core-cpp
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.6.0
|
4
4
|
Summary: Large Language Model Develop Toolkit
|
5
5
|
Author: BigDL Authors
|
6
6
|
License: Apache License, Version 2.0
|
@@ -10,9 +10,13 @@ Classifier: Programming Language :: Python :: 3.9
|
|
10
10
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
11
11
|
Requires-Dist: torch==2.2.0
|
12
12
|
Requires-Dist: numpy==1.26.4
|
13
|
-
Requires-Dist: transformers
|
13
|
+
Requires-Dist: transformers==4.44.2
|
14
14
|
Requires-Dist: sentencepiece~=0.1.98
|
15
|
-
Requires-Dist: accelerate==0.
|
15
|
+
Requires-Dist: accelerate==0.33.0
|
16
16
|
Requires-Dist: protobuf<5.0.0,>=4.21.0
|
17
17
|
Requires-Dist: gguf>=0.1.0
|
18
|
-
|
18
|
+
Dynamic: author
|
19
|
+
Dynamic: classifier
|
20
|
+
Dynamic: license
|
21
|
+
Dynamic: requires-dist
|
22
|
+
Dynamic: summary
|
@@ -0,0 +1,57 @@
|
|
1
|
+
bigdl/cpp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
bigdl/cpp/convert_hf_to_gguf.py,sha256=GB6mGc_deGraPhQfUgU8i33odUb6WfMw0vVPcgZ_-ow,240529
|
3
|
+
bigdl/cpp/convert_hf_to_gguf_update.py,sha256=1BFKEkj0BMDB90lUB5p_-iR9rSVcjgYPGWmEw28avB8,17721
|
4
|
+
bigdl/cpp/convert_llama_ggml_to_gguf.py,sha256=0dKjRhmFzvWV4e-cuLmaeW14JrWUtZwerBmz8mYyMvI,19556
|
5
|
+
bigdl/cpp/convert_lora_to_gguf.py,sha256=sHrcutdgzrDR5H7ZiLPOLoMnkJKg8uZ7OcFhAZhPrLo,19073
|
6
|
+
bigdl/cpp/gguf-py/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
+
bigdl/cpp/gguf-py/gguf/__init__.py,sha256=h5GWs6SMXYR8giWZ7MTZzAc3hYsIJF-HAkdxtgXLOPo,228
|
8
|
+
bigdl/cpp/gguf-py/gguf/constants.py,sha256=CJ0LigNqlnEqYP8IhnJsKcst9fIm-huE4RccvkTYUbg,69188
|
9
|
+
bigdl/cpp/gguf-py/gguf/gguf.py,sha256=QpLc-xU055W2d7CEFvJp2gLIfGO63bdM24ZndZCH6rw,493
|
10
|
+
bigdl/cpp/gguf-py/gguf/gguf_reader.py,sha256=PUrx08ZwaUOz1gLw5JQ459Hi7JIeCdlHgZX7wXcTqbI,12702
|
11
|
+
bigdl/cpp/gguf-py/gguf/gguf_writer.py,sha256=pFgnwrsDupKxI3SHNQbfiuz7dUopCOqj3ERBPuZMkMo,39955
|
12
|
+
bigdl/cpp/gguf-py/gguf/lazy.py,sha256=YIYxGBWD-oKXU4HOvpHs9eiEn81HUgeSmt1mmHJlbdM,8814
|
13
|
+
bigdl/cpp/gguf-py/gguf/metadata.py,sha256=oBTb4DXi_h1L_gYm8x_JRVuEPR4GHlVHuM-iN0OxWoY,33244
|
14
|
+
bigdl/cpp/gguf-py/gguf/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
|
+
bigdl/cpp/gguf-py/gguf/quants.py,sha256=2z6vcK-kBefqZbYNmSEVmdZF_tXHeVb5NC6jCbBdgKc,62040
|
16
|
+
bigdl/cpp/gguf-py/gguf/tensor_mapping.py,sha256=w1JZkRIKHj2tKYADLDUvCOsQfVf8y7Y0ZwqmtmrtLBA,39549
|
17
|
+
bigdl/cpp/gguf-py/gguf/utility.py,sha256=Mx4mqamXtatL15LCH04mG-7SNBwPzP2T75ts0uBnEuI,3002
|
18
|
+
bigdl/cpp/gguf-py/gguf/vocab.py,sha256=QTdt4HZrn7onHqm2tpHTaEq2sL3yG07zbHqQR9iVfu8,20815
|
19
|
+
bigdl/cpp/libs/common.lib,sha256=n3K_h5QgdLN21tyOm6M1z-ZZ1iYsimm-QFdEe9Q2sr4,8645952
|
20
|
+
bigdl/cpp/libs/ggml-base.dll,sha256=7jigx8yb4yeHco7_H6SyDr35JVykjLgdX3dSLGXHcsk,643584
|
21
|
+
bigdl/cpp/libs/ggml-cpu.dll,sha256=9H7R6KXPOjgCDYC5MDxmIx1x1fISG7bHomsRR9ibqc8,1114624
|
22
|
+
bigdl/cpp/libs/ggml-sycl.dll,sha256=ABoeB-9mzloJlpvOFHF3I51Ij1Mz8jXR-ZJZUJZyXTE,5581312
|
23
|
+
bigdl/cpp/libs/ggml.dll,sha256=kKryD7z4T-GXpzJyuT9hDY_Z5F7KZrTJdoK7tGrk6uc,118272
|
24
|
+
bigdl/cpp/libs/libc++.dll,sha256=U0TVK2WfFQIJPP6Bz9SeJmgskm2iqZWJorx_DGdfKIw,1561600
|
25
|
+
bigdl/cpp/libs/llama-batched.exe,sha256=qBYxGqaeT-XkIbTtvH5NVoe-uimcgdbciP5EvWOq7n0,1741824
|
26
|
+
bigdl/cpp/libs/llama-bench.exe,sha256=ji47toe9jinMvm4mW_0ZdLu2U7b7RmqIRThcwDjJvR4,279552
|
27
|
+
bigdl/cpp/libs/llama-cli.exe,sha256=X-RXhTcprd737MAZLbGhtJZ4xajeS1M2iUEMjNHvVoA,1814016
|
28
|
+
bigdl/cpp/libs/llama-embedding.exe,sha256=fLt-tw5sebRVo0H_12RimAt0mgAeMfxP-AxD4fMSvic,1766912
|
29
|
+
bigdl/cpp/libs/llama-gemma3-cli.exe,sha256=5c8HNzHCro5sg9lGKnwnGViXjXjEj9LK-DXl-U-4XYM,2035200
|
30
|
+
bigdl/cpp/libs/llama-gguf.exe,sha256=dCF2umZIjaXz5kgvDmPfezR0jl5rZ4sOrsN1ej-YJ2M,59392
|
31
|
+
bigdl/cpp/libs/llama-llava-cli.exe,sha256=nHYQlifa5GoUkEt_-9TqFm0HXAKX5fFO3Md7uHVSPfo,2019840
|
32
|
+
bigdl/cpp/libs/llama-lookup.exe,sha256=W_2PzuonWgF1Vct6WjvFYZCLVvGJU-__6XBESMK-ooU,1802752
|
33
|
+
bigdl/cpp/libs/llama-ls-sycl-device.exe,sha256=Cm3518SDBhfC3hPirFZXbUyZX07uCERwuLH-OPuY7Vw,10240
|
34
|
+
bigdl/cpp/libs/llama-minicpmv-cli.exe,sha256=0hpPOtoMocOl3wfXh-ompCfDTP9GabnSuImxWU9aDO4,2017792
|
35
|
+
bigdl/cpp/libs/llama-perplexity.exe,sha256=b6MclCeblDWC7-DWxMmOO480fy2tPQadkG2D5gTCqAo,1888256
|
36
|
+
bigdl/cpp/libs/llama-quantize.exe,sha256=vu_aapO5lD9-qavOvkYpsQ0tOspZW9sMnrJZ5WnzC64,122880
|
37
|
+
bigdl/cpp/libs/llama-server.exe,sha256=HSrW7uChCv3tWBe-aMG0-NJQIh1-io_XwnKkgvMCJS8,4132352
|
38
|
+
bigdl/cpp/libs/llama-simple.exe,sha256=SuRTJXmgwRoxgUka2MFYArkofJawNXX5mATauGeqdTU,62464
|
39
|
+
bigdl/cpp/libs/llama-speculative.exe,sha256=P3dLyjIq59HDuk--OVfsaCAsPSCLS0az3Fd4TqiLx0c,1805312
|
40
|
+
bigdl/cpp/libs/llama-tokenize.exe,sha256=lcVOzsGgKe2SuJqNiQtDWRZqseiwNUBLGm3isyySfkY,89088
|
41
|
+
bigdl/cpp/libs/llama.dll,sha256=rK9b2_9b2BdMw501PNjV2B4DldVdNs1NGZVG7F2fvbY,1470464
|
42
|
+
bigdl/cpp/libs/llava_shared.dll,sha256=78Ez5oen9amLMNKDmOSn2bUVvL8TNArcl_Z7RM9cY7E,380416
|
43
|
+
bigdl/cpp/libs/ollama-ggml-base.dll,sha256=bFmhyKn_PvO13I2e68pjg16Q_aeh6Y6TGGOjL0ob_RM,523776
|
44
|
+
bigdl/cpp/libs/ollama-ggml-cpu.dll,sha256=aSrOt-Y7eRw0gE0YJjO4hf3tEtV4ijRxD4U4CDMHVRE,549376
|
45
|
+
bigdl/cpp/libs/ollama-ggml-sycl.dll,sha256=AeZf7VoQL40uQJ9FPLjYuWLlpJfsMqroUwzxN7ykhkc,5346816
|
46
|
+
bigdl/cpp/libs/ollama-lib.exe,sha256=eBr3NVdSehqMI3mySFkwzgVkGrfE__vU1k7KoSNnsxQ,25918464
|
47
|
+
bigdl/cpp/libs/ollama.exe,sha256=SBi5T85BNQ8SkmexhoN1FNrzcLNKVQcq0oPc6HpUbjQ,207360
|
48
|
+
bigdl/cpp/libs/ollama_ggml.dll,sha256=S94zaU79qeHmM0oGkVGZeAcIc7OEaJOovQSF2heJDDg,113152
|
49
|
+
bigdl/cpp/libs/ollama_llama.dll,sha256=6l48cWLrziagipsm96EN7Z9cKWB3mNCqISPTQukwfuk,1421312
|
50
|
+
bigdl/cpp/libs/ollama_llava_shared.dll,sha256=O9AMvxRljh_xwGOlNJNniuqmaNb4d55m5ueQkWHpejo,398336
|
51
|
+
bigdl_core_cpp-2.6.0.data/scripts/init-llama-cpp.bat,sha256=U0h6RifZxL3GGJp-0dxdZapQIvXUATSj644CURJL-lg,751
|
52
|
+
bigdl_core_cpp-2.6.0.data/scripts/init-llama-cpp.ps1,sha256=JFOylLxO4MKpllHhdbPuJ1xHi9azxDpzdJns8JtZpkU,501
|
53
|
+
bigdl_core_cpp-2.6.0.data/scripts/init-ollama.bat,sha256=0I2iBOFv3kR9hvEySGMRUU52-qwVhE7oRZnyWz-2z_U,657
|
54
|
+
bigdl_core_cpp-2.6.0.dist-info/METADATA,sha256=G5HIXXKcV0yN66dgaZhhUgnCOIMbjr0ugN9d9MZID_o,741
|
55
|
+
bigdl_core_cpp-2.6.0.dist-info/WHEEL,sha256=GRAwO4abswPoD8u6X5Ix8yKoy-wTIXRf_V-PAIDNIsM,97
|
56
|
+
bigdl_core_cpp-2.6.0.dist-info/top_level.txt,sha256=iGuLfZARD_qANcIMfy0tbbrC3EtCg6BSiH8icc3dLWs,6
|
57
|
+
bigdl_core_cpp-2.6.0.dist-info/RECORD,,
|