Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/architkaila/Fine-Tuning-LLMs-for-Medical-Entity-Extraction
/ functions
Functions
184 in github.com/architkaila/Fine-Tuning-LLMs-for-Medical-Entity-Extraction
⨍
Functions
184
◇
Types & classes
39
↓ 12 callers
Method
norm_class
(self)
lit_gpt/config.py:134
↓ 10 callers
Method
encode
( self, string: str, device: Optional[torch.device] = None, bos: Optional[bool
lit_gpt/tokenizer.py:80
↓ 8 callers
Method
decode
(self, tensor: torch.Tensor)
lit_gpt/tokenizer.py:105
↓ 8 callers
Function
map_old_state_dict_weights
(state_dict: Dict, mapping: Mapping, prefix: str)
lit_gpt/utils.py:287
↓ 7 callers
Method
__init__
(self, config: Config)
lit_gpt/lora.py:455
↓ 7 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/base.py:58
↓ 7 callers
Function
generate_prompt
Generates a standardized message to prompt the model with an input and a 'response' field.
scripts/prepare_entity_extraction_data.py:132
↓ 7 callers
Function
load_param
(param: Union[torch.Tensor, NotYetLoadedTensor], name: str, dtype: Optional[torch.dtype])
scripts/convert_hf_checkpoint.py:236
↓ 6 callers
Function
check_valid_checkpoint_dir
(checkpoint_dir: Path)
lit_gpt/utils.py:56
↓ 6 callers
Function
num_parameters
(module: nn.Module, requires_grad: Optional[bool] = None)
lit_gpt/utils.py:29
↓ 6 callers
Method
save
(self, obj)
lit_gpt/utils.py:211
↓ 6 callers
Method
set_kv_cache
( self, batch_size: int, rope_cache_length: Optional[int] = None, device: Opti
lit_gpt/model.py:105
↓ 5 callers
Method
__init__
(self, config: Config)
lit_gpt/adapter_v2.py:63
↓ 5 callers
Method
__init__
(self, config: Config)
lit_gpt/model.py:17
↓ 5 callers
Method
from_json
(cls, path: Union[str, Path], **kwargs: Any)
lit_gpt/config.py:105
↓ 4 callers
Function
chunked_cross_entropy
( logits: Union[torch.Tensor, List[torch.Tensor]], targets: torch.Tensor, chunk_size: int = 128 )
lit_gpt/utils.py:241
↓ 4 callers
Function
gptq_quantization
(enabled: bool = False)
lit_gpt/utils.py:41
↓ 4 callers
Function
layer_template
(layer_name: str, idx: int)
scripts/convert_hf_checkpoint.py:228
↓ 4 callers
Method
store_early
(self, tensor)
lit_gpt/utils.py:206
↓ 3 callers
Method
_load_from_state_dict
For compatibility with base checkpoints.
lit_gpt/lora.py:515
↓ 3 callers
Method
_load_from_state_dict
For compatibility with base checkpoints.
lit_gpt/adapter_v2.py:90
↓ 3 callers
Method
from_name
(cls, name: str, **kwargs: Any)
lit_gpt/lora.py:506
↓ 3 callers
Function
get_default_supported_precision
Return default precision that is supported by the hardware: either `bf16` or `16`. Args: training: `-mixed` or `-true` version of the pre
lit_gpt/utils.py:296
↓ 3 callers
Function
load_checkpoint
(fabric: L.Fabric, model: nn.Module, checkpoint_path: Path, strict: bool = True)
lit_gpt/utils.py:312
↓ 3 callers
Method
mlp_class
(self)
lit_gpt/lora.py:450
↓ 3 callers
Method
reset_parameters
Reset all the weights, even including pretrained ones.
lit_gpt/lora.py:128
↓ 2 callers
Method
__init__
(self, config: Config)
lit_gpt/adapter.py:31
↓ 2 callers
Method
_close_mmaps
(self)
lit_gpt/packed_dataset.py:161
↓ 2 callers
Method
_load_n_chunks
(self)
lit_gpt/packed_dataset.py:165
↓ 2 callers
Method
_write_chunk
(self)
lit_gpt/packed_dataset.py:82
↓ 2 callers
Method
_write_storage_and_return_key
(self, storage)
lit_gpt/utils.py:222
↓ 2 callers
Function
apply_rope
(x: torch.Tensor, cos: torch.Tensor, sin: torch.Tensor)
lit_gpt/model.py:313
↓ 2 callers
Method
clear_kv_cache
(self)
lit_gpt/model.py:129
↓ 2 callers
Method
conv1d
An extension of the `torch.nn.functional.conv1d` function with a logic specific to grouped queries. If the number of heads is equal to the nu
lit_gpt/lora.py:298
↓ 2 callers
Function
flops_per_param
(max_seq_length: int, n_layer: int, n_embd: int, n_params: int)
lit_gpt/utils.py:321
↓ 2 callers
Function
get_batch
Function for getting a batch of data Args: fabric: Lightning Fabric object data: Data longest_seq_ix: Index of th
finetune/lora.py:324
↓ 2 callers
Function
get_batch
This function gets a batch of data. Args: fabric (Fabric): Fabric object. data (List[Dict]): Data to get a batch from.
finetune/adapter_v2.py:278
↓ 2 callers
Function
next_token
(model: GPT, input_pos: torch.Tensor, x: torch.Tensor, **kwargs: Any)
generate/base.py:51
↓ 2 callers
Function
next_token
This function is derived from the original file provided by the LIT team: Args: model: The model to use. input_pos: Tensor o
generate/inference_base.py:80
↓ 2 callers
Function
pad_right
(x, pad_id)
finetune/lora.py:350
↓ 2 callers
Function
pad_right
(x, pad_id)
finetune/adapter_v2.py:303
↓ 2 callers
Function
parse_entities
Parse entities from a record in the data. Args: - record: A dictionary representing a single record in the data. - key: The key
scripts/evaluate.py:3
↓ 2 callers
Function
prepare_sample
Processes a single sample. Each sample in the dataset consists of: - input: A string containing adverse event description (email) - outpu
scripts/prepare_entity_extraction_data.py:100
↓ 2 callers
Method
reset_parameters
(self)
lit_gpt/model.py:57
↓ 2 callers
Method
rope_cache
(self, device: Optional[torch.device] = None)
lit_gpt/model.py:96
↓ 2 callers
Function
save_adapter_v2_checkpoint
This function saves the adapter v2 checkpoint. Args: fabric (Fabric): Fabric object. model (torch.nn.Module): The model to s
finetune/adapter_v2.py:340
↓ 2 callers
Function
save_lora_checkpoint
Function for saving the LoRA checkpoint Args: fabric: Lightning Fabric object model: GPT model file_path: Path to th
finetune/lora.py:388
↓ 2 callers
Method
token_to_id
(self, token: str)
lit_gpt/tokenizer.py:58
↓ 2 callers
Function
validate
Function for validating the model on the entity extraction task using LoRA Args: fabric: Lightning Fabric object model: GPT
finetune/lora.py:283
↓ 2 callers
Function
validate
Finetune the adapter v2 model on the entity extraction task. This function validates the model. Args: fabric (Fabric): Fabric object
finetune/adapter_v2.py:237
↓ 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_gpt/lora.py:256
↓ 1 callers
Method
__init__
(self, *args, **kwargs)
lit_gpt/utils.py:50
↓ 1 callers
Method
__reduce_ex__
(self, protocol_version)
lit_gpt/utils.py:134
↓ 1 callers
Method
_read_header
(self, path)
lit_gpt/packed_dataset.py:150
↓ 1 callers
Function
adapter_filter
(key: str, value: Any)
lit_gpt/adapter.py:164
↓ 1 callers
Function
adapter_filter
(key: str, value: Any)
lit_gpt/adapter_v2.py:31
↓ 1 callers
Method
build_kv_cache
( self, batch_size: int, max_seq_length: int, rope_cache_length: Optional[int]
lit_gpt/model.py:240
↓ 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_gpt/model.py:292
↓ 1 callers
Function
calculate_precision_recall
Calculate precision and recall from the data. Args: - data: A list of dictionaries, each containing 'output' and 'prediction'. Retu
scripts/evaluate.py:31
↓ 1 callers
Method
check_if_bos_token_used
(self, checkpoint_dir: Path)
lit_gpt/tokenizer.py:69
↓ 1 callers
Function
code
(dtype)
lit_gpt/packed_dataset.py:16
↓ 1 callers
Function
create_dataset
Create a dataset of Adverse Event Reports for the Drugs using the OpenAI Chat Completions API. Args: folder_path (str): Path to the
scripts/data-prepare.py:101
↓ 1 callers
Function
create_prompt
Create a prompt for the OpenAI API using the drug name and the drug report. Args: drug_name (str): Name of the drug drug_rep
scripts/data-prepare.py:36
↓ 1 callers
Function
download_if_missing
Downloads the raw json data file and saves it in the given destination.
scripts/prepare_entity_extraction_data.py:92
↓ 1 callers
Method
dtype
(self)
lit_gpt/packed_dataset.py:99
↓ 1 callers
Function
extract_section_by_id
Extracts the section with the given ID from the HTML content. Args: soup (BeautifulSoup): BeautifulSoup object containing the HTML
scripts/scrape_drugs_data.py:9
↓ 1 callers
Function
find_multiple
(n: int, k: int)
lit_gpt/utils.py:22
↓ 1 callers
Method
from_name
(cls, name: str, **kwargs: Any)
lit_gpt/config.py:88
↓ 1 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/inference_base.py:98
↓ 1 callers
Function
generate_adverse_event_report
Generate Adverse Event Reports for the Drug using the OpenAI API. Args: prompt (str): Prompt for the OpenAI API Returns:
scripts/data-prepare.py:8
↓ 1 callers
Function
generate_prediction
This function is used to generate predictions using the fine-tuned adapter models. It loads the model and generates and prints a sample predi
generate/inference_adapter.py:30
↓ 1 callers
Function
generate_prediction
This function is used to generate predictions using the fine-tuned LoRA models. It loads the model and generates and prints a sample predicti
generate/inference_lora.py:34
↓ 1 callers
Function
generate_prediction
This function is used to generate predictions using the fine-tuned adapter models. It loads the model and generates and prints a sample predi
generate/inference_base.py:142
↓ 1 callers
Function
genrate_train_test_data
Generate train and test data from the JSON files in the given folder path. Args: folder_path (str): Path to the folder containing JS
scripts/combine-data.py:5
↓ 1 callers
Function
get_longest_seq_length
Function for getting the longest sequence length Args: data: Data Returns: longest_seq_length: Longest sequence length
finetune/lora.py:370
↓ 1 callers
Function
get_longest_seq_length
This function gets the longest sequence length. Args: data (List[Dict]): Data to get the longest sequence length from. Returns:
finetune/adapter_v2.py:323
↓ 1 callers
Function
mark_only_adapter_v2_as_trainable
Sets requires_grad=False for all non-adapter weights
lit_gpt/adapter_v2.py:194
↓ 1 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_gpt/lora.py:389
↓ 1 callers
Method
merge
Merges the LoRA weights into the full-rank weights (W = W + delta_W).
lit_gpt/lora.py:136
↓ 1 callers
Function
merge_lora_weights
Merge LoRA weights into the full-rank weights to speed up inference.
lit_gpt/lora.py:655
↓ 1 callers
Method
mlp_class
(self)
lit_gpt/adapter_v2.py:27
↓ 1 callers
Function
multinomial_num_samples_1
(probs: torch.Tensor)
generate/base.py:29
↓ 1 callers
Function
multinomial_num_samples_1
This function is derived from the original file provided by the LIT team: Args: probs: Tensor of shape (..., N) containing probabili
generate/inference_base.py:39
↓ 1 callers
Method
reset_parameters
(self)
lit_gpt/adapter.py:148
↓ 1 callers
Method
reset_parameters
(self)
lit_gpt/adapter_v2.py:57
↓ 1 callers
Function
sample
(logits: torch.Tensor, temperature: float = 1.0, top_k: Optional[int] = None)
generate/base.py:37
↓ 1 callers
Function
sample
This function is derived from the original file provided by the LIT team: Args: logits: Tensor of shape (..., N) containing logits f
generate/inference_base.py:56
↓ 1 callers
Method
scaled_dot_product_attention
( self, q: torch.Tensor, k: torch.Tensor, v: torch.Tensor, mask: Optional[torch.Tensor] = None )
lit_gpt/model.py:231
↓ 1 callers
Function
train
Function for training the model on the entity extraction task using LoRA Args: fabric: Lightning Fabric object model: GPT mo
finetune/lora.py:190
↓ 1 callers
Function
train
Finetune the adapter v2 model on the entity extraction task. This function trains the model. Args: fabric (Fabric): Fabric object.
finetune/adapter_v2.py:148
Method
__del__
(self)
lit_gpt/packed_dataset.py:192
Method
__enter__
(self)
lit_gpt/utils.py:203
Method
__exit__
(self, type, value, traceback)
lit_gpt/utils.py:234
Method
__init__
(self, config: Config, block_idx: int)
lit_gpt/adapter.py:89
Method
__init__
(self, config: Config, block_idx: int)
lit_gpt/adapter.py:105
Method
__init__
(self, obj, saver, protocol_version=5)
lit_gpt/utils.py:91
Method
__init__
(self, tensor, saver, protocol_version=5)
lit_gpt/utils.py:119
Method
__init__
(self, saver, *args, **kwargs)
lit_gpt/utils.py:141
Method
__init__
(self, name)
lit_gpt/utils.py:197
Method
__init__
(self, checkpoint_dir: Union[Path, str])
lit_gpt/tokenizer.py:9
next →
1–100 of 184, ranked by callers