I want you to come up and invent your own sophisticated new neural network structure…
- User
I want you to come up and invent your own sophisticated new neural network structure that would be a better alternative to the generative Transformer architecture, making something that is much more fit to be smaller and efficient, you can borrow architecture design elements from Google Reformer.
You will write one long code file that:
- Implements the newly invented neural network architecture as an LLM model
- Saves the model and all its required files
- Trains the model on the following datasets to help it understand language and reasoning:
open-web-math/open-web-math - same way used in SAMPLE CODE tau/commonsense_qa - same way used in SAMPLE CODE tau/commonsense_qa - same way used in SAMPLE CODE
VMware/open-instruct - using the fields “instruction” and “response” (instruction: The natural language instruction; response: Expected response to the instruction)
All the other models in the SAMPLE CODE
The code file must:
- Be run on a MacBook Air with 8GB of memory and not use MPS.
- Must be storage efficient and use streaming for datasets and not fill my storage
THE RESEARCH:
https://arxiv.org/pdf/2403.09629
THE SAMPLE CODE:
import torch torch.backends.cuda.matmul.allow_tf32 = True import random from transformers import AutoTokenizer, AutoModelForCausalLM, TextGenerationPipeline, AutoConfig from accelerate import infer_auto_device_map, init_empty_weights, dispatch_model from datasets import load_dataset from torch.nn import CrossEntropyLoss from transformers import TrainingArguments, Trainer import os import time import wandb from huggingface_custom_callback import EarlyStoppingCallback from eval_helpers import preprocess_eval_function_gsm, preprocess_eval_function_csqa, preprocess_function, compute_metrics, truncate_or_pad random_seed = 42 torch.manual_seed(random_seed) random.seed(random_seed)
MAIN SETUP
root_prefix = "YOUR_CACHE_PATH_HERE" wandb_cache_dir = root_prefix + "cache/quietstar/wandb_cache" dataset_name = 'open-web-math/open-web-math'
dataset_name = 'c4'
project_name = "quiet-star" os.environ["WANDB_PROJECT"] = project_name + "-" + dataset_name.split("/")[-1] os.environ["WANDB_CACHE_DIR"] = wandb_cache_dir n_ahead_talk_global = 4 n_passes_global = 2 n_ahead_global = 12 n_examples = 1_000 full_batch_size = 8 eval_and_logging_steps = 10 save_steps = 100
def model_init(params): original = False if params is None: params = {} else: params = params.params # save params to file n_ahead = params.get("n_ahead", n_ahead_global if not original else 1) n_ahead_talk = params.get("n_ahead_talk", n_ahead_talk_global if not original else 1) n_passes = params.get("n_passes", n_passes_global if not original else 1) gumbel_temperature = params.get("gumbel_temperature", 1) use_start_thought_token = params.get("use_start_thought_token", True) use_end_thought_token = params.get("use_end_thought_token", True) include_policy_loss = params.get("include_policy_loss", True) gumbel_detach = params.get("gumbel_detach", True) merged_talk_heads = params.get("merged_talk_heads", True) gradient_accumulation_steps = params.get("gradient_accumulation_steps", global_gradient_accumulation_steps) residual_think_head = params.get("residual_think_head", False) optimize_lm_head_only_at_start = params.get("optimize_lm_head_only_at_start", False)
- Assistant