Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/LLMBook-zh/LLMBook-zh.github.io
/ functions
Functions
49 in github.com/LLMBook-zh/LLMBook-zh.github.io
⨍
Functions
49
◇
Types & classes
17
↓ 2 callers
Method
_forward_rmloss
(self, input_ids, attention_mask, **kargs)
code/8.1 奖励模型训练.py:14
↓ 2 callers
Method
encode
(self, examples)
code/6.3 预训练数据类.py:25
↓ 2 callers
Method
forward
(self, sent1_idx, attention_mask_1, sent2_idx, attention_mask_2, labels, prompt_ids, lm_attn_mask, response_id
code/8.1 奖励模型训练.py:50
↓ 2 callers
Function
rotate_half
(x)
code/5.2 RoPE.py:1
↓ 1 callers
Method
_forward_lmloss
(self, prompt_ids, lm_attn_mask, response_ids)
code/8.1 奖励模型训练.py:29
↓ 1 callers
Function
dequantize_func
(x_q, scales, zero_point)
code/9.2 量化示例.py:9
↓ 1 callers
Method
encode_src_tgt
(self, s, t, tokenizer)
code/7.2 SFT数据类.py:37
↓ 1 callers
Function
encode_with_bpe
使用字节对编码(BPE)算法对输入文本进行编码。此函数首先提取词元的初始频率, 然后迭代合并频率最高的字符对,直到达到指定的合并次数或没有可合并的对为止。 参数: texts (list of str): 输入的字符串列表,每个字符串代表一段文本。 num
code/4.4 BPE分词.py:61
↓ 1 callers
Function
extract_frequencies
将输入文本列表中的每个文本转换为带有结束标记'</w>'的单个字符序列, 并计算每种序列的频率。此函数使用Counter来累加每种序列的出现次数, 这样可以快速得到每个序列在文本中出现的总次数。 参数: texts (list of str): 输
code/4.4 BPE分词.py:4
↓ 1 callers
Function
frequency_of_pairs
从给定的频率字典中计算所有相邻字符对的频率。通过遍历每个词元, 查找并统计所有相邻字符对的出现频率。 参数: frequencies (Counter): 词元到其频率的映射字典。 返回: Counter: 字符对到其频率的映射字典。
code/4.4 BPE分词.py:22
↓ 1 callers
Function
get_data
(split, data_path)
code/8.2 DPO实践.py:36
↓ 1 callers
Method
group_texts
(self, examples)
code/6.3 预训练数据类.py:30
↓ 1 callers
Function
merge_vocab
合并词汇表中最频繁的字符对。此函数接受一个字符对和当前的词汇表, 将所有包含该字符对的词元中的对应字符合并为一个单一字符, 并更新词汇表以反映这一变化。 参数: pair (tuple): 要合并的字符对。 vocab (Counter): 当前的
code/4.4 BPE分词.py:40
↓ 1 callers
Method
process
(self, tokenizer)
code/7.2 SFT数据类.py:48
↓ 1 callers
Method
process
(self)
code/6.3 预训练数据类.py:41
↓ 1 callers
Function
quantize_func
(x, scales, zero_point, n_bits=8)
code/9.2 量化示例.py:4
↓ 1 callers
Function
train
()
code/7.1 SFT实践.py:64
↓ 1 callers
Function
train
()
code/6.2 预训练实践.py:43
↓ 1 callers
Function
train
()
code/8.2 DPO实践.py:53
↓ 1 callers
Function
train
()
code/7.4 LoRA实践.py:32
Method
__call__
(self, instances)
code/7.1 SFT实践.py:52
Method
__getitem__
(self, i)
code/7.2 SFT数据类.py:33
Method
__getitem__
(self, i)
code/6.3 预训练数据类.py:21
Method
__init__
(self, config)
code/6.1 LM损失.py:2
Method
__init__
(self)
code/4.3 隐私过滤.py:5
Method
__init__
(self)
code/4.2 去重.py:6
Method
__init__
(self, config: LlamaConfig)
code/5.5 LLaMA.py:2
Method
__init__
(self, config)
code/8.1 奖励模型训练.py:8
Method
__init__
(self, args, tokenizer)
code/7.2 SFT数据类.py:22
Method
__init__
(self, experts: List[nn.Module], gate: nn.Module, num_experts_per_tok: int)
code/5.4 MoE.py:2
Method
__init__
(self, config: LlamaConfig, layer_idx: int)
code/5.6 LLaMALayer.py:2
Method
__init__
(self, args, tokenizer)
code/6.3 预训练数据类.py:8
Method
__init__
(self)
code/4.1 质量过滤.py:4
Method
__init__
(self, in_features, out_features, config, bias=True)
code/7.3 LoRA基础.py:4
Method
__init__
(self, hidden_size, eps=1e-6)
code/5.1 RMSNorm.py:2
Method
__len__
(self)
code/7.2 SFT数据类.py:29
Method
__len__
(self)
code/6.3 预训练数据类.py:17
Function
apply_rotary_pos_emb
(q, k, cos, sin, position_ids)
code/5.2 RoPE.py:7
Function
build_alibi_tensor
(attention_mask: torch.Tensor, num_heads: int, dtype: torch.dtype)
code/5.3 ALiBi.py:1
Method
clean_single_text
(self, text: str, repl_text: str = "**MASKED**IDCARD**")
code/4.3 隐私过滤.py:7
Method
clean_single_text
(self, text: str, n: int = 5, thre_sim: float = 0.95)
code/4.2 去重.py:11
Method
filter_single_text
(self, text: str, accept_lang_list: list)
code/4.1 质量过滤.py:8
Function
forward
( self, input_ids: torch.LongTensor = None, attention_mask: Optional[torch.Tensor] = N
code/5.5 LLaMA.py:18
Method
forward
( self, input_ids: torch.LongTensor = None, attention_mask: Optional[torch.Tensor] = N
code/6.1 LM损失.py:8
Method
forward
(self, inputs: torch.Tensor)
code/5.4 MoE.py:10
Method
forward
( self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor] = None,
code/5.6 LLaMALayer.py:13
Method
forward
(self, input)
code/7.3 LoRA基础.py:22
Method
forward
(self, hidden_states)
code/5.1 RMSNorm.py:7
Function
split_prompt_and_responses_hh
(sample)
code/8.2 DPO实践.py:39