Spaces:
Runtime error
Runtime error
MaduRox commited on
Commit ·
74aa433
1
Parent(s): 9ab7159
fix: configure clean chat template and hybrid RIF sliding window on T4 GPU
Browse files61 unmodified lines6263646566676869707172737475761 unmodified line787980818283848586878861 unmodified lines_load_model(device, dtype)messages = [{"role": "system", "content": "You are a helpful, intelligent AI assistant. Always answer user queries clearly, accurately, and concisely in English."},{"role": "user", "content": prompt.strip()}]fmt = _LOCAL_TOKENIZER.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = _LOCAL_TOKENIZER(fmt, return_tensors="pt").to(device)num_layers = getattr(_LOCAL_QWEN_MODEL.config, "num_hidden_layers", 24)cache = KalpanaDynamicCache(num_layers=num_layers, bands=2048)t0 = time.perf_counter()with torch.inference_mode():1 unmodified line**inputs,past_key_values=cache,max_new_tokens=int(max_tokens),do_sample=True,temperature=float(temperature) if float(temperature) > 0 else 0.6,top_p=0.85,top_k=40,repetition_penalty=1.15,pad_token_id=_LOCAL_TOKENIZER.eos_token_id,)t1 = time.perf_counter()61 unmodified lines6263646566676869707172731 unmodified line7576777879808182838461 unmodified lines_load_model(device, dtype)messages = [{"role": "user", "content": prompt.strip()}]fmt = _LOCAL_TOKENIZER.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = _LOCAL_TOKENIZER(fmt, return_tensors="pt").to(device)num_layers = getattr(_LOCAL_QWEN_MODEL.config, "num_hidden_layers", 24)cache = KalpanaDynamicCache(num_layers=num_layers, bands=2048, sliding_window=128)t0 = time.perf_counter()with torch.inference_mode():1 unmodified line**inputs,past_key_values=cache,max_new_tokens=int(max_tokens),do_sample=(float(temperature) > 0),temperature=float(temperature) if float(temperature) > 0 else 1.0,top_p=0.9,repetition_penalty=1.1,pad_token_id=_LOCAL_TOKENIZER.eos_token_id,)t1 = time.perf_counter()
app.py+6-10