Merge pull request 'Evaluate LiSA recovery with complete answers at 3–5 attention layers' (#14) from codex/lisa-full-answer into main
Reviewed-on: #14
This commit was merged in pull request #14.
This commit is contained in:
@@ -0,0 +1,221 @@
|
|||||||
|
"""Freeze numeric tasks and screen the effect of sharing on complete answers."""
|
||||||
|
import argparse
|
||||||
|
from hashlib import sha256
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import random
|
||||||
|
import re
|
||||||
|
|
||||||
|
import torch
|
||||||
|
from tokenizers import Tokenizer
|
||||||
|
|
||||||
|
from crossqkv.lisa_effect_screen import WORDS
|
||||||
|
from crossqkv.lisa_generate import GenerationDecoder, generate
|
||||||
|
from crossqkv.lisa_tail import TorchTail
|
||||||
|
from functional.model import StreamingLM
|
||||||
|
from functional.run import write_json
|
||||||
|
|
||||||
|
|
||||||
|
TASKS = ('lookup', 'latest', 'addition', 'count')
|
||||||
|
SEEDS = {'screen': 621001, 'fit': 621002, 'validation': 621003, 'test': 621004}
|
||||||
|
COUNTS = {'screen': 8, 'fit': 24, 'validation': 8, 'test': 32}
|
||||||
|
SCHEDULES = {'native': (), 'direct_3': (15, 19, 23),
|
||||||
|
'direct_4': (11, 15, 19, 23), 'direct_5': (7, 11, 15, 19, 23)}
|
||||||
|
STOP_TEXT = ('<|im_end|>', '<|endoftext|>')
|
||||||
|
MAX_NEW_TOKENS = 24
|
||||||
|
|
||||||
|
|
||||||
|
def fixed_problems():
|
||||||
|
output = {}
|
||||||
|
for split, seed in SEEDS.items():
|
||||||
|
rng = random.Random(seed)
|
||||||
|
rows = []
|
||||||
|
for task in TASKS:
|
||||||
|
for i in range(COUNTS[split]):
|
||||||
|
if task in ('lookup', 'latest'):
|
||||||
|
keys = rng.sample(WORDS, 12)
|
||||||
|
values = rng.sample(range(20, 100), 12)
|
||||||
|
pos = rng.randrange(len(keys))
|
||||||
|
key = keys[pos]
|
||||||
|
if task == 'latest':
|
||||||
|
later = rng.randrange(1, len(keys))
|
||||||
|
earlier = rng.randrange(later)
|
||||||
|
keys[earlier] = keys[later]
|
||||||
|
pos, key = later, keys[later]
|
||||||
|
schedule = ', '.join(f'{k}={v}' for k, v in zip(keys, values))
|
||||||
|
descriptor = 'last recorded' if task == 'latest' else 'recorded'
|
||||||
|
question = f'Records in time order: {schedule}.\nWhat is the {descriptor} number for {key}?'
|
||||||
|
answer = values[pos]
|
||||||
|
elif task == 'addition':
|
||||||
|
a, b = sorted((rng.randint(20, 89), rng.randint(20, 89)))
|
||||||
|
question = f'What is {a} plus {b}?'
|
||||||
|
answer = a + b
|
||||||
|
else:
|
||||||
|
first, second = rng.sample(WORDS, 2)
|
||||||
|
answer = rng.randint(10, 15)
|
||||||
|
values = [first] * answer + [second] * rng.randint(3, 9)
|
||||||
|
rng.shuffle(values)
|
||||||
|
question = f"Items: {', '.join(values)}.\nHow many items are exactly '{first}'?"
|
||||||
|
rows.append({'id': f'{split}-{task}-{i:03}', 'task': task,
|
||||||
|
'question': question, 'answer': answer})
|
||||||
|
output[split] = rows
|
||||||
|
# Arithmetic questions can repeat across independently seeded splits.
|
||||||
|
# Keep the first generated occurrence and fill duplicates with new disjoint sums.
|
||||||
|
used = set()
|
||||||
|
replacement = random.Random(621005)
|
||||||
|
for rows in output.values():
|
||||||
|
for row in rows:
|
||||||
|
while row['task'] == 'addition' and row['question'] in used:
|
||||||
|
a, b = sorted((replacement.randint(20, 89), replacement.randint(20, 89)))
|
||||||
|
row.update(question=f'What is {a} plus {b}?', answer=a+b)
|
||||||
|
if row['question'] in used:
|
||||||
|
raise ValueError('Prompt repeated across the frozen set')
|
||||||
|
used.add(row['question'])
|
||||||
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
def prompt(question):
|
||||||
|
return ('<|im_start|>user\n' + question + '\nReply with the integer and no other text.'
|
||||||
|
'<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n')
|
||||||
|
|
||||||
|
|
||||||
|
def final_integer(text):
|
||||||
|
# Only completed reasoning prefixes precede an answer.
|
||||||
|
text = re.sub(r'\A\s*(?:<think>.*?</think>\s*)+', '', text, flags=re.S).strip()
|
||||||
|
if '<think>' in text or '</think>' in text:
|
||||||
|
return None
|
||||||
|
match = re.fullmatch(r'(?:[Ff]inal answer:\s*|[Aa]nswer:\s*)?([+-]?\d+)\.?', text)
|
||||||
|
if not match:
|
||||||
|
match = re.search(r'(?:^|\n)\s*(?:[Ff]inal answer|[Aa]nswer):\s*([+-]?\d+)\.?\s*\Z', text)
|
||||||
|
return int(match[1]) if match else None
|
||||||
|
|
||||||
|
|
||||||
|
def grade(tokenizer, tokens, stop, expected):
|
||||||
|
whole = tokenizer.decode(tokens, skip_special_tokens=False)
|
||||||
|
body = tokenizer.decode(tokens[:-1] if stop == 'eos' else tokens,
|
||||||
|
skip_special_tokens=False)
|
||||||
|
value = final_integer(body) if stop == 'eos' else None
|
||||||
|
return {'tokens': tokens, 'response': whole, 'stop': stop, 'answer': value,
|
||||||
|
'correct': value == expected}
|
||||||
|
|
||||||
|
|
||||||
|
def evaluate(model, tokenizer, examples, arms, adapters=None):
|
||||||
|
stop_ids = {tokenizer.token_to_id(text) for text in STOP_TEXT}
|
||||||
|
if None in stop_ids or len(stop_ids) != len(STOP_TEXT):
|
||||||
|
raise ValueError('Unexpected tokenizer stop tokens')
|
||||||
|
ids = [tokenizer.encode(prompt(x['question']), add_special_tokens=False).ids for x in examples]
|
||||||
|
expanded = [x for x in ids for _ in arms]
|
||||||
|
schedules = list(arms.values()) * len(examples)
|
||||||
|
predictions = iter(generate(model, expanded, schedules, stop_ids, MAX_NEW_TOKENS, adapters))
|
||||||
|
return [{'id': x['id'], 'task': x['task'], 'gold': x['answer'],
|
||||||
|
'arms': {mode: grade(tokenizer, *next(predictions), x['answer']) for mode in arms}}
|
||||||
|
for x in examples]
|
||||||
|
|
||||||
|
|
||||||
|
def summarize(rows):
|
||||||
|
results = {}
|
||||||
|
for task in TASKS:
|
||||||
|
group = [row for row in rows if row['task'] == task]
|
||||||
|
results[task] = {}
|
||||||
|
for name in SCHEDULES:
|
||||||
|
original_correct = lambda row: row['arms']['native']['correct']
|
||||||
|
produced_wrong = lambda row: row['arms'][name]['answer'] is not None and not row['arms'][name]['correct']
|
||||||
|
results[task][name] = {
|
||||||
|
'n': len(group),
|
||||||
|
'correct': sum(row['arms'][name]['correct'] for row in group),
|
||||||
|
'unscored': sum(row['arms'][name]['answer'] is None for row in group),
|
||||||
|
'native_correct_to_wrong_integer': [
|
||||||
|
row['id'] for row in group if original_correct(row) and produced_wrong(row)],
|
||||||
|
}
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def choose(summary):
|
||||||
|
options = []
|
||||||
|
for task, arms in summary.items():
|
||||||
|
if arms['native']['correct'] >= 6:
|
||||||
|
for arm in ('direct_3', 'direct_4', 'direct_5'):
|
||||||
|
losses = arms[arm]['native_correct_to_wrong_integer']
|
||||||
|
if len(losses) >= 2:
|
||||||
|
options.append((len(losses), arms['native']['correct'],
|
||||||
|
len(SCHEDULES[arm]), task, arm))
|
||||||
|
if not options:
|
||||||
|
return None
|
||||||
|
_, _, _, task, arm = max(options)
|
||||||
|
return {'task': task, 'arm': arm, 'recipients': list(SCHEDULES[arm])}
|
||||||
|
|
||||||
|
|
||||||
|
def fingerprint(path):
|
||||||
|
return sha256(path.read_bytes()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument('--source', required=True, type=Path)
|
||||||
|
parser.add_argument('--out', required=True, type=Path)
|
||||||
|
parser.add_argument('--seconds', default=21600, type=int)
|
||||||
|
parser.add_argument('--batch-prompts', default=2, type=int, choices=(1, 2))
|
||||||
|
parser.add_argument('--execution-batch-prompts', type=int, choices=(1, 2),
|
||||||
|
help='Use a different execution batch on resume after replaying completed rows')
|
||||||
|
parser.add_argument('--preflight', action='store_true')
|
||||||
|
args = parser.parse_args()
|
||||||
|
torch.set_num_threads(1)
|
||||||
|
args.out.mkdir(exist_ok=True)
|
||||||
|
files = {name: fingerprint(args.source/name) for name in
|
||||||
|
('manifest.json', 'model_config.json', 'tokenizer.json')}
|
||||||
|
protocol = {'weights': files, 'schedules': SCHEDULES, 'cap': MAX_NEW_TOKENS,
|
||||||
|
'stops': STOP_TEXT, 'batch_prompts': args.batch_prompts,
|
||||||
|
'decode': 'full vocabulary greedy, closed thinking prefix'}
|
||||||
|
manifest = args.out/'frozen.json'
|
||||||
|
frozen = {'protocol': protocol, 'problems': fixed_problems()}
|
||||||
|
frozen = json.loads(json.dumps(frozen))
|
||||||
|
if manifest.exists() and json.loads(manifest.read_text()) != frozen:
|
||||||
|
raise ValueError('Frozen protocol or prompts changed')
|
||||||
|
write_json(manifest, frozen)
|
||||||
|
model = StreamingLM(args.source/'weights', json.loads((args.source/'model_config.json').read_text()),
|
||||||
|
seconds=args.seconds, process_swap_limit_kib=None)
|
||||||
|
tokenizer = Tokenizer.from_file(str(args.source/'tokenizer.json'))
|
||||||
|
examples = frozen['problems']['screen']
|
||||||
|
if args.preflight:
|
||||||
|
ids = torch.tensor([tokenizer.encode(prompt(examples[0]['question']),
|
||||||
|
add_special_tokens=False).ids])
|
||||||
|
hidden = torch.from_numpy(model.embedding(ids.numpy()))
|
||||||
|
with torch.no_grad():
|
||||||
|
expected, _ = TorchTail(model, 0)(hidden, None, torch.tensor([ids.shape[1]]),
|
||||||
|
'native', ())
|
||||||
|
decoder = GenerationDecoder(model, [()], [0])
|
||||||
|
decoder.advance(ids[:, :-2])
|
||||||
|
actual = decoder.advance(ids[:, -2:])
|
||||||
|
ref = expected[:, -2:]
|
||||||
|
torch.testing.assert_close(actual, ref, atol=8e-5, rtol=7e-5)
|
||||||
|
write_json(args.out/'preflight.json', {'prompt_id': examples[0]['id'],
|
||||||
|
'prompt_tokens': ids.shape[1], 'tail_hidden_max_abs': float((actual-ref).abs().max())})
|
||||||
|
return
|
||||||
|
path = args.out/'screen-rows.json'
|
||||||
|
rows = json.loads(path.read_text()) if path.exists() else []
|
||||||
|
if [r['id'] for r in rows] != [x['id'] for x in examples[:len(rows)]]:
|
||||||
|
raise ValueError('Existing screen results do not match frozen prompts')
|
||||||
|
batch = args.execution_batch_prompts or args.batch_prompts
|
||||||
|
if batch != args.batch_prompts:
|
||||||
|
if len(rows) < batch:
|
||||||
|
raise ValueError('The alternate batch requires enough already evaluated prompts for replay')
|
||||||
|
replay = evaluate(model, tokenizer, examples[:batch], SCHEDULES)
|
||||||
|
if replay != rows[:batch]:
|
||||||
|
raise ValueError('Alternate batch changed the first completed token streams')
|
||||||
|
write_json(args.out/'execution-batch-replay.json',
|
||||||
|
{'frozen_sha256': fingerprint(manifest), 'batch_prompts': batch,
|
||||||
|
'matched_rows': [row['id'] for row in replay]})
|
||||||
|
print('validated execution batch', batch, flush=True)
|
||||||
|
for start in range(len(rows), len(examples), batch):
|
||||||
|
rows.extend(evaluate(model, tokenizer, examples[start:start+batch], SCHEDULES))
|
||||||
|
write_json(path, rows)
|
||||||
|
print('screen complete', len(rows), '/', len(examples), flush=True)
|
||||||
|
summary = summarize(rows)
|
||||||
|
write_json(args.out/'screen-summary.json', summary)
|
||||||
|
write_json(args.out/'selection.json', {'frozen_sha256': fingerprint(manifest),
|
||||||
|
'screen_sha256': fingerprint(path),
|
||||||
|
'chosen': choose(summary)})
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -0,0 +1,206 @@
|
|||||||
|
"""Fit LiSA on a development-selected schedule, then evaluate fresh continuations."""
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import torch
|
||||||
|
from tokenizers import Tokenizer
|
||||||
|
|
||||||
|
from crossqkv.lisa_effect_audit import paired
|
||||||
|
from crossqkv.lisa_full_answer import (SCHEDULES, STOP_TEXT, choose, evaluate, fingerprint,
|
||||||
|
prompt, summarize)
|
||||||
|
from crossqkv.lisa_tail import TorchTail, weight_chunks
|
||||||
|
from crossqkv.lisa_train import LearnableSharingAttention, huber_distillation, language_model_loss
|
||||||
|
from functional.model import PREFIX, StreamingLM
|
||||||
|
from functional.run import write_json
|
||||||
|
|
||||||
|
|
||||||
|
class FitCapture(TorchTail):
|
||||||
|
def norm(self, x, name, centered=True):
|
||||||
|
if name == f'layers.{self.sites[0]}.input_layernorm':
|
||||||
|
self.residual = x
|
||||||
|
return super().norm(x, name, centered)
|
||||||
|
|
||||||
|
|
||||||
|
def load_locked(source, screen):
|
||||||
|
fixed = screen/'frozen.json'
|
||||||
|
rows = screen/'screen-rows.json'
|
||||||
|
chosen = json.loads((screen/'selection.json').read_text())
|
||||||
|
if (chosen['frozen_sha256'] != fingerprint(fixed)
|
||||||
|
or chosen['screen_sha256'] != fingerprint(rows)):
|
||||||
|
raise ValueError('Locked screening hashes do not match')
|
||||||
|
manifest = json.loads(fixed.read_text())
|
||||||
|
screen_rows = json.loads(rows.read_text())
|
||||||
|
expected = [(x['id'], x['task'], x['answer']) for x in manifest['problems']['screen']]
|
||||||
|
if [(x['id'], x['task'], x['gold']) for x in screen_rows] != expected:
|
||||||
|
raise ValueError('Screening did not evaluate the frozen development set')
|
||||||
|
expected_selection = choose(summarize(screen_rows))
|
||||||
|
if expected_selection is None or chosen['chosen'] != expected_selection:
|
||||||
|
raise ValueError('Development screen did not produce a qualifying schedule')
|
||||||
|
for name, digest in manifest['protocol']['weights'].items():
|
||||||
|
if fingerprint(source/name) != digest:
|
||||||
|
raise ValueError(f'Model input {name} changed')
|
||||||
|
return chosen, manifest
|
||||||
|
|
||||||
|
|
||||||
|
@torch.no_grad()
|
||||||
|
def capture(model, tokenizer, fit_examples, directory):
|
||||||
|
directory.mkdir(exist_ok=True)
|
||||||
|
teacher = FitCapture(model, 0)
|
||||||
|
teacher.sites = model.sites
|
||||||
|
for i, row in enumerate(fit_examples):
|
||||||
|
path = directory/f'{i:03}.npz'
|
||||||
|
if path.exists():
|
||||||
|
continue
|
||||||
|
text = prompt(row['question'])
|
||||||
|
base = tokenizer.encode(text, add_special_tokens=False).ids
|
||||||
|
complete = tokenizer.encode(text + str(row['answer']) + STOP_TEXT[0],
|
||||||
|
add_special_tokens=False).ids
|
||||||
|
if complete[:len(base)] != base or len(complete) <= len(base):
|
||||||
|
raise ValueError('Answer did not tokenize as an extension of the frozen prompt')
|
||||||
|
ids = np.array([complete])
|
||||||
|
model.guard()
|
||||||
|
hidden = torch.from_numpy(model.embedding(ids))
|
||||||
|
_, side = teacher(hidden, None, torch.tensor([len(complete)]), 'native', ())
|
||||||
|
pending = path.with_suffix('.tmp.npz')
|
||||||
|
np.savez(pending, ids=ids, start=[len(base)], residual=teacher.residual.numpy(),
|
||||||
|
donor=side[model.sites[0]-4][0].numpy(),
|
||||||
|
teacher=np.stack([side[i][0].numpy() for i in model.sites]))
|
||||||
|
pending.replace(path)
|
||||||
|
print('fit capture', i+1, '/', len(fit_examples), flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
def checkpoint(path, obj):
|
||||||
|
pending = path.with_suffix('.tmp')
|
||||||
|
torch.save(obj, pending)
|
||||||
|
pending.replace(path)
|
||||||
|
|
||||||
|
|
||||||
|
def train(model, tokenizer, out, split, epochs, rank):
|
||||||
|
c = model.config
|
||||||
|
rope = c['rope_parameters']
|
||||||
|
adapters = {i: LearnableSharingAttention(c['hidden_size'], c['num_attention_heads'],
|
||||||
|
c['num_key_value_heads'], rank, rope['rope_theta'], rope['partial_rotary_factor'],
|
||||||
|
bias=c.get('attention_bias', False)) for i in model.sites}
|
||||||
|
tail = TorchTail(model, model.sites[0], adapters)
|
||||||
|
optim = torch.optim.AdamW(tail.parameters(), lr=.0003, weight_decay=.1)
|
||||||
|
last = out/'resume.pt'
|
||||||
|
selected = out/'lisa.pt'
|
||||||
|
state = {'epoch': 0, 'steps': [], 'trace': [], 'best_correct': -1}
|
||||||
|
if last.exists():
|
||||||
|
state = torch.load(last, weights_only=True, map_location='cpu')
|
||||||
|
tail.adapters.load_state_dict(state['parameters'])
|
||||||
|
optim.load_state_dict(state['optimizer'])
|
||||||
|
|
||||||
|
embedding = model.tensors[PREFIX+'embed_tokens.weight']
|
||||||
|
|
||||||
|
def vocab():
|
||||||
|
start = 0
|
||||||
|
for w in weight_chunks(embedding, 0, embedding.shape[0], rows=1024):
|
||||||
|
yield start, w
|
||||||
|
start += len(w)
|
||||||
|
|
||||||
|
paths = sorted((out/'fit-capture').glob('*.npz'))
|
||||||
|
for epoch in range(state['epoch'], epochs):
|
||||||
|
for path in paths[len(state['steps']):]:
|
||||||
|
with np.load(path, allow_pickle=False) as entry:
|
||||||
|
b = {key: torch.from_numpy(entry[key]) for key in entry.files}
|
||||||
|
lengths = torch.tensor([b['ids'].shape[1]])
|
||||||
|
optim.zero_grad(set_to_none=True)
|
||||||
|
h, side = tail(b['residual'], b['donor'], lengths, 'lisa', model.sites)
|
||||||
|
kd = torch.stack([huber_distillation(side[i][0], t, lengths)
|
||||||
|
for i, t in zip(model.sites, b['teacher'])]).mean()
|
||||||
|
ce = language_model_loss(h, b['ids'], lengths, vocab, completion_starts=b['start'])
|
||||||
|
loss = .25*kd + .75*ce
|
||||||
|
loss.backward()
|
||||||
|
if any(p.grad is None or not torch.isfinite(p.grad).all() for p in tail.parameters()):
|
||||||
|
raise FloatingPointError('Nonfinite LiSA gradient')
|
||||||
|
optim.step()
|
||||||
|
state['steps'].append({'capture': path.name, 'huber': float(kd.detach()),
|
||||||
|
'completion_ce': float(ce.detach())})
|
||||||
|
checkpoint(last, {**state, 'parameters': tail.adapters.state_dict(),
|
||||||
|
'optimizer': optim.state_dict()})
|
||||||
|
print('fit epoch', epoch+1, 'step', len(state['steps']), '/', len(paths), flush=True)
|
||||||
|
val = []
|
||||||
|
for start in range(0, len(split['validation']), 2):
|
||||||
|
val.extend(evaluate(model, tokenizer, split['validation'][start:start+2],
|
||||||
|
{'lisa': model.sites}, adapters))
|
||||||
|
correct = sum(x['arms']['lisa']['correct'] for x in val)
|
||||||
|
if correct > state['best_correct']:
|
||||||
|
state['best_correct'] = correct
|
||||||
|
state['best_epoch'] = epoch+1
|
||||||
|
state['best_parameters'] = {
|
||||||
|
name: param.detach().clone() for name, param in tail.adapters.state_dict().items()
|
||||||
|
}
|
||||||
|
state['trace'].append({'epoch': epoch+1, 'steps': state['steps'], 'validation': val})
|
||||||
|
state['steps'] = []
|
||||||
|
state['epoch'] = epoch+1
|
||||||
|
checkpoint(last, {**state, 'parameters': tail.adapters.state_dict(),
|
||||||
|
'optimizer': optim.state_dict()})
|
||||||
|
write_json(out/'trace.json', {'selected_epoch': state['best_epoch'], 'epochs': state['trace']})
|
||||||
|
checkpoint(selected, state['best_parameters'])
|
||||||
|
tail.adapters.load_state_dict(state['best_parameters'])
|
||||||
|
return adapters
|
||||||
|
|
||||||
|
|
||||||
|
def audit(rows):
|
||||||
|
correct = {name: np.array([r['arms'][name]['correct'] for r in rows])
|
||||||
|
for name in ('native', 'direct', 'lisa')}
|
||||||
|
bad_value = [r for r in rows if r['arms']['native']['correct']
|
||||||
|
and r['arms']['direct']['answer'] is not None and not r['arms']['direct']['correct']]
|
||||||
|
return {'n': len(rows), 'correct': {name: int(x.sum()) for name, x in correct.items()},
|
||||||
|
'substantive_loss_ids': [r['id'] for r in bad_value],
|
||||||
|
'substantive_rescued_ids': [r['id'] for r in bad_value if r['arms']['lisa']['correct']],
|
||||||
|
'unscored': {name: sum(r['arms'][name]['answer'] is None for r in rows) for name in correct},
|
||||||
|
**paired(correct['native'], correct['direct'], correct['lisa'])}
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
p = argparse.ArgumentParser(description=__doc__)
|
||||||
|
for path in ('source', 'screen', 'out'):
|
||||||
|
p.add_argument('--'+path, type=Path, required=True)
|
||||||
|
p.add_argument('--epochs', type=int, default=2)
|
||||||
|
args = p.parse_args()
|
||||||
|
if args.epochs < 1:
|
||||||
|
p.error('--epochs must be positive')
|
||||||
|
torch.set_num_threads(1)
|
||||||
|
torch.manual_seed(621011)
|
||||||
|
locked, manifest = load_locked(args.source, args.screen)
|
||||||
|
selection = locked['chosen']
|
||||||
|
sites = tuple(selection['recipients'])
|
||||||
|
if sites != SCHEDULES[selection['arm']]:
|
||||||
|
raise ValueError('Unexpected selected schedule')
|
||||||
|
spec = {'screen': locked, 'epochs': args.epochs, 'rank': 40, 'seed': 621011,
|
||||||
|
'objective': '0.25 teacher attention Huber + 0.75 full-vocabulary completion CE'}
|
||||||
|
args.out.mkdir(exist_ok=True)
|
||||||
|
run = args.out/'train-spec.json'
|
||||||
|
if run.exists() and json.loads(run.read_text()) != spec:
|
||||||
|
raise ValueError('Cannot resume with a different experiment definition')
|
||||||
|
write_json(run, spec)
|
||||||
|
tasks = {name: [r for r in rows if r['task'] == selection['task']]
|
||||||
|
for name, rows in manifest['problems'].items()}
|
||||||
|
model = StreamingLM(args.source/'weights', json.loads((args.source/'model_config.json').read_text()),
|
||||||
|
seconds=86400, process_swap_limit_kib=None)
|
||||||
|
model.sites = sites
|
||||||
|
tokenizer = Tokenizer.from_file(str(args.source/'tokenizer.json'))
|
||||||
|
capture(model, tokenizer, tasks['fit'], args.out/'fit-capture')
|
||||||
|
adapters = train(model, tokenizer, args.out, tasks, args.epochs, spec['rank'])
|
||||||
|
output = args.out/'test-items.json'
|
||||||
|
rows = json.loads(output.read_text()) if output.exists() else []
|
||||||
|
if [r['id'] for r in rows] != [x['id'] for x in tasks['test'][:len(rows)]]:
|
||||||
|
raise ValueError('Test continuation does not match the frozen rows')
|
||||||
|
for start in range(len(rows), len(tasks['test']), 2):
|
||||||
|
batch = tasks['test'][start:start+2]
|
||||||
|
base = evaluate(model, tokenizer, batch, {'native': (), 'direct': sites})
|
||||||
|
lisa = evaluate(model, tokenizer, batch, {'lisa': sites}, adapters)
|
||||||
|
for x, y in zip(base, lisa):
|
||||||
|
x['arms'].update(y['arms'])
|
||||||
|
rows.extend(base)
|
||||||
|
write_json(output, rows)
|
||||||
|
print('test complete', len(rows), '/', len(tasks['test']), flush=True)
|
||||||
|
write_json(args.out/'test-audit.json', audit(rows))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
"""Reconstruct complete-answer scores from the saved token streams."""
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from tokenizers import Tokenizer
|
||||||
|
|
||||||
|
from crossqkv.lisa_full_answer import SCHEDULES, fingerprint, grade
|
||||||
|
from crossqkv.lisa_full_answer_train import audit
|
||||||
|
from functional.run import write_json
|
||||||
|
|
||||||
|
|
||||||
|
def verify(tokenizer, protocol, expected, rows, arms, allow_prefix=False):
|
||||||
|
"""Validate each recorded model answer against its frozen prompt and token IDs."""
|
||||||
|
if not rows or len(rows) > len(expected) or (not allow_prefix and len(rows) != len(expected)):
|
||||||
|
raise ValueError('Unexpected number of evaluated items')
|
||||||
|
stop_ids = {tokenizer.token_to_id(text) for text in protocol['stops']}
|
||||||
|
if None in stop_ids:
|
||||||
|
raise ValueError('Missing stop token in the frozen tokenizer')
|
||||||
|
for item, row in zip(expected, rows):
|
||||||
|
if (row['id'], row['task'], row['gold']) != (item['id'], item['task'], item['answer']):
|
||||||
|
raise ValueError(f"Unexpected row for {item['id']}")
|
||||||
|
if set(row['arms']) != set(arms):
|
||||||
|
raise ValueError(f"Unexpected arms for {item['id']}")
|
||||||
|
for arm in arms:
|
||||||
|
stored = row['arms'][arm]
|
||||||
|
tokens = stored['tokens']
|
||||||
|
if (not 0 < len(tokens) <= protocol['cap']
|
||||||
|
or any(type(token) is not int or tokenizer.id_to_token(token) is None
|
||||||
|
for token in tokens)
|
||||||
|
or any(token in stop_ids for token in tokens[:-1])):
|
||||||
|
raise ValueError(f"Invalid generated token stream for {item['id']} / {arm}")
|
||||||
|
ended = tokens[-1] in stop_ids
|
||||||
|
if not ended and len(tokens) != protocol['cap']:
|
||||||
|
raise ValueError(f"Generation ended before a stop or the cap for {item['id']} / {arm}")
|
||||||
|
score = grade(tokenizer, tokens, 'eos' if ended else 'max_new_tokens', item['answer'])
|
||||||
|
if stored != score:
|
||||||
|
raise ValueError(f"Archived score does not match the tokens for {item['id']} / {arm}")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
for name in ('tokenizer', 'frozen', 'rows', 'out'):
|
||||||
|
parser.add_argument('--'+name, required=True, type=Path)
|
||||||
|
parser.add_argument('--selection', type=Path, help='Verify the selected task on the test split')
|
||||||
|
parser.add_argument('--allow-screen-prefix', action='store_true')
|
||||||
|
args = parser.parse_args()
|
||||||
|
if args.selection and args.allow_screen_prefix:
|
||||||
|
parser.error('Test verification requires all frozen test rows')
|
||||||
|
frozen = json.loads(args.frozen.read_bytes())
|
||||||
|
protocol = frozen['protocol']
|
||||||
|
if fingerprint(args.tokenizer) != protocol['weights']['tokenizer.json']:
|
||||||
|
raise ValueError('Tokenizer differs from the frozen experiment')
|
||||||
|
rows = json.loads(args.rows.read_bytes())
|
||||||
|
tokenizer = Tokenizer.from_file(str(args.tokenizer))
|
||||||
|
report = {'frozen_sha256': fingerprint(args.frozen), 'rows_sha256': fingerprint(args.rows),
|
||||||
|
'rows_verified': len(rows)}
|
||||||
|
if args.selection:
|
||||||
|
chosen = json.loads(args.selection.read_bytes())
|
||||||
|
if chosen['frozen_sha256'] != report['frozen_sha256']:
|
||||||
|
raise ValueError('Selection points to a different frozen manifest')
|
||||||
|
expected = [item for item in frozen['problems']['test']
|
||||||
|
if item['task'] == chosen['chosen']['task']]
|
||||||
|
verify(tokenizer, protocol, expected, rows, ('native', 'direct', 'lisa'))
|
||||||
|
report['final_answer_audit'] = audit(rows)
|
||||||
|
else:
|
||||||
|
verify(tokenizer, protocol, frozen['problems']['screen'], rows, SCHEDULES,
|
||||||
|
allow_prefix=args.allow_screen_prefix)
|
||||||
|
write_json(args.out, report)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
"""Cached autoregressive Qwen text generation for the LiSA comparisons."""
|
||||||
|
import math
|
||||||
|
|
||||||
|
import torch
|
||||||
|
from torch.nn import functional as F
|
||||||
|
|
||||||
|
from crossqkv.lisa_tail import TorchTail, rotate, weight_chunks
|
||||||
|
from functional.model import PREFIX
|
||||||
|
|
||||||
|
|
||||||
|
class GenerationDecoder(TorchTail):
|
||||||
|
"""Share the previous full-attention layer's actual scores per batch lane."""
|
||||||
|
|
||||||
|
def __init__(self, source, schedules, padding, adapters=None):
|
||||||
|
super().__init__(source, 0, adapters)
|
||||||
|
full = [i for i, kind in enumerate(self.c['layer_types']) if kind == 'full_attention']
|
||||||
|
if (len(schedules) != len(padding) or not schedules
|
||||||
|
or any(set(sites) - set(full[1:]) for sites in schedules)):
|
||||||
|
raise ValueError('Recipients need an earlier full-attention layer')
|
||||||
|
if self.adapters and any(tuple(sites) != tuple(map(int, self.adapters)) for sites in schedules):
|
||||||
|
raise ValueError('LiSA decoding requires one shared schedule for the batch')
|
||||||
|
self.padding = torch.tensor(padding)
|
||||||
|
self.share = {i: torch.tensor([i in sites for sites in schedules])[:, None, None, None]
|
||||||
|
for i in set().union(*schedules)}
|
||||||
|
self.position = 0
|
||||||
|
self.states = {}
|
||||||
|
|
||||||
|
def attention_chunk(self, h, layer, positions, allowed, donor):
|
||||||
|
heads, kv, dim = (self.c[k] for k in
|
||||||
|
('num_attention_heads', 'num_key_value_heads', 'head_dim'))
|
||||||
|
p = f'layers.{layer}.self_attn.'
|
||||||
|
adapter = self.adapters[str(layer)] if str(layer) in self.adapters else None
|
||||||
|
if adapter is None:
|
||||||
|
q, gate = self.linear(h, p+'q_proj').unflatten(-1, (heads, 2*dim)).chunk(2, -1)
|
||||||
|
k = self.linear(h, p+'k_proj').unflatten(-1, (kv, dim))
|
||||||
|
rope = self.c['rope_parameters']
|
||||||
|
q = rotate(self.norm(q, p+'q_norm'), rope['rope_theta'],
|
||||||
|
rope['partial_rotary_factor'], positions)
|
||||||
|
k = rotate(self.norm(k, p+'k_norm'), rope['rope_theta'],
|
||||||
|
rope['partial_rotary_factor'], positions)
|
||||||
|
else:
|
||||||
|
gate = self.gate_only(h, p)
|
||||||
|
q = adapter.rotate(adapter.q_proj(h).unflatten(-1, (heads, adapter.rank)), positions)
|
||||||
|
k = adapter.rotate(adapter.k_proj(h).unflatten(-1, (kv, adapter.rank)), positions)
|
||||||
|
v = self.linear(h, p+'v_proj').unflatten(-1, (kv, dim))
|
||||||
|
if layer in self.states:
|
||||||
|
prior_k, prior_v = self.states[layer]
|
||||||
|
k = torch.cat((prior_k, k), dim=1)
|
||||||
|
v = torch.cat((prior_v, v), dim=1)
|
||||||
|
self.states[layer] = k, v
|
||||||
|
repeats = heads // kv
|
||||||
|
scores = torch.einsum('bthd,bshd->bhts', q, k.repeat_interleave(repeats, 2))
|
||||||
|
scores = scores / math.sqrt(q.shape[-1])
|
||||||
|
if adapter is not None:
|
||||||
|
both = torch.cat((scores, donor), dim=1).permute(0, 2, 3, 1)
|
||||||
|
scores = adapter.fuse(both).permute(0, 3, 1, 2)
|
||||||
|
elif layer in self.share:
|
||||||
|
scores = torch.where(self.share[layer], donor, scores)
|
||||||
|
weights = scores.masked_fill(~allowed, -torch.inf).softmax(dim=-1)
|
||||||
|
context = torch.einsum('bhts,bshd->bthd', weights, v.repeat_interleave(repeats, 2))
|
||||||
|
return self.linear((context * gate.sigmoid()).flatten(-2), p+'o_proj'), scores
|
||||||
|
|
||||||
|
@torch.no_grad()
|
||||||
|
def advance(self, ids):
|
||||||
|
"""Consume a prompt or continuation and return the final-normalized states."""
|
||||||
|
stop = self.position + ids.shape[1]
|
||||||
|
queries = torch.arange(self.position, stop)
|
||||||
|
keys = torch.arange(stop)
|
||||||
|
positions = (queries[None, :] - self.padding[:, None]).clamp_min(0)
|
||||||
|
q_valid = queries[None, :] >= self.padding[:, None]
|
||||||
|
k_valid = keys[None, :] >= self.padding[:, None]
|
||||||
|
allowed = (queries[:, None] >= keys)[None, None] & (
|
||||||
|
k_valid[:, None, None, :] | ~q_valid[:, None, :, None])
|
||||||
|
h = torch.from_numpy(self.source.embedding(ids.numpy())) * q_valid[..., None]
|
||||||
|
donor = None
|
||||||
|
trim = getattr(self.source, 'malloc_trim', None)
|
||||||
|
for layer, kind in enumerate(self.c['layer_types']):
|
||||||
|
if hasattr(self.source, 'guard'):
|
||||||
|
self.source.guard()
|
||||||
|
p = f'layers.{layer}.'
|
||||||
|
n = self.norm(h, p+'input_layernorm')
|
||||||
|
if kind == 'full_attention':
|
||||||
|
out, donor = self.attention_chunk(n, layer, positions, allowed, donor)
|
||||||
|
else:
|
||||||
|
out, self.states[layer] = self.linear_attention_chunk(n, layer, self.states.get(layer))
|
||||||
|
h = h + out
|
||||||
|
n = self.norm(h, p+'post_attention_layernorm')
|
||||||
|
activation = F.silu(self.linear(n, p+'mlp.gate_proj')) * self.linear(n, p+'mlp.up_proj')
|
||||||
|
h = h + self.linear(activation, p+'mlp.down_proj')
|
||||||
|
del n, out, activation
|
||||||
|
if trim is not None:
|
||||||
|
trim(0)
|
||||||
|
self.position = stop
|
||||||
|
return self.norm(h, 'norm')
|
||||||
|
|
||||||
|
|
||||||
|
def greedy_tokens(hidden, embedding):
|
||||||
|
"""Take the argmax over the complete tied vocabulary in bounded blocks."""
|
||||||
|
peak = hidden.new_full((len(hidden),), -torch.inf)
|
||||||
|
ids = torch.zeros(len(hidden), dtype=torch.long)
|
||||||
|
start = 0
|
||||||
|
for weight in weight_chunks(embedding, 0, embedding.shape[0], rows=1024):
|
||||||
|
score, arg = F.linear(hidden, weight).max(dim=-1)
|
||||||
|
ids = torch.where(score > peak, arg + start, ids)
|
||||||
|
peak = torch.maximum(peak, score)
|
||||||
|
start += len(weight)
|
||||||
|
if not torch.isfinite(peak).all():
|
||||||
|
raise FloatingPointError('Non-finite next-token score')
|
||||||
|
return ids
|
||||||
|
|
||||||
|
|
||||||
|
@torch.no_grad()
|
||||||
|
def generate(source, prompts, schedules, stop_tokens, max_new_tokens, adapters=None):
|
||||||
|
width = max(map(len, prompts))
|
||||||
|
padding = [width - len(prompt) for prompt in prompts]
|
||||||
|
seed = torch.tensor([[0] * n + prompt for prompt, n in zip(prompts, padding)])
|
||||||
|
decoder = GenerationDecoder(source, schedules, padding, adapters)
|
||||||
|
head = source.tensors[PREFIX+'embed_tokens.weight']
|
||||||
|
state = decoder.advance(seed)[:, -1]
|
||||||
|
output = [[] for _ in prompts]
|
||||||
|
finished = [False] * len(prompts)
|
||||||
|
for step in range(max_new_tokens):
|
||||||
|
ids = greedy_tokens(state, head)
|
||||||
|
for row, token in enumerate(ids.tolist()):
|
||||||
|
if not finished[row]:
|
||||||
|
output[row].append(token)
|
||||||
|
finished[row] = token in stop_tokens
|
||||||
|
if all(finished) or step + 1 == max_new_tokens:
|
||||||
|
break
|
||||||
|
state = decoder.advance(ids[:, None])[:, -1]
|
||||||
|
return [(tokens, 'eos' if done else 'max_new_tokens') for tokens, done in zip(output, finished)]
|
||||||
+28
-11
@@ -37,20 +37,23 @@ class FrozenLinear(torch.autograd.Function):
|
|||||||
return out, None, None, None
|
return out, None, None, None
|
||||||
|
|
||||||
|
|
||||||
def rotate(x, theta, fraction):
|
def rotate(x, theta, fraction, positions=None):
|
||||||
d = int(x.shape[-1] * fraction)
|
d = int(x.shape[-1] * fraction)
|
||||||
inv = theta ** (-torch.arange(0, d, 2, dtype=x.dtype, device=x.device) / d)
|
inv = theta ** (-torch.arange(0, d, 2, dtype=x.dtype, device=x.device) / d)
|
||||||
phase = torch.arange(x.shape[1], dtype=x.dtype, device=x.device)[:, None] * inv
|
if positions is None:
|
||||||
angle = torch.cat((phase, phase), dim=-1)[None, :, None, :]
|
positions = torch.arange(x.shape[1], dtype=x.dtype, device=x.device)[None, :]
|
||||||
|
phase = positions[..., None] * inv
|
||||||
|
angle = torch.cat((phase, phase), dim=-1).unsqueeze(-2)
|
||||||
a, b = x[..., :d].chunk(2, dim=-1)
|
a, b = x[..., :d].chunk(2, dim=-1)
|
||||||
return torch.cat((x[..., :d] * angle.cos() + torch.cat((-b, a), -1) * angle.sin(),
|
return torch.cat((x[..., :d] * angle.cos() + torch.cat((-b, a), -1) * angle.sin(),
|
||||||
x[..., d:]), dim=-1)
|
x[..., d:]), dim=-1)
|
||||||
|
|
||||||
|
|
||||||
def gated_delta(q, k, v, g, beta):
|
def gated_delta_chunk(q, k, v, g, beta, state=None):
|
||||||
q = q * (q.square().sum(-1, keepdim=True) + 1e-6).rsqrt() / math.sqrt(q.shape[-1])
|
q = q * (q.square().sum(-1, keepdim=True) + 1e-6).rsqrt() / math.sqrt(q.shape[-1])
|
||||||
k = k * (k.square().sum(-1, keepdim=True) + 1e-6).rsqrt()
|
k = k * (k.square().sum(-1, keepdim=True) + 1e-6).rsqrt()
|
||||||
state = v.new_zeros(v.shape[0], v.shape[2], k.shape[-1], v.shape[-1])
|
if state is None:
|
||||||
|
state = v.new_zeros(v.shape[0], v.shape[2], k.shape[-1], v.shape[-1])
|
||||||
rows = []
|
rows = []
|
||||||
for i in range(v.shape[1]):
|
for i in range(v.shape[1]):
|
||||||
qt, kt, vt = q[:, i], k[:, i], v[:, i]
|
qt, kt, vt = q[:, i], k[:, i], v[:, i]
|
||||||
@@ -58,7 +61,11 @@ def gated_delta(q, k, v, g, beta):
|
|||||||
delta = (vt - (state * kt.unsqueeze(-1)).sum(-2)) * beta[:, i, :, None]
|
delta = (vt - (state * kt.unsqueeze(-1)).sum(-2)) * beta[:, i, :, None]
|
||||||
state = state + kt.unsqueeze(-1) * delta.unsqueeze(-2)
|
state = state + kt.unsqueeze(-1) * delta.unsqueeze(-2)
|
||||||
rows.append((state * qt.unsqueeze(-1)).sum(-2))
|
rows.append((state * qt.unsqueeze(-1)).sum(-2))
|
||||||
return torch.stack(rows, dim=1)
|
return torch.stack(rows, dim=1), state
|
||||||
|
|
||||||
|
|
||||||
|
def gated_delta(q, k, v, g, beta):
|
||||||
|
return gated_delta_chunk(q, k, v, g, beta)[0]
|
||||||
|
|
||||||
|
|
||||||
class TorchTail(nn.Module):
|
class TorchTail(nn.Module):
|
||||||
@@ -133,14 +140,23 @@ class TorchTail(nn.Module):
|
|||||||
return self.linear(out.flatten(-2), name+'o_proj'), scores, native
|
return self.linear(out.flatten(-2), name+'o_proj'), scores, native
|
||||||
|
|
||||||
def linear_attention(self, x, layer):
|
def linear_attention(self, x, layer):
|
||||||
|
return self.linear_attention_chunk(x, layer)[0]
|
||||||
|
|
||||||
|
def linear_attention_chunk(self, x, layer, previous=None):
|
||||||
p = f'layers.{layer}.linear_attn.'
|
p = f'layers.{layer}.linear_attn.'
|
||||||
c = self.c
|
c = self.c
|
||||||
kh, vh = c['linear_num_key_heads'], c['linear_num_value_heads']
|
kh, vh = c['linear_num_key_heads'], c['linear_num_value_heads']
|
||||||
kd, vd = c['linear_key_head_dim'], c['linear_value_head_dim']
|
kd, vd = c['linear_key_head_dim'], c['linear_value_head_dim']
|
||||||
projected = self.linear(x, p+'in_proj_qkv').transpose(1, 2)
|
projected = self.linear(x, p+'in_proj_qkv').transpose(1, 2)
|
||||||
kernel = self.small(p+'conv1d.weight')
|
kernel = self.small(p+'conv1d.weight')
|
||||||
convolved = F.conv1d(projected, kernel, padding=kernel.shape[-1]-1,
|
history = kernel.shape[-1] - 1
|
||||||
groups=projected.shape[1])[..., :x.shape[1]]
|
if previous is None:
|
||||||
|
projected = F.pad(projected, (history, 0))
|
||||||
|
state = None
|
||||||
|
else:
|
||||||
|
prefix, state = previous
|
||||||
|
projected = torch.cat((prefix, projected), dim=-1)
|
||||||
|
convolved = F.conv1d(projected, kernel, groups=projected.shape[1])
|
||||||
q, k, v = F.silu(convolved.transpose(1, 2)).split((kh*kd, kh*kd, vh*vd), dim=-1)
|
q, k, v = F.silu(convolved.transpose(1, 2)).split((kh*kd, kh*kd, vh*vd), dim=-1)
|
||||||
q = q.unflatten(-1, (kh, kd)).repeat_interleave(vh//kh, dim=2)
|
q = q.unflatten(-1, (kh, kd)).repeat_interleave(vh//kh, dim=2)
|
||||||
k = k.unflatten(-1, (kh, kd)).repeat_interleave(vh//kh, dim=2)
|
k = k.unflatten(-1, (kh, kd)).repeat_interleave(vh//kh, dim=2)
|
||||||
@@ -149,9 +165,10 @@ class TorchTail(nn.Module):
|
|||||||
beta = self.linear(x, p+'in_proj_b').sigmoid()
|
beta = self.linear(x, p+'in_proj_b').sigmoid()
|
||||||
a = self.linear(x, p+'in_proj_a')
|
a = self.linear(x, p+'in_proj_a')
|
||||||
g = -self.small(p+'A_log').exp() * F.softplus(a + self.small(p+'dt_bias'))
|
g = -self.small(p+'A_log').exp() * F.softplus(a + self.small(p+'dt_bias'))
|
||||||
out = gated_delta(q, k, v, g, beta)
|
out, state = gated_delta_chunk(q, k, v, g, beta, state)
|
||||||
return self.linear((self.norm(out, p+'norm', centered=False)*F.silu(gate)).flatten(-2),
|
output = self.linear((self.norm(out, p+'norm', centered=False)*F.silu(gate)).flatten(-2),
|
||||||
p+'out_proj')
|
p+'out_proj')
|
||||||
|
return output, (projected[..., projected.shape[-1]-history:].clone(), state)
|
||||||
|
|
||||||
def forward(self, h, donor, lengths, mode, recipients, keep_teacher=False):
|
def forward(self, h, donor, lengths, mode, recipients, keep_teacher=False):
|
||||||
side = {}
|
side = {}
|
||||||
|
|||||||
@@ -114,10 +114,13 @@ class _FrozenVocabularyCE(torch.autograd.Function):
|
|||||||
return grad_hidden * (gradient * weights[:, None] / weights.sum()), None, None, None
|
return grad_hidden * (gradient * weights[:, None] / weights.sum()), None, None, None
|
||||||
|
|
||||||
|
|
||||||
def language_model_loss(hidden, ids, lengths, vocabulary, answer_weight=1.0):
|
def language_model_loss(hidden, ids, lengths, vocabulary, answer_weight=1.0,
|
||||||
|
completion_starts=None):
|
||||||
"""Train on all valid next-token targets, avoiding padding and final positions."""
|
"""Train on all valid next-token targets, avoiding padding and final positions."""
|
||||||
positions = torch.arange(ids.shape[1] - 1, device=ids.device)
|
positions = torch.arange(ids.shape[1] - 1, device=ids.device)
|
||||||
valid = positions[None, :] + 1 < lengths[:, None]
|
valid = positions[None, :] + 1 < lengths[:, None]
|
||||||
|
if completion_starts is not None:
|
||||||
|
valid = valid & (positions[None, :] + 1 >= completion_starts[:, None])
|
||||||
weights = torch.where(positions[None, :] + 2 == lengths[:, None], answer_weight, 1.0)
|
weights = torch.where(positions[None, :] + 2 == lengths[:, None], answer_weight, 1.0)
|
||||||
return _FrozenVocabularyCE.apply(hidden[:, :-1][valid], ids[:, 1:][valid],
|
return _FrozenVocabularyCE.apply(hidden[:, :-1][valid], ids[:, 1:][valid],
|
||||||
weights[valid].to(dtype=hidden.dtype), vocabulary)
|
weights[valid].to(dtype=hidden.dtype), vocabulary)
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# 完整答案评估下的 LiSA 共享实验
|
||||||
|
|
||||||
|
本轮在同一 Qwen3.5-2B 检查点上比较 3、4、5 个全注意力层接收共享分数的效果。上一轮发现首 token 命中的变化集中在 `<think>` 和同一个选项。本轮要求模型从全词表生成完整的多 token 数值答案,逐题复核答案的数值。
|
||||||
|
|
||||||
|
## 开发筛选与冻结
|
||||||
|
|
||||||
|
从 0 开始编号。接收层分别为 `[15, 19, 23]`、`[11, 15, 19, 23]` 和 `[7, 11, 15, 19, 23]`。每个接收层使用本次前向中前一全注意力层实际输出的分数。接收端保留自身的 V、门控和输出投影。原模型与三个直接共享配置配对生成。
|
||||||
|
|
||||||
|
候选任务为表中数值查找、重复键最后值查找、两位数加法、重复项计数。固定生成器在运行筛选之前写出每类任务 8 道开发题、24 道训练题、8 道验证题和 32 道留出测试题。同一数值题跨数据划分去重,加法按交换律规范操作数。每个候选都要满足原模型至少答对 6/8 且至少 2 道原模型答对的题在直接共享下生成了错误整数。选择时依次比较数字错误数、原模型正确数和接收层数,仍并列时取字典序最大的任务标识。完成了生成却没有可提取答案的情况单独记数。
|
||||||
|
|
||||||
|
使用检查点发布的单轮聊天模板和关闭 thinking 的生成前缀。所有配置从全词表逐 token 贪心生成,遇到回合结束或文本结束 token 停止,最多生成 24 tokens。主要指标要求已生成停止 token,并从整条答复提取完整整数。接受纯整数或明确的最终答案行,可去掉开头完整的 thinking 区块。原始 token、文本、停止原因和提取值都随结果存档。 [检查点聊天模板](https://huggingface.co/Qwen/Qwen3.5-2B/blob/15852e8c16360a2fea060d615a32b45270f8a8fc/chat_template.jinja)
|
||||||
|
|
||||||
|
## LiSA 训练与测试
|
||||||
|
|
||||||
|
开发筛选完成后用固定哈希验证题集、共享配置、原模型和筛选数据。仅在存在达标配置时启动训练。冻结原模型,只训练两个线性层组成的注意力头融合和 rank 40 的低秩 Q/K。用原模型在同一训练序列上的遮罩前注意力分数作为教师。损失为 0.25 倍 Huber 距离加 0.75 倍全词表交叉熵。Huber 覆盖实际序列长度内的所有查询和键,注意力前向应用因果遮罩。交叉熵覆盖参考答案的所有 token 和结束 token。每个训练样本更新后保存优化器和模型状态。验证集上生成完整答案,按正确数选择两轮中的最佳检查点,同分选较早者。
|
||||||
|
|
||||||
|
最终对同一批留出题的原模型、直接共享、训练后的 LiSA 分别生成并保存完整回答。报告准确率、直接共享造成的数值错误、其中被 LiSA 恢复的题、新增错误和缺少可提取答案的情况。准确率差按题配对估计,另报告 McNemar 精确双侧检验。
|
||||||
|
|
||||||
|
## 运行命令
|
||||||
|
|
||||||
|
在已确认的远程 CPU 环境中,从源代码目录运行,使用独立输出目录。模型源目录需要包含上一轮实验使用的权重、配置、下载清单和 tokenizer。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
export OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1
|
||||||
|
PYTHON=venv/bin/python
|
||||||
|
SOURCE=runs/cpu-qwen35-2b
|
||||||
|
SCREEN=runs/NEW_FULL_ANSWER_SCREEN
|
||||||
|
RESULT=runs/NEW_FULL_ANSWER_RESULT
|
||||||
|
|
||||||
|
"$PYTHON" -B -m crossqkv.lisa_full_answer --source "$SOURCE" --out "$SCREEN" --batch-prompts 1 --preflight
|
||||||
|
"$PYTHON" -B -m crossqkv.lisa_full_answer --source "$SOURCE" --out "$SCREEN" --batch-prompts 1
|
||||||
|
"$PYTHON" -B -m crossqkv.lisa_full_answer_train --source "$SOURCE" --screen "$SCREEN" --out "$RESULT"
|
||||||
|
"$PYTHON" -B -m crossqkv.lisa_full_answer_verify --tokenizer "$SOURCE/tokenizer.json" \
|
||||||
|
--frozen "$SCREEN/frozen.json" --selection "$SCREEN/selection.json" \
|
||||||
|
--rows "$RESULT/test-items.json" --out "$RESULT/verified-test.json"
|
||||||
|
```
|
||||||
|
|
||||||
|
使用原目录运行相同命令即可续跑。筛选和测试将按已保存的题号继续。训练使用已保存的优化器和训练步。
|
||||||
|
|
||||||
|
筛选续跑可加 `--execution-batch-prompts 2`。它会重跑已完成的前两题,要求所有配置的 token 序列、停止原因与判分逐项一致,才继续处理剩余题目,并把回放凭证写入 `execution-batch-replay.json`。冻结的 `--batch-prompts 1` 参数仍用于校验原实验。双题模式超出资源限制或未通过回放时,可用原单题命令从已保存的行继续。本次在第五题写盘后交接,前两题的四个配置均通过了完整回放核对。
|
||||||
|
|
||||||
|
服务器约有 1.7 GiB 内存。前五题采用单题批量,从第六题起采用通过回放的双题批量。每道题的四个配置共享权重读取。前两次预检和一次生成在服务器仍有约 1 GiB 可用内存时触发进程独立换页上限。当前作业沿用原冻结题集,并在每层结束时释放空闲内存。可用内存、进程 RSS、低可用内存下的持续换页压力和运行时间均由原检查器监控。
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# 完整答案下的 3–5 层共享实验
|
||||||
|
|
||||||
|
开发集筛选选定表中数值查找和三个接收层 `[15, 19, 23]`,层号从 0 起算。原模型在查表组答对 8/8,3 层直接共享在这八题上都生成了用结束 token 收尾的错误整数。该条件用于后续 LiSA 训练和独立留出评估。
|
||||||
|
|
||||||
|
## 开发集筛选
|
||||||
|
|
||||||
|
每个任务各有八题。共享列依次列出正确数、原模型答对却在直接共享后得到错误整数的题数,以及未提取到答案的题数。
|
||||||
|
|
||||||
|
| 任务 | 原模型正确 | 3 层共享 | 4 层共享 | 5 层共享 |
|
||||||
|
| --- | ---: | ---: | ---: | ---: |
|
||||||
|
| 查表 | 8 | 0 / 8 / 0 | 0 / 4 / 4 | 0 / 0 / 8 |
|
||||||
|
| 重复键最后值 | 6 | 0 / 6 / 0 | 0 / 3 / 4 | 0 / 0 / 8 |
|
||||||
|
| 加法 | 7 | 0 / 7 / 0 | 0 / 1 / 7 | 0 / 0 / 8 |
|
||||||
|
| 重复项计数 | 1 | 1 / 1 / 0 | 0 / 1 / 0 | 0 / 0 / 8 |
|
||||||
|
|
||||||
|
5 层配置的 32 道生成均达到 24-token 上限。3 层对查表、重复键和加法均达到筛选门槛,查表中从正确变成错误整数的题数最多。筛选结果用于选择条件。留出集将另行估计准确率差、恢复题和新增错误。
|
||||||
|
|
||||||
|
独立复核用原分词器重新解析 32 道题的全部四组 token 序列,核对终止原因和正确性。冻结清单、逐题生成、组内汇总、选择记录和训练配置均已归档。 [实验协议](LISA_FULL_ANSWER_PROTOCOL.md) · [原始数据](../results/lisa-full-answer-reproduction/)
|
||||||
|
|
||||||
|
## 训练与独立留出评估
|
||||||
|
|
||||||
|
三个接收层各训练 825,344 个参数,总计 2,476,032 个。完成了 24 道冻结拟合题的教师分数采集,复核按题检查输入 token、教师张量形状与有限值,并保存各采集文件的 SHA-256。
|
||||||
|
|
||||||
|
两轮各完成 24 次更新。用冻结分词器重新解码两轮各 8 道验证题的生成结果,首轮答对 1 道,第二轮答对 2 道。按预先固定的验证正确数选用第二轮检查点。两轮逐步损失、验证题原始输出及检查点选择见训练记录。 [训练记录](../results/lisa-full-answer-reproduction/trace.json)
|
||||||
|
|
||||||
|
### 留出集结果
|
||||||
|
|
||||||
|
在 32 道独立查表题上,三组共 96 条回答全部生成了正常的结束 token,并能提取完整整数。原模型全对。三层直接共享让 32 道题都答成了错误整数,LiSA 救回其中 3 道,另外 29 道仍答错。
|
||||||
|
|
||||||
|
| 配置 | 正确数 | 准确率 |
|
||||||
|
| --- | ---: | ---: |
|
||||||
|
| 原模型 | 32/32 | 100% |
|
||||||
|
| 三层直接共享 | 0/32 | 0% |
|
||||||
|
| 三层 LiSA | 3/32 | 9.38% |
|
||||||
|
|
||||||
|
| 恢复题 | 原模型及标准答案 | 直接共享 | LiSA |
|
||||||
|
| --- | ---: | ---: | ---: |
|
||||||
|
| `test-lookup-014` | 71 | 47 | 71 |
|
||||||
|
| `test-lookup-020` | 94 | 5 | 94 |
|
||||||
|
| `test-lookup-021` | 44 | 10 | 44 |
|
||||||
|
|
||||||
|
相对直接共享,LiSA 准确率提高 9.38 个百分点,按题配对 bootstrap 95% 区间为 0 至 21.88 个百分点。McNemar 精确双侧检验的 p 值为 0.25。逐题变化方向是 3 道从错变对、0 道从对变错。直接共享全错,因此这个留出集无法估计 LiSA 保留直接共享已有正确答案的能力。
|
||||||
|
|
||||||
|
结果确认了三个真实数值错误的恢复案例。样本上的准确率提升仍有较大不确定性。结论限于这一个 Qwen3.5-2B 检查点、查表任务和三个接收层,训练用 24 道合成题。四层和五层共享只做了开发筛选,其 LiSA 恢复效果仍待测。
|
||||||
|
|
||||||
|
远程实验和独立复核均以退出码 0 完成。复核从保存的 token 重新解析并重算三组分数,结果与训练进程生成的汇总一致。摘要记录的是远程原件路径,选中的适配器保存在该远程运行目录。 [逐题输出](../results/lisa-full-answer-reproduction/test-items.json) · [配对统计](../results/lisa-full-answer-reproduction/test-audit.json) · [复核回执](../results/lisa-full-answer-reproduction/verified-test.json) · [文件摘要](../results/lisa-full-answer-reproduction/result.sha256)
|
||||||
+6
-2
@@ -77,11 +77,13 @@ def attention(q, k, v):
|
|||||||
|
|
||||||
|
|
||||||
class StreamingLM:
|
class StreamingLM:
|
||||||
def __init__(self, weights, config, seconds=7200, enforce_memory=True):
|
def __init__(self, weights, config, seconds=7200, enforce_memory=True,
|
||||||
|
process_swap_limit_kib=128*1024):
|
||||||
self.tensors = load_tensors(Path(weights))
|
self.tensors = load_tensors(Path(weights))
|
||||||
self.config = config.get('text_config', config)
|
self.config = config.get('text_config', config)
|
||||||
self.deadline = time.monotonic() + seconds
|
self.deadline = time.monotonic() + seconds
|
||||||
self.enforce_memory = enforce_memory
|
self.enforce_memory = enforce_memory
|
||||||
|
self.process_swap_limit_kib = process_swap_limit_kib
|
||||||
self.eps = self.config['rms_norm_eps']
|
self.eps = self.config['rms_norm_eps']
|
||||||
self.norm_replacement = None
|
self.norm_replacement = None
|
||||||
self.capture_qk = False
|
self.capture_qk = False
|
||||||
@@ -107,7 +109,9 @@ class StreamingLM:
|
|||||||
rate = (count-self.swap_observation[1])*4096/elapsed
|
rate = (count-self.swap_observation[1])*4096/elapsed
|
||||||
self.swap_pressure_windows = self.swap_pressure_windows+1 if rate > 4*1024**2 else 0
|
self.swap_pressure_windows = self.swap_pressure_windows+1 if rate > 4*1024**2 else 0
|
||||||
own_swap_kib = int(status.get('VmSwap', '0 kB').split()[0])
|
own_swap_kib = int(status.get('VmSwap', '0 kB').split()[0])
|
||||||
if self.swap_pressure_windows >= 3 and (available < 384*1024 or own_swap_kib > 128*1024):
|
over_process_limit = (self.process_swap_limit_kib is not None
|
||||||
|
and own_swap_kib > self.process_swap_limit_kib)
|
||||||
|
if self.swap_pressure_windows >= 3 and (available < 384*1024 or over_process_limit):
|
||||||
raise MemoryError(f'Sustained host swap pressure plus constrained memory: available={available} KiB, process_swap={own_swap_kib} KiB')
|
raise MemoryError(f'Sustained host swap pressure plus constrained memory: available={available} KiB, process_swap={own_swap_kib} KiB')
|
||||||
self.swap_observation = (now,count)
|
self.swap_observation = (now,count)
|
||||||
if rss_kib > 512*1024 or available < 256*1024:
|
if rss_kib > 512*1024 or available < 256*1024:
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
07179a56936844f1bd639e1f31ee7f9d0110ec28c472fe6a59c7fcaf3e033355 crossqkv/lisa_full_answer.py
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
94437e0138c54ec34b1beaaa0e08a334ce0822f60af598a5a896459b778a3a1c functional/model.py
|
||||||
|
98927a1ccd935b2f7a438bad31bbd973e210a54deceac911c61551092e52c96c crossqkv/lisa_generate.py
|
||||||
|
519e0a031efcfb69c9b86fca1cb649fe8bb93d799401c8023ff7b6549cded448 crossqkv/lisa_full_answer.py
|
||||||
|
74d6cbe3be94a8118f670c8810037b6d8abe085bd42b638a58af856eb45a17f3 crossqkv/lisa_full_answer_train.py
|
||||||
|
d47b4c9cc34082e9b356e745821298a43981e4cd18ed55a3f59b4b6fe7cc46e3 crossqkv/lisa_tail.py
|
||||||
|
9f0b6a53f107950661e91c16f03b49440708b3936120e2f84ef1d66f185257b6 crossqkv/lisa_train.py
|
||||||
|
96d12fdfa266ca02ac50330971ff403e04b977358f479d63c8d6276a514fe025 tests/test_lisa_full_answer.py
|
||||||
|
d1f3b3b2b92005c47f7fbc4f558407749b7059592c3b54d8b784da58ea12b3ef tests/test_lisa_tail.py
|
||||||
|
d249035103ed7f43978c0d6452bf70ec9a345777289cb92c0b6a2a181e6d4380 tests/test_lisa_train.py
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"frozen_sha256": "409cadff8b2ef2f0efcfa71bf0a94802391a341ed04cb6e374154b8b8ff1b545",
|
||||||
|
"batch_prompts": 2,
|
||||||
|
"matched_rows": [
|
||||||
|
"screen-lookup-000",
|
||||||
|
"screen-lookup-001"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"rows": 5, "rows_sha256": "ff93a751537895e3d7fc55e3496afbbc46df34bb04ed89663319e38b8aa7a6e2", "stopped_pid": 4124128}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "screen-lookup-000",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 82,
|
||||||
|
"arms": {
|
||||||
|
"native": {
|
||||||
|
"tokens": [
|
||||||
|
23,
|
||||||
|
17,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "82<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 82,
|
||||||
|
"correct": true
|
||||||
|
},
|
||||||
|
"direct_3": {
|
||||||
|
"tokens": [
|
||||||
|
20,
|
||||||
|
248044
|
||||||
|
],
|
||||||
|
"response": "5<|endoftext|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 5,
|
||||||
|
"correct": false
|
||||||
|
},
|
||||||
|
"direct_4": {
|
||||||
|
"tokens": [
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16
|
||||||
|
],
|
||||||
|
"response": "111111111111111111111111",
|
||||||
|
"stop": "max_new_tokens",
|
||||||
|
"answer": null,
|
||||||
|
"correct": false
|
||||||
|
},
|
||||||
|
"direct_5": {
|
||||||
|
"tokens": [
|
||||||
|
1206,
|
||||||
|
1423,
|
||||||
|
279,
|
||||||
|
4087,
|
||||||
|
11,
|
||||||
|
1042,
|
||||||
|
579,
|
||||||
|
1353,
|
||||||
|
506,
|
||||||
|
279,
|
||||||
|
1103,
|
||||||
|
314,
|
||||||
|
4947,
|
||||||
|
488,
|
||||||
|
3766,
|
||||||
|
25,
|
||||||
|
271,
|
||||||
|
332,
|
||||||
|
16,
|
||||||
|
13,
|
||||||
|
220,
|
||||||
|
16,
|
||||||
|
332,
|
||||||
|
198
|
||||||
|
],
|
||||||
|
"response": "To find the answer, let's look at the list of numbers you provided:\n\n**1. 1**\n",
|
||||||
|
"stop": "max_new_tokens",
|
||||||
|
"answer": null,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"frozen_sha256": "409cadff8b2ef2f0efcfa71bf0a94802391a341ed04cb6e374154b8b8ff1b545",
|
||||||
|
"rows_sha256": "630c27e010ac00677bd2e7a280f17e9076c802c245f4857ec8f6795418e00c3d",
|
||||||
|
"rows_verified": 1
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"prompt_id": "screen-lookup-000",
|
||||||
|
"prompt_tokens": 103,
|
||||||
|
"tail_hidden_max_abs": 0.0001049041748046875
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
df49b966e0f68bcb0f06642e9ec141008aaf8550d63fc467f00c6b9e864af799 /opt/exp-model-parameter-similarity/runs/lisa-full-answer-20261124-run/final/train-spec.json
|
||||||
|
3366a4f4653837e4698ebabaa1d9656788b920f04f3b4e01f776342347c3604d /opt/exp-model-parameter-similarity/runs/lisa-full-answer-20261124-run/final/trace.json
|
||||||
|
c82db5af7fa42cf58a349f3e53961da2360b211a7ed606f53a728860c64f6f29 /opt/exp-model-parameter-similarity/runs/lisa-full-answer-20261124-run/final/lisa.pt
|
||||||
|
5c04ffff27c8b31a0be2d39553ed035d3c677907cabc1d17a9ea5886f97f8e5d /opt/exp-model-parameter-similarity/runs/lisa-full-answer-20261124-run/final/test-items.json
|
||||||
|
c5f8b769819335d4a0969575f33c783859b4114dbf13405feeb06f3610a593c8 /opt/exp-model-parameter-similarity/runs/lisa-full-answer-20261124-run/final/test-audit.json
|
||||||
|
74c5b1a4a4a88420d3965e57671d765f22cc3440eb74e9737d0ecbb7b0776ad1 /opt/exp-model-parameter-similarity/runs/lisa-full-answer-20261124-run/final/verified-test.json
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,145 @@
|
|||||||
|
{
|
||||||
|
"lookup": {
|
||||||
|
"native": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 8,
|
||||||
|
"unscored": 0,
|
||||||
|
"native_correct_to_wrong_integer": []
|
||||||
|
},
|
||||||
|
"direct_3": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 0,
|
||||||
|
"unscored": 0,
|
||||||
|
"native_correct_to_wrong_integer": [
|
||||||
|
"screen-lookup-000",
|
||||||
|
"screen-lookup-001",
|
||||||
|
"screen-lookup-002",
|
||||||
|
"screen-lookup-003",
|
||||||
|
"screen-lookup-004",
|
||||||
|
"screen-lookup-005",
|
||||||
|
"screen-lookup-006",
|
||||||
|
"screen-lookup-007"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"direct_4": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 0,
|
||||||
|
"unscored": 4,
|
||||||
|
"native_correct_to_wrong_integer": [
|
||||||
|
"screen-lookup-001",
|
||||||
|
"screen-lookup-003",
|
||||||
|
"screen-lookup-004",
|
||||||
|
"screen-lookup-005"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"direct_5": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 0,
|
||||||
|
"unscored": 8,
|
||||||
|
"native_correct_to_wrong_integer": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"latest": {
|
||||||
|
"native": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 6,
|
||||||
|
"unscored": 0,
|
||||||
|
"native_correct_to_wrong_integer": []
|
||||||
|
},
|
||||||
|
"direct_3": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 0,
|
||||||
|
"unscored": 0,
|
||||||
|
"native_correct_to_wrong_integer": [
|
||||||
|
"screen-latest-000",
|
||||||
|
"screen-latest-001",
|
||||||
|
"screen-latest-004",
|
||||||
|
"screen-latest-005",
|
||||||
|
"screen-latest-006",
|
||||||
|
"screen-latest-007"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"direct_4": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 0,
|
||||||
|
"unscored": 4,
|
||||||
|
"native_correct_to_wrong_integer": [
|
||||||
|
"screen-latest-000",
|
||||||
|
"screen-latest-001",
|
||||||
|
"screen-latest-005"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"direct_5": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 0,
|
||||||
|
"unscored": 8,
|
||||||
|
"native_correct_to_wrong_integer": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"addition": {
|
||||||
|
"native": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 7,
|
||||||
|
"unscored": 0,
|
||||||
|
"native_correct_to_wrong_integer": []
|
||||||
|
},
|
||||||
|
"direct_3": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 0,
|
||||||
|
"unscored": 0,
|
||||||
|
"native_correct_to_wrong_integer": [
|
||||||
|
"screen-addition-000",
|
||||||
|
"screen-addition-001",
|
||||||
|
"screen-addition-002",
|
||||||
|
"screen-addition-004",
|
||||||
|
"screen-addition-005",
|
||||||
|
"screen-addition-006",
|
||||||
|
"screen-addition-007"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"direct_4": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 0,
|
||||||
|
"unscored": 7,
|
||||||
|
"native_correct_to_wrong_integer": [
|
||||||
|
"screen-addition-000"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"direct_5": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 0,
|
||||||
|
"unscored": 8,
|
||||||
|
"native_correct_to_wrong_integer": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"count": {
|
||||||
|
"native": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 1,
|
||||||
|
"unscored": 0,
|
||||||
|
"native_correct_to_wrong_integer": []
|
||||||
|
},
|
||||||
|
"direct_3": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 1,
|
||||||
|
"unscored": 0,
|
||||||
|
"native_correct_to_wrong_integer": [
|
||||||
|
"screen-count-002"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"direct_4": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 0,
|
||||||
|
"unscored": 0,
|
||||||
|
"native_correct_to_wrong_integer": [
|
||||||
|
"screen-count-002"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"direct_5": {
|
||||||
|
"n": 8,
|
||||||
|
"correct": 0,
|
||||||
|
"unscored": 8,
|
||||||
|
"native_correct_to_wrong_integer": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"frozen_sha256": "409cadff8b2ef2f0efcfa71bf0a94802391a341ed04cb6e374154b8b8ff1b545",
|
||||||
|
"screen_sha256": "59225fa1b583af3a5890c020b9cc18487d182312728865e4386fa9007fee0da4",
|
||||||
|
"chosen": {
|
||||||
|
"task": "lookup",
|
||||||
|
"arm": "direct_3",
|
||||||
|
"recipients": [
|
||||||
|
15,
|
||||||
|
19,
|
||||||
|
23
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
{
|
||||||
|
"n": 32,
|
||||||
|
"correct": {
|
||||||
|
"native": 32,
|
||||||
|
"direct": 0,
|
||||||
|
"lisa": 3
|
||||||
|
},
|
||||||
|
"substantive_loss_ids": [
|
||||||
|
"test-lookup-000",
|
||||||
|
"test-lookup-001",
|
||||||
|
"test-lookup-002",
|
||||||
|
"test-lookup-003",
|
||||||
|
"test-lookup-004",
|
||||||
|
"test-lookup-005",
|
||||||
|
"test-lookup-006",
|
||||||
|
"test-lookup-007",
|
||||||
|
"test-lookup-008",
|
||||||
|
"test-lookup-009",
|
||||||
|
"test-lookup-010",
|
||||||
|
"test-lookup-011",
|
||||||
|
"test-lookup-012",
|
||||||
|
"test-lookup-013",
|
||||||
|
"test-lookup-014",
|
||||||
|
"test-lookup-015",
|
||||||
|
"test-lookup-016",
|
||||||
|
"test-lookup-017",
|
||||||
|
"test-lookup-018",
|
||||||
|
"test-lookup-019",
|
||||||
|
"test-lookup-020",
|
||||||
|
"test-lookup-021",
|
||||||
|
"test-lookup-022",
|
||||||
|
"test-lookup-023",
|
||||||
|
"test-lookup-024",
|
||||||
|
"test-lookup-025",
|
||||||
|
"test-lookup-026",
|
||||||
|
"test-lookup-027",
|
||||||
|
"test-lookup-028",
|
||||||
|
"test-lookup-029",
|
||||||
|
"test-lookup-030",
|
||||||
|
"test-lookup-031"
|
||||||
|
],
|
||||||
|
"substantive_rescued_ids": [
|
||||||
|
"test-lookup-014",
|
||||||
|
"test-lookup-020",
|
||||||
|
"test-lookup-021"
|
||||||
|
],
|
||||||
|
"unscored": {
|
||||||
|
"native": 0,
|
||||||
|
"direct": 0,
|
||||||
|
"lisa": 0
|
||||||
|
},
|
||||||
|
"native_correct_lost_by_direct": 32,
|
||||||
|
"rescued": 3,
|
||||||
|
"newly_lost_among_native_and_direct_correct": 0,
|
||||||
|
"candidate_correct_direct_wrong": 3,
|
||||||
|
"direct_correct_candidate_wrong": 0,
|
||||||
|
"accuracy_delta_vs_direct": 0.09375,
|
||||||
|
"paired_prompt_bootstrap_95": [
|
||||||
|
0.0,
|
||||||
|
0.21875
|
||||||
|
],
|
||||||
|
"mcnemar_exact_p": 0.25
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,547 @@
|
|||||||
|
{
|
||||||
|
"selected_epoch": 2,
|
||||||
|
"epochs": [
|
||||||
|
{
|
||||||
|
"epoch": 1,
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"capture": "000.npz",
|
||||||
|
"huber": 6.466125965118408,
|
||||||
|
"completion_ce": 3.640169858932495
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "001.npz",
|
||||||
|
"huber": 6.416173458099365,
|
||||||
|
"completion_ce": 2.7350101470947266
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "002.npz",
|
||||||
|
"huber": 6.482085704803467,
|
||||||
|
"completion_ce": 2.03899884223938
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "003.npz",
|
||||||
|
"huber": 6.430853366851807,
|
||||||
|
"completion_ce": 1.5210151672363281
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "004.npz",
|
||||||
|
"huber": 6.329977512359619,
|
||||||
|
"completion_ce": 1.6759847402572632
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "005.npz",
|
||||||
|
"huber": 6.335151195526123,
|
||||||
|
"completion_ce": 1.0699304342269897
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "006.npz",
|
||||||
|
"huber": 6.317526340484619,
|
||||||
|
"completion_ce": 1.4101346731185913
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "007.npz",
|
||||||
|
"huber": 6.251140594482422,
|
||||||
|
"completion_ce": 1.1468429565429688
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "008.npz",
|
||||||
|
"huber": 6.1668524742126465,
|
||||||
|
"completion_ce": 1.6777559518814087
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "009.npz",
|
||||||
|
"huber": 6.1963043212890625,
|
||||||
|
"completion_ce": 1.2596086263656616
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "010.npz",
|
||||||
|
"huber": 6.088558673858643,
|
||||||
|
"completion_ce": 0.6729698181152344
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "011.npz",
|
||||||
|
"huber": 6.079294681549072,
|
||||||
|
"completion_ce": 1.2998491525650024
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "012.npz",
|
||||||
|
"huber": 6.054551601409912,
|
||||||
|
"completion_ce": 1.4103832244873047
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "013.npz",
|
||||||
|
"huber": 5.936060428619385,
|
||||||
|
"completion_ce": 1.0076059103012085
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "014.npz",
|
||||||
|
"huber": 5.830902576446533,
|
||||||
|
"completion_ce": 0.8567708134651184
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "015.npz",
|
||||||
|
"huber": 5.81991720199585,
|
||||||
|
"completion_ce": 0.9816989898681641
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "016.npz",
|
||||||
|
"huber": 5.782172679901123,
|
||||||
|
"completion_ce": 0.32713380455970764
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "017.npz",
|
||||||
|
"huber": 5.763124465942383,
|
||||||
|
"completion_ce": 2.0601158142089844
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "018.npz",
|
||||||
|
"huber": 5.706521511077881,
|
||||||
|
"completion_ce": 1.5579833984375
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "019.npz",
|
||||||
|
"huber": 5.558866500854492,
|
||||||
|
"completion_ce": 0.44708251953125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "020.npz",
|
||||||
|
"huber": 5.477881908416748,
|
||||||
|
"completion_ce": 1.1636791229248047
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "021.npz",
|
||||||
|
"huber": 5.311099529266357,
|
||||||
|
"completion_ce": 1.1208223104476929
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "022.npz",
|
||||||
|
"huber": 5.279181957244873,
|
||||||
|
"completion_ce": 1.268227219581604
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "023.npz",
|
||||||
|
"huber": 5.142008304595947,
|
||||||
|
"completion_ce": 0.9710490107536316
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"validation": [
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-000",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 28,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
24,
|
||||||
|
22,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "97<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 97,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-001",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 92,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
24,
|
||||||
|
21,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "96<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 96,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-002",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 71,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
19,
|
||||||
|
16,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "41<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 41,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-003",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 89,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
23,
|
||||||
|
19,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "84<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 84,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-004",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 98,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
24,
|
||||||
|
23,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "98<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 98,
|
||||||
|
"correct": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-005",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 26,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
20,
|
||||||
|
24,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "59<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 59,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-006",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 38,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
24,
|
||||||
|
16,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "91<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 91,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-007",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 32,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
20,
|
||||||
|
24,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "59<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 59,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"epoch": 2,
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"capture": "000.npz",
|
||||||
|
"huber": 4.952552318572998,
|
||||||
|
"completion_ce": 1.4009037017822266
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "001.npz",
|
||||||
|
"huber": 4.789427280426025,
|
||||||
|
"completion_ce": 0.5592880249023438
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "002.npz",
|
||||||
|
"huber": 4.726945400238037,
|
||||||
|
"completion_ce": 1.2972265481948853
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "003.npz",
|
||||||
|
"huber": 4.5856170654296875,
|
||||||
|
"completion_ce": 0.5974127650260925
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "004.npz",
|
||||||
|
"huber": 4.457610607147217,
|
||||||
|
"completion_ce": 0.4448140561580658
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "005.npz",
|
||||||
|
"huber": 4.406347274780273,
|
||||||
|
"completion_ce": 0.6005427241325378
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "006.npz",
|
||||||
|
"huber": 4.3611578941345215,
|
||||||
|
"completion_ce": 1.11090087890625
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "007.npz",
|
||||||
|
"huber": 4.287736415863037,
|
||||||
|
"completion_ce": 0.4663238525390625
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "008.npz",
|
||||||
|
"huber": 4.187578201293945,
|
||||||
|
"completion_ce": 1.04208242893219
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "009.npz",
|
||||||
|
"huber": 4.137438774108887,
|
||||||
|
"completion_ce": 0.754715621471405
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "010.npz",
|
||||||
|
"huber": 3.979546308517456,
|
||||||
|
"completion_ce": 0.5380516052246094
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "011.npz",
|
||||||
|
"huber": 3.8709640502929688,
|
||||||
|
"completion_ce": 0.7800388336181641
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "012.npz",
|
||||||
|
"huber": 3.749253273010254,
|
||||||
|
"completion_ce": 0.5718275904655457
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "013.npz",
|
||||||
|
"huber": 3.5951597690582275,
|
||||||
|
"completion_ce": 0.8369833827018738
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "014.npz",
|
||||||
|
"huber": 3.4549624919891357,
|
||||||
|
"completion_ce": 0.37712350487709045
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "015.npz",
|
||||||
|
"huber": 3.3932430744171143,
|
||||||
|
"completion_ce": 0.47049713134765625
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "016.npz",
|
||||||
|
"huber": 3.3298141956329346,
|
||||||
|
"completion_ce": 0.24415016174316406
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "017.npz",
|
||||||
|
"huber": 3.315248727798462,
|
||||||
|
"completion_ce": 1.5147151947021484
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "018.npz",
|
||||||
|
"huber": 3.2439496517181396,
|
||||||
|
"completion_ce": 0.15868441760540009
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "019.npz",
|
||||||
|
"huber": 3.1188666820526123,
|
||||||
|
"completion_ce": 0.05583127215504646
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "020.npz",
|
||||||
|
"huber": 3.04500412940979,
|
||||||
|
"completion_ce": 0.022246679291129112
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "021.npz",
|
||||||
|
"huber": 2.903524160385132,
|
||||||
|
"completion_ce": 0.07955551147460938
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "022.npz",
|
||||||
|
"huber": 2.9015865325927734,
|
||||||
|
"completion_ce": 1.1182270050048828
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"capture": "023.npz",
|
||||||
|
"huber": 2.8223178386688232,
|
||||||
|
"completion_ce": 0.44306373596191406
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"validation": [
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-000",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 28,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
24,
|
||||||
|
22,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "97<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 97,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-001",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 92,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
24,
|
||||||
|
17,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "92<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 92,
|
||||||
|
"correct": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-002",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 71,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
19,
|
||||||
|
16,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "41<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 41,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-003",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 89,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
20,
|
||||||
|
19,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "54<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 54,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-004",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 98,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
24,
|
||||||
|
23,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "98<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 98,
|
||||||
|
"correct": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-005",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 26,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
21,
|
||||||
|
20,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "65<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 65,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-006",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 38,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
24,
|
||||||
|
16,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "91<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 91,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "validation-lookup-007",
|
||||||
|
"task": "lookup",
|
||||||
|
"gold": 32,
|
||||||
|
"arms": {
|
||||||
|
"lisa": {
|
||||||
|
"tokens": [
|
||||||
|
20,
|
||||||
|
18,
|
||||||
|
248046
|
||||||
|
],
|
||||||
|
"response": "53<|im_end|>",
|
||||||
|
"stop": "eos",
|
||||||
|
"answer": 53,
|
||||||
|
"correct": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"screen": {
|
||||||
|
"frozen_sha256": "409cadff8b2ef2f0efcfa71bf0a94802391a341ed04cb6e374154b8b8ff1b545",
|
||||||
|
"screen_sha256": "59225fa1b583af3a5890c020b9cc18487d182312728865e4386fa9007fee0da4",
|
||||||
|
"chosen": {
|
||||||
|
"task": "lookup",
|
||||||
|
"arm": "direct_3",
|
||||||
|
"recipients": [
|
||||||
|
15,
|
||||||
|
19,
|
||||||
|
23
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"epochs": 2,
|
||||||
|
"rank": 40,
|
||||||
|
"seed": 621011,
|
||||||
|
"objective": "0.25 teacher attention Huber + 0.75 full-vocabulary completion CE"
|
||||||
|
}
|
||||||
@@ -0,0 +1,181 @@
|
|||||||
|
{
|
||||||
|
"frozen_sha256": "409cadff8b2ef2f0efcfa71bf0a94802391a341ed04cb6e374154b8b8ff1b545",
|
||||||
|
"train_spec_sha256": "df49b966e0f68bcb0f06642e9ec141008aaf8550d63fc467f00c6b9e864af799",
|
||||||
|
"task": "lookup",
|
||||||
|
"recipients": [
|
||||||
|
15,
|
||||||
|
19,
|
||||||
|
23
|
||||||
|
],
|
||||||
|
"captures_verified": 24,
|
||||||
|
"records": [
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-000",
|
||||||
|
"file": "000.npz",
|
||||||
|
"input_tokens": 102,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "e7489bf56a40293759ac2e24822cbf3cd5fbd88a3d2429f069009e9197de2c46"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-001",
|
||||||
|
"file": "001.npz",
|
||||||
|
"input_tokens": 103,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "27e531a27d9ad9f04675f4df1ffd66b4ec89089e23d11b9b0de6285a4a729af3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-002",
|
||||||
|
"file": "002.npz",
|
||||||
|
"input_tokens": 100,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "45a01a55c646e0ea3635b5794072b5371984f7fa9aca1b1c827155579a06fb9d"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-003",
|
||||||
|
"file": "003.npz",
|
||||||
|
"input_tokens": 103,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "38792661d7a9372a32609a52f64724b2553bc12311b56b482324ddb52165f97d"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-004",
|
||||||
|
"file": "004.npz",
|
||||||
|
"input_tokens": 103,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "c9a628e3d17ff06d276dabf26008fbb139f53ecbc814c0cd497c9be80c2e6bd3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-005",
|
||||||
|
"file": "005.npz",
|
||||||
|
"input_tokens": 103,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "d1c0b5b50dbdba10488fb655d7414bc309647ae6f79a1835f7e91a6594859845"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-006",
|
||||||
|
"file": "006.npz",
|
||||||
|
"input_tokens": 103,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "744daf42b3431fdb56de9710ddbf5f3e322ed99181742643dd5c053af9ae6a11"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-007",
|
||||||
|
"file": "007.npz",
|
||||||
|
"input_tokens": 103,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "4b2f194edddc6da7fd79676db47580e31e3345d753b4e5b961c3bd539f29e582"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-008",
|
||||||
|
"file": "008.npz",
|
||||||
|
"input_tokens": 103,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "b839bc0393ba2ddd4fa8f0d15cbbfac319585a336e26c3ce1cb3a3e0708769df"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-009",
|
||||||
|
"file": "009.npz",
|
||||||
|
"input_tokens": 102,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "e24b25781451ba931dcc1b2319cf40b946456cfaaafc15100351f9aff1c23846"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-010",
|
||||||
|
"file": "010.npz",
|
||||||
|
"input_tokens": 104,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "5576e4a26f4d255b39683e503cf4c868c582d668639255d034a82b91f723b9d3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-011",
|
||||||
|
"file": "011.npz",
|
||||||
|
"input_tokens": 103,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "b659078ce11cc5e175a3987e14353b95fd837f13ea6b3aad54cfb5ebc6ff3d8f"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-012",
|
||||||
|
"file": "012.npz",
|
||||||
|
"input_tokens": 104,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "adb5d0128a5146cd6662c7f2fdb8dc9404032bb17cbe8eea2a6387a8d0054a9d"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-013",
|
||||||
|
"file": "013.npz",
|
||||||
|
"input_tokens": 102,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "7e704a18185ef9b0e7c4f001444841c9a0aa40bfaf392fa549ec69f8b7e7c288"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-014",
|
||||||
|
"file": "014.npz",
|
||||||
|
"input_tokens": 102,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "4033dbdaa677b4eb49f7aab020a8f1329da8753326bd11e07be64471ea39559a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-015",
|
||||||
|
"file": "015.npz",
|
||||||
|
"input_tokens": 101,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "6fd9fc00fdbb0dfb4c3fd385c411c9e09931c3bd30d7406881d61bd00150f891"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-016",
|
||||||
|
"file": "016.npz",
|
||||||
|
"input_tokens": 103,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "be79c79a87ed2c3ced2c9fa4efacb7d373d521dd301fad48d0ce7d0b714f60ba"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-017",
|
||||||
|
"file": "017.npz",
|
||||||
|
"input_tokens": 101,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "f2e2ac748ac1c136e18725be7e4d31b8501ada2c2f2f46a0a5ca399b087ca572"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-018",
|
||||||
|
"file": "018.npz",
|
||||||
|
"input_tokens": 105,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "5befccbda4c55e06b2b8cdd7dd040dcbe7cb3dc8d3d09ad55542f03820e066ad"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-019",
|
||||||
|
"file": "019.npz",
|
||||||
|
"input_tokens": 100,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "3037fea3ed609eb068ebcc85bf58fc56288df201e21e0988339710a981734e87"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-020",
|
||||||
|
"file": "020.npz",
|
||||||
|
"input_tokens": 103,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "93e7764c575f8d3b9a2a4619d4458bf732fb20240e5c9a6261700d6bae59bc29"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-021",
|
||||||
|
"file": "021.npz",
|
||||||
|
"input_tokens": 102,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "f79679202390c4bf2d41db5e12a00867c4d77f2f5b912006cdf43200b93dcc3c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-022",
|
||||||
|
"file": "022.npz",
|
||||||
|
"input_tokens": 100,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "c66571c5ad7cc0328eec7c170392c0ed027151b46097030e87dab9c44d488cf0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fit-lookup-023",
|
||||||
|
"file": "023.npz",
|
||||||
|
"input_tokens": 102,
|
||||||
|
"answer_and_eos_tokens": 3,
|
||||||
|
"sha256": "3f971f14a8cbfde8644b4e82f4ce8c4b10d3df0314ea15ae5141a50d957c53ff"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"frozen_sha256": "409cadff8b2ef2f0efcfa71bf0a94802391a341ed04cb6e374154b8b8ff1b545",
|
||||||
|
"rows_sha256": "59225fa1b583af3a5890c020b9cc18487d182312728865e4386fa9007fee0da4",
|
||||||
|
"rows_verified": 32
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"frozen_sha256": "409cadff8b2ef2f0efcfa71bf0a94802391a341ed04cb6e374154b8b8ff1b545",
|
||||||
|
"rows_sha256": "5c04ffff27c8b31a0be2d39553ed035d3c677907cabc1d17a9ea5886f97f8e5d",
|
||||||
|
"rows_verified": 32,
|
||||||
|
"final_answer_audit": {
|
||||||
|
"n": 32,
|
||||||
|
"correct": {
|
||||||
|
"native": 32,
|
||||||
|
"direct": 0,
|
||||||
|
"lisa": 3
|
||||||
|
},
|
||||||
|
"substantive_loss_ids": [
|
||||||
|
"test-lookup-000",
|
||||||
|
"test-lookup-001",
|
||||||
|
"test-lookup-002",
|
||||||
|
"test-lookup-003",
|
||||||
|
"test-lookup-004",
|
||||||
|
"test-lookup-005",
|
||||||
|
"test-lookup-006",
|
||||||
|
"test-lookup-007",
|
||||||
|
"test-lookup-008",
|
||||||
|
"test-lookup-009",
|
||||||
|
"test-lookup-010",
|
||||||
|
"test-lookup-011",
|
||||||
|
"test-lookup-012",
|
||||||
|
"test-lookup-013",
|
||||||
|
"test-lookup-014",
|
||||||
|
"test-lookup-015",
|
||||||
|
"test-lookup-016",
|
||||||
|
"test-lookup-017",
|
||||||
|
"test-lookup-018",
|
||||||
|
"test-lookup-019",
|
||||||
|
"test-lookup-020",
|
||||||
|
"test-lookup-021",
|
||||||
|
"test-lookup-022",
|
||||||
|
"test-lookup-023",
|
||||||
|
"test-lookup-024",
|
||||||
|
"test-lookup-025",
|
||||||
|
"test-lookup-026",
|
||||||
|
"test-lookup-027",
|
||||||
|
"test-lookup-028",
|
||||||
|
"test-lookup-029",
|
||||||
|
"test-lookup-030",
|
||||||
|
"test-lookup-031"
|
||||||
|
],
|
||||||
|
"substantive_rescued_ids": [
|
||||||
|
"test-lookup-014",
|
||||||
|
"test-lookup-020",
|
||||||
|
"test-lookup-021"
|
||||||
|
],
|
||||||
|
"unscored": {
|
||||||
|
"native": 0,
|
||||||
|
"direct": 0,
|
||||||
|
"lisa": 0
|
||||||
|
},
|
||||||
|
"native_correct_lost_by_direct": 32,
|
||||||
|
"rescued": 3,
|
||||||
|
"newly_lost_among_native_and_direct_correct": 0,
|
||||||
|
"candidate_correct_direct_wrong": 3,
|
||||||
|
"direct_correct_candidate_wrong": 0,
|
||||||
|
"accuracy_delta_vs_direct": 0.09375,
|
||||||
|
"paired_prompt_bootstrap_95": [
|
||||||
|
0.0,
|
||||||
|
0.21875
|
||||||
|
],
|
||||||
|
"mcnemar_exact_p": 0.25
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
"""Protect final-answer scoring, split isolation and the screening threshold."""
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from crossqkv.lisa_full_answer import SCHEDULES, choose, final_integer, fixed_problems, grade
|
||||||
|
from crossqkv.lisa_full_answer_train import audit
|
||||||
|
|
||||||
|
|
||||||
|
class FullAnswerTests(unittest.TestCase):
|
||||||
|
def test_reads_the_terminal_answer_and_requires_eos(self):
|
||||||
|
self.assertEqual(final_integer('<think>First try 17.</think>\n42'), 42)
|
||||||
|
self.assertEqual(final_integer('Working: 17 and 25.\nFinal answer: 42.'), 42)
|
||||||
|
self.assertIsNone(final_integer('17 or 42'))
|
||||||
|
self.assertIsNone(final_integer('<think>17'))
|
||||||
|
self.assertIsNone(final_integer('<think>\nFinal answer: 42'))
|
||||||
|
|
||||||
|
class TextTokenizer:
|
||||||
|
def decode(self, tokens, skip_special_tokens):
|
||||||
|
return ''.join(tokens)
|
||||||
|
|
||||||
|
tok = TextTokenizer()
|
||||||
|
self.assertTrue(grade(tok, ['4', '2', '<EOS>'], 'eos', 42)['correct'])
|
||||||
|
self.assertFalse(grade(tok, ['4', '2'], 'max_new_tokens', 42)['correct'])
|
||||||
|
|
||||||
|
def test_frozen_splits_are_disjoint_and_schedule_must_lose_answers(self):
|
||||||
|
data = fixed_problems()
|
||||||
|
questions = [row['question'] for rows in data.values() for row in rows]
|
||||||
|
self.assertEqual(len(questions), len(set(questions)))
|
||||||
|
self.assertTrue(all(row['answer'] >= 10 for rows in data.values() for row in rows))
|
||||||
|
a = {name: {'correct': 6, 'native_correct_to_wrong_integer': []} for name in SCHEDULES}
|
||||||
|
self.assertIsNone(choose({'lookup': a}))
|
||||||
|
a['direct_4']['native_correct_to_wrong_integer'] = ['a', 'b']
|
||||||
|
self.assertEqual(choose({'lookup': a})['recipients'], [11, 15, 19, 23])
|
||||||
|
|
||||||
|
def test_audit_distinguishes_wrong_numbers_and_missing_answers(self):
|
||||||
|
def row(name, direct):
|
||||||
|
return {'id': name, 'arms': {'native': {'answer': 12, 'correct': True},
|
||||||
|
'direct': {'answer': direct, 'correct': False},
|
||||||
|
'lisa': {'answer': 12, 'correct': True}}}
|
||||||
|
|
||||||
|
report = audit([row('wrong', 13), row('missing', None)])
|
||||||
|
self.assertEqual(report['rescued'], 2)
|
||||||
|
self.assertEqual(report['substantive_loss_ids'], ['wrong'])
|
||||||
|
self.assertEqual(report['substantive_rescued_ids'], ['wrong'])
|
||||||
@@ -7,6 +7,7 @@ from torch.nn import functional as F
|
|||||||
|
|
||||||
from crossqkv.lisa_decode import AttentionSiteCache
|
from crossqkv.lisa_decode import AttentionSiteCache
|
||||||
from crossqkv.lisa_decode_bench import ResidentSite, timed_site
|
from crossqkv.lisa_decode_bench import ResidentSite, timed_site
|
||||||
|
from crossqkv.lisa_generate import GenerationDecoder
|
||||||
from crossqkv.lisa_tail import FrozenLinear, TorchTail, gated_delta, rotate
|
from crossqkv.lisa_tail import FrozenLinear, TorchTail, gated_delta, rotate
|
||||||
from crossqkv.lisa_train import LearnableSharingAttention
|
from crossqkv.lisa_train import LearnableSharingAttention
|
||||||
from functional.model import PREFIX, delta_rule, rope
|
from functional.model import PREFIX, delta_rule, rope
|
||||||
@@ -85,6 +86,17 @@ class TailTests(unittest.TestCase):
|
|||||||
lengths = torch.tensor([5, 5])
|
lengths = torch.tensor([5, 5])
|
||||||
native, _ = tail(h, None, lengths, 'native', ())
|
native, _ = tail(h, None, lengths, 'native', ())
|
||||||
torch.testing.assert_close(native, torch.tensor(expected), atol=2e-5, rtol=2e-5)
|
torch.testing.assert_close(native, torch.tensor(expected), atol=2e-5, rtol=2e-5)
|
||||||
|
padded = np.stack([ids[0], np.concatenate(([0, 0], ids[1, 2:]))])
|
||||||
|
for mode, schedules, modules in (
|
||||||
|
('direct', [(), (2,)], None), ('lisa', [(2,), (2,)], {2: adapters[2]})
|
||||||
|
):
|
||||||
|
decoder = GenerationDecoder(original, schedules, [0, 2], modules)
|
||||||
|
actual = torch.cat((decoder.advance(torch.tensor(padded[:, :4])),
|
||||||
|
decoder.advance(torch.tensor(padded[:, 4:]))), dim=1)
|
||||||
|
for bi, pad in enumerate((0, 2)):
|
||||||
|
x = h[bi:bi+1, pad:]
|
||||||
|
ref, _ = tail(x, None, torch.tensor([5-pad]), mode, schedules[bi])
|
||||||
|
torch.testing.assert_close(actual[bi:bi+1, pad:], ref, atol=2e-6, rtol=2e-5)
|
||||||
donor = torch.tensor(rand(2, 2, 5, 5))
|
donor = torch.tensor(rand(2, 2, 5, 5))
|
||||||
run, _ = tail(h, donor, lengths, 'lisa', (0,2), keep_teacher=False)
|
run, _ = tail(h, donor, lengths, 'lisa', (0,2), keep_teacher=False)
|
||||||
ref, _ = tail(h, donor, lengths, 'lisa', (0,2), keep_teacher=True)
|
ref, _ = tail(h, donor, lengths, 'lisa', (0,2), keep_teacher=True)
|
||||||
|
|||||||
@@ -43,6 +43,20 @@ class LiSATrainingTests(unittest.TestCase):
|
|||||||
torch.testing.assert_close(torch.autograd.grad(streamed, h)[0],
|
torch.testing.assert_close(torch.autograd.grad(streamed, h)[0],
|
||||||
torch.autograd.grad(dense, h)[0])
|
torch.autograd.grad(dense, h)[0])
|
||||||
|
|
||||||
|
def test_completion_loss_covers_all_reply_tokens(self):
|
||||||
|
h = torch.randn((2, 6, 3), generator=torch.Generator().manual_seed(4),
|
||||||
|
requires_grad=True)
|
||||||
|
w = torch.randn((8, 3), generator=torch.Generator().manual_seed(5))
|
||||||
|
ids = torch.tensor([[1, 2, 1, 4, 2, 7], [1, 3, 5, 7, 0, 0]])
|
||||||
|
lengths, starts = torch.tensor([6, 4]), torch.tensor([3, 2])
|
||||||
|
valid = (torch.arange(1, 6) < lengths[:, None]) & (torch.arange(1, 6) >= starts[:, None])
|
||||||
|
reference = F.cross_entropy(F.linear(h[:, :-1][valid], w), ids[:, 1:][valid])
|
||||||
|
streamed = language_model_loss(h, ids, lengths, lambda: iter([(0, w)]),
|
||||||
|
completion_starts=starts)
|
||||||
|
torch.testing.assert_close(streamed, reference)
|
||||||
|
torch.testing.assert_close(torch.autograd.grad(streamed, h)[0],
|
||||||
|
torch.autograd.grad(reference, h)[0])
|
||||||
|
|
||||||
def test_causality_and_gradients_for_both_adapter_components(self):
|
def test_causality_and_gradients_for_both_adapter_components(self):
|
||||||
torch.manual_seed(9)
|
torch.manual_seed(9)
|
||||||
a = LearnableSharingAttention(8, 2, 1, 8, 10000, .25, width=10)
|
a = LearnableSharingAttention(8, 2, 1, 8, 10000, .25, width=10)
|
||||||
|
|||||||
Reference in New Issue
Block a user