File size: 1,199 Bytes
f77c1f2
 
 
 
 
 
 
447fbbb
 
 
 
 
 
 
 
 
 
 
 
 
 
f77c1f2
447fbbb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
    sys.path.insert(0, str(ROOT))

import os

from nzfc_gram_runtime import NZFCGramLongMemoryChat
from nzfc_gram_runtime.quality import attach_answer_quality_governor
from nzfc_gram_runtime.large_document import attach_large_document_memory
from nzfc_gram_runtime.diffusiongemma_adapter import attach_diffusiongemma_block_diffusion

MODEL_ID = 'google/diffusiongemma-26B-A4B-it'

if os.environ.get('LOAD_MODEL', '0') != '1':
    print('Set LOAD_MODEL=1 to run this optional model-load check.')
    raise SystemExit(0)

bot = NZFCGramLongMemoryChat(
    repo_dir=str(ROOT),
    model_id=MODEL_ID,
    memory_db_path='./optional_model_load_memory.sqlite3',
    load_model=False,
    require_model=False,
    preload_static_memory=False,
)

attach_large_document_memory(bot)
attach_answer_quality_governor(bot)

meta = attach_diffusiongemma_block_diffusion(
    bot,
    model_id=MODEL_ID,
    device_map='auto',
    dtype='auto',
)

print(meta)

out = bot.generate_answer(
    system_prompt='You are concise.',
    user_prompt='Say DIFFUSIONGEMMA_OK.',
    max_new_tokens=32,
)

print(out)