Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,7 +18,7 @@ nvmlInit()
|
|
| 18 |
gpu_h = nvmlDeviceGetHandleByIndex(0)
|
| 19 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 20 |
|
| 21 |
-
ctx_limit =
|
| 22 |
gen_limit = 1000
|
| 23 |
|
| 24 |
########################## text rwkv ################################################################
|
|
@@ -68,7 +68,11 @@ def evaluate(
|
|
| 68 |
for i in range(int(token_count)):
|
| 69 |
|
| 70 |
input_ids = pipeline_v6.encode(ctx)[-ctx_limit:] if i == 0 else [token]
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
for n in occurrence:
|
| 73 |
out[n] -= (args.alpha_presence + occurrence[n] * args.alpha_frequency)
|
| 74 |
|
|
|
|
| 18 |
gpu_h = nvmlDeviceGetHandleByIndex(0)
|
| 19 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 20 |
|
| 21 |
+
ctx_limit = 3000
|
| 22 |
gen_limit = 1000
|
| 23 |
|
| 24 |
########################## text rwkv ################################################################
|
|
|
|
| 68 |
for i in range(int(token_count)):
|
| 69 |
|
| 70 |
input_ids = pipeline_v6.encode(ctx)[-ctx_limit:] if i == 0 else [token]
|
| 71 |
+
CHUNK_LEN = 512
|
| 72 |
+
# out, state = model_v6.forward(input_ids, state)
|
| 73 |
+
while len(input_ids) > 0:
|
| 74 |
+
out, state = model_v6.forward(input_ids[:CHUNK_LEN], state)
|
| 75 |
+
input_ids = input_ids[CHUNK_LEN:]
|
| 76 |
for n in occurrence:
|
| 77 |
out[n] -= (args.alpha_presence + occurrence[n] * args.alpha_frequency)
|
| 78 |
|