Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Lightning-AI/lit-llama
/ functions
Functions
276 in github.com/Lightning-AI/lit-llama
⨍
Functions
276
◇
Types & classes
39
↳
Endpoints
1
↓ 26 callers
Method
encode
( self, string: str, bos: bool = True, eos: bool = False, max_length:
lit_llama/tokenizer.py:24
↓ 23 callers
Method
save
(self, obj)
lit_llama/utils.py:475
↓ 22 callers
Method
from_name
(cls, name: str)
lit_llama/model.py:125
↓ 16 callers
Method
decode
(self, tokens: torch.Tensor)
lit_llama/tokenizer.py:45
↓ 15 callers
Method
train
Set the module into train or eval mode if `mode` is True of False respectively. For train mode (train(True)) if weights are merged we need to
lit_llama/lora.py:243
↓ 12 callers
Function
_check_python_packages
()
lit_llama/utils.py:504
↓ 12 callers
Function
generate_prompt
Generates a standardized message to prompt the model with an instruction, optional input and a 'response' field.
scripts/prepare_alpaca.py:113
↓ 9 callers
Function
generate
Takes a conditioning sequence (prompt) as input and continues to generate as many tokens as requested. The implementation of this function is mod
generate.py:21
↓ 9 callers
Function
llama_model_lookup
Returns the LLaMA model name from the checkpoint. Checks the width of the lm_head.weight matrix, as these uniquely identify the model.
lit_llama/utils.py:29
↓ 8 callers
Method
_load_tensor
()
lit_llama/utils.py:181
↓ 8 callers
Method
init_module
(self, empty_init)
tests/test_generate.py:72
↓ 6 callers
Function
find_multiple
(n: int, k: int)
lit_llama/utils.py:38
↓ 6 callers
Function
lora
Apply context manager under which you can instantiate the model with LoRA. In a nutshell the code inside this function forces to use LoRA variant
lit_llama/lora.py:450
↓ 5 callers
Method
build_rope_cache
(self, idx: torch.Tensor)
lit_llama/model.py:128
↓ 4 callers
Method
__init__
(self, config: LLaMAConfig)
lit_llama/model.py:241
↓ 4 callers
Method
add_array
(self, arr)
lit_llama/packed_dataset.py:124
↓ 4 callers
Function
apply_rope
(x: torch.Tensor, rope_cache: RoPECache)
lit_llama/model.py:306
↓ 4 callers
Method
build_mask_cache
(self, idx: torch.Tensor)
lit_llama/model.py:136
↓ 4 callers
Function
quantization
(mode: str = None)
lit_llama/utils.py:142
↓ 4 callers
Method
reset_cache
(self)
lit_llama/model.py:140
↓ 4 callers
Function
save_model_checkpoint
Handles boilerplate logic for retrieving and saving the state_dict. This will be upstreamed to Fabric soon.
lit_llama/utils.py:44
↓ 3 callers
Method
__init__
Store LoRA specific attributes in a class. Args: r: rank of the weight update matrices. To make sense of using LoRA the rank shou
lit_llama/lora.py:60
↓ 3 callers
Function
add_adapter_v2_parameters_to_linear_layers
(model)
lit_llama/adapter_v2.py:44
↓ 3 callers
Method
store_early
(self, tensor)
lit_llama/utils.py:470
↓ 2 callers
Method
__init__
(self, config: LLaMAConfig, block_idx: int)
lit_llama/adapter.py:197
↓ 2 callers
Method
__init__
(self, fn)
lit_llama/utils.py:333
↓ 2 callers
Method
_close_mmaps
(self)
lit_llama/packed_dataset.py:179
↓ 2 callers
Method
_load_n_chunks
(self)
lit_llama/packed_dataset.py:183
↓ 2 callers
Method
_quantize_weight
(self, weight: torch.Tensor)
lit_llama/quantization.py:69
↓ 2 callers
Method
_write_chunk
(self)
lit_llama/packed_dataset.py:100
↓ 2 callers
Method
_write_storage_and_return_key
(self, storage)
lit_llama/utils.py:486
↓ 2 callers
Function
adapter_state_from_state_dict
Returns the model state dict with only the adapter weights for saving.
lit_llama/adapter.py:313
↓ 2 callers
Function
adapter_v2_linear_with_bias_and_scale
(layer)
lit_llama/adapter_v2.py:36
↓ 2 callers
Function
adapter_v2_state_from_state_dict
Returns the model state dict with only the adapter weights for saving.
lit_llama/adapter_v2.py:24
↓ 2 callers
Function
copy_weights
(llama_model, orig_llama_model)
tests/test_model.py:29
↓ 2 callers
Function
create_dataloader
( batch_size: int, block_size: int, data_dir: str, fabric, shuffle: bool = True, seed:
pretrain/redpajama.py:237
↓ 2 callers
Function
download_original
(wd: str)
scripts/download.py:13
↓ 2 callers
Method
dtype
(self)
lit_llama/packed_dataset.py:117
↓ 2 callers
Function
enable_gate
(model)
tests/test_model.py:155
↓ 2 callers
Method
find_params_weight
(self, x)
lit_llama/quantization.py:477
↓ 2 callers
Function
get_adapter_substrings
()
lit_llama/adapter_v2.py:11
↓ 2 callers
Function
get_batch
(fabric: L.Fabric, data: list)
finetune/adapter.py:217
↓ 2 callers
Function
get_batch
(fabric: L.Fabric, data: list)
finetune/full.py:201
↓ 2 callers
Function
get_batch
(fabric: L.Fabric, data: list)
finetune/lora.py:196
↓ 2 callers
Function
get_batch
(fabric: L.Fabric, data: list)
finetune/adapter_v2.py:220
↓ 2 callers
Function
get_batch
(fabric: L.Fabric, data: np.ndarray, block_size: int)
pretrain/shakespeare.py:152
↓ 2 callers
Function
load_generate_script
()
tests/test_generate.py:18
↓ 2 callers
Function
lora_state_dict
Return state_dict with weights of LoRA's A and B matrices and with biases depending on the `bias` value. Args: model: model with LoRA lay
lit_llama/lora.py:364
↓ 2 callers
Function
loss_fn
(logits, targets)
finetune/adapter.py:209
↓ 2 callers
Function
loss_fn
(logits, targets)
finetune/full.py:193
↓ 2 callers
Function
loss_fn
(logits, targets)
finetune/lora.py:188
↓ 2 callers
Function
loss_fn
(logits, targets)
finetune/adapter_v2.py:212
↓ 2 callers
Function
mark_only_lora_as_trainable
Freeze all modules except LoRA's and depending on 'bias' value unfreezes bias weights. Args: model: model with LoRA layers bias:
lit_llama/lora.py:329
↓ 2 callers
Function
pad_right
(x, pad_id)
finetune/adapter.py:225
↓ 2 callers
Function
pad_right
(x, pad_id)
finetune/full.py:209
↓ 2 callers
Function
pad_right
(x, pad_id)
finetune/lora.py:204
↓ 2 callers
Function
pad_right
(x, pad_id)
finetune/adapter_v2.py:228
↓ 2 callers
Function
permute
(w)
scripts/convert_hf_checkpoint.py:63
↓ 2 callers
Function
prepare_line
Processes a single sample. This function processes the line to produce the tokenized version of it.
scripts/prepare_any_text.py:78
↓ 2 callers
Function
prepare_sample
Processes a single sample. Each sample in the dataset consists of: - instruction: A string describing the task - input: A string hold
scripts/prepare_dolly.py:81
↓ 2 callers
Function
prepare_sample
Processes a single sample. Each sample in the dataset consists of: - instruction: A string describing the task - input: A string hold
scripts/prepare_alpaca.py:78
↓ 2 callers
Method
quantize
(self)
lit_llama/quantization.py:531
↓ 2 callers
Function
save_model_checkpoint
(fabric, model, file_path)
finetune/adapter.py:282
↓ 2 callers
Function
save_model_checkpoint
(fabric, model, file_path)
finetune/adapter_v2.py:285
↓ 2 callers
Function
tokenize
(tokenizer: Tokenizer, string: str, max_length: int, eos=True)
scripts/prepare_dolly.py:111
↓ 2 callers
Function
tokenize
(tokenizer: Tokenizer, string: str, max_length: int, eos=True)
scripts/prepare_alpaca.py:109
↓ 2 callers
Function
train_tokenizer
(destination_path)
tests/test_prepare_redpajama.py:16
↓ 2 callers
Method
write_reminder
(self)
lit_llama/packed_dataset.py:135
↓ 2 callers
Method
zero_pad
Properly pad weight updates with zeros. If, based on `self.enable_lora`, we want to fine-tune queries and values, but not keys, then
lit_llama/lora.py:205
↓ 1 callers
Method
__enter__
(self)
lit_llama/utils.py:339
↓ 1 callers
Method
__exit__
(self, exc_type, exc_val, exc_tb)
lit_llama/utils.py:342
↓ 1 callers
Method
__init__
(self, *args, **kwargs)
lit_llama/quantization.py:46
↓ 1 callers
Method
__reduce_ex__
(self, protocol_version)
lit_llama/utils.py:395
↓ 1 callers
Method
_read_header
(self, path)
lit_llama/packed_dataset.py:168
↓ 1 callers
Function
build_rope_cache
Enhanced Transformer with Rotary Position Embedding. Derived from: https://github.com/labmlai/annotated_deep_learning_paper_implementations/blob/
lit_llama/model.py:280
↓ 1 callers
Function
code
(dtype)
lit_llama/packed_dataset.py:28
↓ 1 callers
Function
convert_state_dict
(state_dict: Dict[str, torch.Tensor], dtype: torch.dtype = torch.float32)
scripts/convert_checkpoint.py:22
↓ 1 callers
Function
copy_adapter_weights
(llama_model, orig_llama_model)
tests/test_model.py:136
↓ 1 callers
Function
copy_attention
(llama_attn, orig_llama_attn)
tests/test_model.py:14
↓ 1 callers
Function
copy_block
(llama_block, orig_llama_block)
tests/test_model.py:22
↓ 1 callers
Function
copy_mlp
(llama_mlp, orig_llama_mlp)
tests/test_model.py:8
↓ 1 callers
Function
create_dataloaders
( batch_size: int, block_size: int, fabric, train_data_dir: str = "data/lit-redpajama", va
pretrain/redpajama.py:268
↓ 1 callers
Function
del_lora_state_dict
(model: nn.Module)
scripts/convert_lora_weights.py:20
↓ 1 callers
Function
download
Downloads the raw json data file and saves it in the given destination.
scripts/prepare_dolly.py:73
↓ 1 callers
Function
download
Downloads the raw json data file and saves it in the given destination.
scripts/prepare_alpaca.py:70
↓ 1 callers
Function
generate_prompt
Generates a standardized message to prompt the model with an instruction, optional input and a 'response' field.
scripts/prepare_dolly.py:115
↓ 1 callers
Function
generate_response
(model, instruction, input="")
finetune/adapter.py:169
↓ 1 callers
Function
generate_response
(model, instruction)
finetune/full.py:152
↓ 1 callers
Function
generate_response
(model, instruction, tokenizer_path)
finetune/lora.py:148
↓ 1 callers
Function
generate_response
(model, instruction, input="")
finetune/adapter_v2.py:174
↓ 1 callers
Function
get_dataloader
( fabric: L.Fabric, data: torch.Tensor, micro_batch_size: int, group_by_length: bool, )
finetune/adapter.py:249
↓ 1 callers
Function
get_dataloader
( fabric: L.Fabric, data: torch.Tensor, micro_batch_size: int, group_by_length: bool, )
finetune/full.py:233
↓ 1 callers
Function
get_dataloader
( fabric: L.Fabric, data: torch.Tensor, micro_batch_size: int, group_by_length: bool, )
finetune/lora.py:228
↓ 1 callers
Function
get_dataloader
( fabric: L.Fabric, data: torch.Tensor, micro_batch_size: int, group_by_length: bool, )
finetune/adapter_v2.py:252
↓ 1 callers
Function
get_length_grouped_indices
Return a list of indices so that each slice of `batch_size` consecutive indices correspond to elements of similar lengths. To do this, the in
finetune/length_grouped_sampler.py:26
↓ 1 callers
Function
get_lr
(it)
pretrain/redpajama.py:302
↓ 1 callers
Function
get_sample_data
()
quantize/gptq.py:24
↓ 1 callers
Method
get_weight
(self, dtype=torch.float)
lit_llama/quantization.py:392
↓ 1 callers
Function
llama_blockwise_quantization
This is the classic post-training quantization of all linear layers. We quantize in order, i.e. when observing the inputs, we use the outputs
quantize/gptq.py:39
↓ 1 callers
Function
load_datasets
(data_dir)
finetune/adapter.py:276
next →
1–100 of 276, ranked by callers