This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from transformers import AutoTokenizer, T5ForConditionalGeneration | |
| # Model Init | |
| n_gpu = 8 | |
| tokenizer = AutoTokenizer.from_pretrained("google/flan-ul2") | |
| model = T5ForConditionalGeneration.from_pretrained("google/flan-ul2") | |
| heads_per_gpu = len(model.encoder.block) // n_gpu | |
| device_map = { | |
| gpu: list( | |
| range( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import List, Optional, Tuple, Union | |
| from torchtyping import TensorType | |
| from transformers.adapters.modeling import Adapter | |
| from transformers.adapters import ( | |
| BartAdapterModel, | |
| RobertaAdapterModel, | |
| BertAdapterModel, | |
| AdapterConfig, | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ast | |
| # To Delete After Debug | |
| import code | |
| import copyreg | |
| import datetime | |
| import functools | |
| import json | |
| import os | |
| import re |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def _push_parquet_shards_to_hub( [1071/1877] | |
| self, | |
| repo_id: str, | |
| data_dir: str = "data", | |
| split: Optional[str] = None, | |
| token: Optional[str] = None, | |
| revision: Optional[str] = None, | |
| create_pr: Optional[bool] = False, | |
| max_shard_size: Optional[Union[int, str]] = None, | |
| num_shards: Optional[int] = None, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| text = # Tokenized Text Corresponding to Recording Transcript | |
| audio = # Mel Spectrogram of the Recording | |
| # Only Train Connector and Projection | |
| self.encoder.freeze() | |
| self.llama.freeze() | |
| # Convert Raw Audio Signal to 1500 Embeddings with Whisper Encoder (CNN+Transformer) | |
| audio_features = self.encoder(audio) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from time import sleep | |
| from datasets import load_dataset | |
| from huggingface_hub import InferenceClient | |
| from ratelimit import limits, sleep_and_retry | |
| from transformers import AutoTokenizer | |
| dataset = load_dataset("yijingwu/HeySQuAD_human", split="train") | |
| tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import gradio as gr | |
| import math | |
| import numpy as np | |
| import time | |
| import io | |
| import wave | |
| def wave_header_chunk(frame_input=b"", channels=1, sample_width=2, sample_rate=24000): | |
| # This will create a wave header then append the frame input |
OlderNewer